@sonicjs-cms/core 2.5.0 → 2.6.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.
Files changed (92) hide show
  1. package/dist/{app-Db0AfT5F.d.cts → app-DV27cjPy.d.cts} +1 -1
  2. package/dist/{app-Db0AfT5F.d.ts → app-DV27cjPy.d.ts} +1 -1
  3. package/dist/{chunk-YIXSSJWD.cjs → chunk-63K7XXRX.cjs} +5 -5
  4. package/dist/{chunk-YIXSSJWD.cjs.map → chunk-63K7XXRX.cjs.map} +1 -1
  5. package/dist/{chunk-BHNDALCA.js → chunk-7DL5SPPX.js} +6 -4
  6. package/dist/chunk-7DL5SPPX.js.map +1 -0
  7. package/dist/{chunk-AZLU3ROK.cjs → chunk-BZC4FYW7.cjs} +4 -4
  8. package/dist/chunk-BZC4FYW7.cjs.map +1 -0
  9. package/dist/chunk-CLIH2T74.js +403 -0
  10. package/dist/chunk-CLIH2T74.js.map +1 -0
  11. package/dist/{chunk-VEL7QRYI.js → chunk-EVZOVYLO.js} +9 -2
  12. package/dist/chunk-EVZOVYLO.js.map +1 -0
  13. package/dist/{chunk-TJTWRO4G.js → chunk-EYWR6UA2.js} +4 -4
  14. package/dist/{chunk-TJTWRO4G.js.map → chunk-EYWR6UA2.js.map} +1 -1
  15. package/dist/{chunk-3YUHXWSG.js → chunk-F332TENF.js} +3 -3
  16. package/dist/{chunk-3YUHXWSG.js.map → chunk-F332TENF.js.map} +1 -1
  17. package/dist/{chunk-OJZ45OJD.js → chunk-F6GZURXJ.js} +2243 -539
  18. package/dist/chunk-F6GZURXJ.js.map +1 -0
  19. package/dist/{chunk-I4V3VZWF.cjs → chunk-IIRVZSP2.cjs} +9 -2
  20. package/dist/chunk-IIRVZSP2.cjs.map +1 -0
  21. package/dist/{chunk-V5LBQN3I.js → chunk-KA2PDJNB.js} +4 -4
  22. package/dist/chunk-KA2PDJNB.js.map +1 -0
  23. package/dist/{chunk-AVPUX57O.js → chunk-KAOWRIFD.js} +3 -3
  24. package/dist/{chunk-AVPUX57O.js.map → chunk-KAOWRIFD.js.map} +1 -1
  25. package/dist/{chunk-ILZ3DP4I.cjs → chunk-MPT5PA6U.cjs} +24 -2
  26. package/dist/chunk-MPT5PA6U.cjs.map +1 -0
  27. package/dist/{chunk-UAQL2VWX.cjs → chunk-N7TDLOUE.cjs} +2406 -703
  28. package/dist/chunk-N7TDLOUE.cjs.map +1 -0
  29. package/dist/{chunk-YYV3XQOQ.cjs → chunk-T3YIKW2A.cjs} +7 -7
  30. package/dist/{chunk-YYV3XQOQ.cjs.map → chunk-T3YIKW2A.cjs.map} +1 -1
  31. package/dist/{chunk-LWG2MWDA.cjs → chunk-Y72M3MVX.cjs} +4 -4
  32. package/dist/{chunk-LWG2MWDA.cjs.map → chunk-Y72M3MVX.cjs.map} +1 -1
  33. package/dist/{chunk-SGAG6FD3.js → chunk-YFJJU26H.js} +24 -2
  34. package/dist/chunk-YFJJU26H.js.map +1 -0
  35. package/dist/chunk-YHW27CBV.cjs +406 -0
  36. package/dist/chunk-YHW27CBV.cjs.map +1 -0
  37. package/dist/{chunk-ZWV3EBZ7.cjs → chunk-YMTTGHEK.cjs} +6 -4
  38. package/dist/chunk-YMTTGHEK.cjs.map +1 -0
  39. package/dist/{collection-config-B6gMPunn.d.cts → collection-config-BF95LgQb.d.cts} +1 -1
  40. package/dist/{collection-config-B6gMPunn.d.ts → collection-config-BF95LgQb.d.ts} +1 -1
  41. package/dist/index.cjs +2156 -300
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +503 -8
  44. package/dist/index.d.ts +503 -8
  45. package/dist/index.js +1893 -44
  46. package/dist/index.js.map +1 -1
  47. package/dist/middleware.cjs +24 -24
  48. package/dist/middleware.d.cts +1 -1
  49. package/dist/middleware.d.ts +1 -1
  50. package/dist/middleware.js +3 -3
  51. package/dist/migrations-QNYAWQLB.cjs +13 -0
  52. package/dist/{migrations-NIEUFG44.cjs.map → migrations-QNYAWQLB.cjs.map} +1 -1
  53. package/dist/migrations-R6NQBKQV.js +4 -0
  54. package/dist/{migrations-TGZKJKV4.js.map → migrations-R6NQBKQV.js.map} +1 -1
  55. package/dist/{plugin-bootstrap-dYhD9fQR.d.ts → plugin-bootstrap-CB-xaBfK.d.ts} +2 -2
  56. package/dist/{plugin-bootstrap-SHsdjE6X.d.cts → plugin-bootstrap-U-cw9jn3.d.cts} +2 -2
  57. package/dist/plugins.cjs +11 -11
  58. package/dist/plugins.js +2 -2
  59. package/dist/routes.cjs +27 -27
  60. package/dist/routes.d.cts +1 -1
  61. package/dist/routes.d.ts +1 -1
  62. package/dist/routes.js +7 -7
  63. package/dist/services.cjs +16 -16
  64. package/dist/services.d.cts +2 -2
  65. package/dist/services.d.ts +2 -2
  66. package/dist/services.js +2 -2
  67. package/dist/templates.cjs +17 -17
  68. package/dist/templates.js +2 -2
  69. package/dist/types.d.cts +1 -1
  70. package/dist/types.d.ts +1 -1
  71. package/dist/utils.cjs +14 -14
  72. package/dist/utils.d.cts +1 -1
  73. package/dist/utils.d.ts +1 -1
  74. package/dist/utils.js +1 -1
  75. package/migrations/029_ai_search_plugin.sql +45 -0
  76. package/package.json +4 -2
  77. package/dist/chunk-AI2JJIJX.cjs +0 -211
  78. package/dist/chunk-AI2JJIJX.cjs.map +0 -1
  79. package/dist/chunk-AZLU3ROK.cjs.map +0 -1
  80. package/dist/chunk-BHNDALCA.js.map +0 -1
  81. package/dist/chunk-I4V3VZWF.cjs.map +0 -1
  82. package/dist/chunk-ILZ3DP4I.cjs.map +0 -1
  83. package/dist/chunk-OJZ45OJD.js.map +0 -1
  84. package/dist/chunk-QDBNW7KQ.js +0 -209
  85. package/dist/chunk-QDBNW7KQ.js.map +0 -1
  86. package/dist/chunk-SGAG6FD3.js.map +0 -1
  87. package/dist/chunk-UAQL2VWX.cjs.map +0 -1
  88. package/dist/chunk-V5LBQN3I.js.map +0 -1
  89. package/dist/chunk-VEL7QRYI.js.map +0 -1
  90. package/dist/chunk-ZWV3EBZ7.cjs.map +0 -1
  91. package/dist/migrations-NIEUFG44.cjs +0 -13
  92. package/dist/migrations-TGZKJKV4.js +0 -4
@@ -1,70 +1,70 @@
1
1
  'use strict';
2
2
 
3
- var chunkYIXSSJWD_cjs = require('./chunk-YIXSSJWD.cjs');
4
- var chunkAZLU3ROK_cjs = require('./chunk-AZLU3ROK.cjs');
3
+ var chunk63K7XXRX_cjs = require('./chunk-63K7XXRX.cjs');
4
+ var chunkBZC4FYW7_cjs = require('./chunk-BZC4FYW7.cjs');
5
5
  require('./chunk-IGJUBJBW.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "renderFilterBar", {
10
10
  enumerable: true,
11
- get: function () { return chunkYIXSSJWD_cjs.renderFilterBar; }
11
+ get: function () { return chunk63K7XXRX_cjs.renderFilterBar; }
12
12
  });
13
13
  Object.defineProperty(exports, "getConfirmationDialogScript", {
14
14
  enumerable: true,
15
- get: function () { return chunkAZLU3ROK_cjs.getConfirmationDialogScript; }
15
+ get: function () { return chunkBZC4FYW7_cjs.getConfirmationDialogScript; }
16
16
  });
17
17
  Object.defineProperty(exports, "renderAdminLayout", {
18
18
  enumerable: true,
19
- get: function () { return chunkAZLU3ROK_cjs.renderAdminLayout; }
19
+ get: function () { return chunkBZC4FYW7_cjs.renderAdminLayout; }
20
20
  });
21
21
  Object.defineProperty(exports, "renderAdminLayoutCatalyst", {
22
22
  enumerable: true,
23
- get: function () { return chunkAZLU3ROK_cjs.renderAdminLayoutCatalyst; }
23
+ get: function () { return chunkBZC4FYW7_cjs.renderAdminLayoutCatalyst; }
24
24
  });
25
25
  Object.defineProperty(exports, "renderAlert", {
26
26
  enumerable: true,
27
- get: function () { return chunkAZLU3ROK_cjs.renderAlert; }
27
+ get: function () { return chunkBZC4FYW7_cjs.renderAlert; }
28
28
  });
29
29
  Object.defineProperty(exports, "renderCheckboxPage", {
30
30
  enumerable: true,
31
- get: function () { return chunkAZLU3ROK_cjs.renderCheckboxPage; }
31
+ get: function () { return chunkBZC4FYW7_cjs.renderCheckboxPage; }
32
32
  });
33
33
  Object.defineProperty(exports, "renderCodeExamplesList", {
34
34
  enumerable: true,
35
- get: function () { return chunkAZLU3ROK_cjs.renderCodeExamplesList; }
35
+ get: function () { return chunkBZC4FYW7_cjs.renderCodeExamplesList; }
36
36
  });
37
37
  Object.defineProperty(exports, "renderConfirmationDialog", {
38
38
  enumerable: true,
39
- get: function () { return chunkAZLU3ROK_cjs.renderConfirmationDialog; }
39
+ get: function () { return chunkBZC4FYW7_cjs.renderConfirmationDialog; }
40
40
  });
41
41
  Object.defineProperty(exports, "renderDesignPage", {
42
42
  enumerable: true,
43
- get: function () { return chunkAZLU3ROK_cjs.renderDesignPage; }
43
+ get: function () { return chunkBZC4FYW7_cjs.renderDesignPage; }
44
44
  });
45
45
  Object.defineProperty(exports, "renderForm", {
46
46
  enumerable: true,
47
- get: function () { return chunkAZLU3ROK_cjs.renderForm; }
47
+ get: function () { return chunkBZC4FYW7_cjs.renderForm; }
48
48
  });
49
49
  Object.defineProperty(exports, "renderFormField", {
50
50
  enumerable: true,
51
- get: function () { return chunkAZLU3ROK_cjs.renderFormField; }
51
+ get: function () { return chunkBZC4FYW7_cjs.renderFormField; }
52
52
  });
53
53
  Object.defineProperty(exports, "renderLogo", {
54
54
  enumerable: true,
55
- get: function () { return chunkAZLU3ROK_cjs.renderLogo; }
55
+ get: function () { return chunkBZC4FYW7_cjs.renderLogo; }
56
56
  });
57
57
  Object.defineProperty(exports, "renderPagination", {
58
58
  enumerable: true,
59
- get: function () { return chunkAZLU3ROK_cjs.renderPagination; }
59
+ get: function () { return chunkBZC4FYW7_cjs.renderPagination; }
60
60
  });
61
61
  Object.defineProperty(exports, "renderTable", {
62
62
  enumerable: true,
63
- get: function () { return chunkAZLU3ROK_cjs.renderTable; }
63
+ get: function () { return chunkBZC4FYW7_cjs.renderTable; }
64
64
  });
65
65
  Object.defineProperty(exports, "renderTestimonialsList", {
66
66
  enumerable: true,
67
- get: function () { return chunkAZLU3ROK_cjs.renderTestimonialsList; }
67
+ get: function () { return chunkBZC4FYW7_cjs.renderTestimonialsList; }
68
68
  });
69
69
  //# sourceMappingURL=templates.cjs.map
70
70
  //# sourceMappingURL=templates.cjs.map
package/dist/templates.js CHANGED
@@ -1,5 +1,5 @@
1
- export { renderFilterBar } from './chunk-AVPUX57O.js';
2
- export { getConfirmationDialogScript, renderAdminLayout, renderAdminLayoutCatalyst, renderAlert, renderCheckboxPage, renderCodeExamplesList, renderConfirmationDialog, renderDesignPage, renderForm, renderFormField, renderLogo, renderPagination, renderTable, renderTestimonialsList } from './chunk-V5LBQN3I.js';
1
+ export { renderFilterBar } from './chunk-KAOWRIFD.js';
2
+ export { getConfirmationDialogScript, renderAdminLayout, renderAdminLayoutCatalyst, renderAlert, renderCheckboxPage, renderCodeExamplesList, renderConfirmationDialog, renderDesignPage, renderForm, renderFormField, renderLogo, renderPagination, renderTable, renderTestimonialsList } from './chunk-KA2PDJNB.js';
3
3
  import './chunk-V4OQ3NZ2.js';
4
4
  //# sourceMappingURL=templates.js.map
5
5
  //# sourceMappingURL=templates.js.map
package/dist/types.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BlockDefinition, b as BlockDefinitions, c as CollectionConfig, d as CollectionConfigModule, C as CollectionSchema, e as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-B6gMPunn.cjs';
1
+ export { B as BlockDefinition, b as BlockDefinitions, c as CollectionConfig, d as CollectionConfigModule, C as CollectionSchema, e as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-BF95LgQb.cjs';
2
2
  export { A as AuthService, C as ContentService, v as HOOKS, k as HookContext, H as HookHandler, u as HookName, l as HookSystem, p as MediaService, M as ModelRelationship, P as Plugin, g as PluginAdminPage, r as PluginBuilderOptions, h as PluginComponent, b as PluginConfig, a as PluginContext, j as PluginHook, q as PluginLogger, n as PluginManager, i as PluginMenuItem, d as PluginMiddleware, e as PluginModel, m as PluginRegistry, c as PluginRoutes, f as PluginService, o as PluginStatus, t as PluginValidationResult, s as PluginValidator, S as ScopedHookSystem } from './plugin-zvZpaiP5.cjs';
3
3
  export { P as PluginManifest } from './plugin-manifest-Dpy8wxIB.cjs';
4
4
  export { b as TelemetryConfig, T as TelemetryEvent, c as TelemetryIdentity, a as TelemetryProperties } from './telemetry-UiD1i9GS.cjs';
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BlockDefinition, b as BlockDefinitions, c as CollectionConfig, d as CollectionConfigModule, C as CollectionSchema, e as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-B6gMPunn.js';
1
+ export { B as BlockDefinition, b as BlockDefinitions, c as CollectionConfig, d as CollectionConfigModule, C as CollectionSchema, e as CollectionSyncResult, a as FieldConfig, F as FieldType } from './collection-config-BF95LgQb.js';
2
2
  export { A as AuthService, C as ContentService, v as HOOKS, k as HookContext, H as HookHandler, u as HookName, l as HookSystem, p as MediaService, M as ModelRelationship, P as Plugin, g as PluginAdminPage, r as PluginBuilderOptions, h as PluginComponent, b as PluginConfig, a as PluginContext, j as PluginHook, q as PluginLogger, n as PluginManager, i as PluginMenuItem, d as PluginMiddleware, e as PluginModel, m as PluginRegistry, c as PluginRoutes, f as PluginService, o as PluginStatus, t as PluginValidationResult, s as PluginValidator, S as ScopedHookSystem } from './plugin-zvZpaiP5.js';
3
3
  export { P as PluginManifest } from './plugin-manifest-Dpy8wxIB.js';
4
4
  export { b as TelemetryConfig, T as TelemetryEvent, c as TelemetryIdentity, a as TelemetryProperties } from './telemetry-UiD1i9GS.js';
package/dist/utils.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkZWV3EBZ7_cjs = require('./chunk-ZWV3EBZ7.cjs');
3
+ var chunkYMTTGHEK_cjs = require('./chunk-YMTTGHEK.cjs');
4
4
  var chunkP3XDZL6Q_cjs = require('./chunk-P3XDZL6Q.cjs');
5
5
  var chunkRCQ2HIQD_cjs = require('./chunk-RCQ2HIQD.cjs');
6
6
  require('./chunk-IGJUBJBW.cjs');
@@ -9,55 +9,55 @@ require('./chunk-IGJUBJBW.cjs');
9
9
 
10
10
  Object.defineProperty(exports, "QueryFilterBuilder", {
11
11
  enumerable: true,
12
- get: function () { return chunkZWV3EBZ7_cjs.QueryFilterBuilder; }
12
+ get: function () { return chunkYMTTGHEK_cjs.QueryFilterBuilder; }
13
13
  });
14
14
  Object.defineProperty(exports, "SONICJS_VERSION", {
15
15
  enumerable: true,
16
- get: function () { return chunkZWV3EBZ7_cjs.SONICJS_VERSION; }
16
+ get: function () { return chunkYMTTGHEK_cjs.SONICJS_VERSION; }
17
17
  });
18
18
  Object.defineProperty(exports, "TemplateRenderer", {
19
19
  enumerable: true,
20
- get: function () { return chunkZWV3EBZ7_cjs.TemplateRenderer; }
20
+ get: function () { return chunkYMTTGHEK_cjs.TemplateRenderer; }
21
21
  });
22
22
  Object.defineProperty(exports, "buildQuery", {
23
23
  enumerable: true,
24
- get: function () { return chunkZWV3EBZ7_cjs.buildQuery; }
24
+ get: function () { return chunkYMTTGHEK_cjs.buildQuery; }
25
25
  });
26
26
  Object.defineProperty(exports, "escapeHtml", {
27
27
  enumerable: true,
28
- get: function () { return chunkZWV3EBZ7_cjs.escapeHtml; }
28
+ get: function () { return chunkYMTTGHEK_cjs.escapeHtml; }
29
29
  });
30
30
  Object.defineProperty(exports, "generateSlug", {
31
31
  enumerable: true,
32
- get: function () { return chunkZWV3EBZ7_cjs.generateSlug; }
32
+ get: function () { return chunkYMTTGHEK_cjs.generateSlug; }
33
33
  });
34
34
  Object.defineProperty(exports, "getBlocksFieldConfig", {
35
35
  enumerable: true,
36
- get: function () { return chunkZWV3EBZ7_cjs.getBlocksFieldConfig; }
36
+ get: function () { return chunkYMTTGHEK_cjs.getBlocksFieldConfig; }
37
37
  });
38
38
  Object.defineProperty(exports, "getCoreVersion", {
39
39
  enumerable: true,
40
- get: function () { return chunkZWV3EBZ7_cjs.getCoreVersion; }
40
+ get: function () { return chunkYMTTGHEK_cjs.getCoreVersion; }
41
41
  });
42
42
  Object.defineProperty(exports, "parseBlocksValue", {
43
43
  enumerable: true,
44
- get: function () { return chunkZWV3EBZ7_cjs.parseBlocksValue; }
44
+ get: function () { return chunkYMTTGHEK_cjs.parseBlocksValue; }
45
45
  });
46
46
  Object.defineProperty(exports, "renderTemplate", {
47
47
  enumerable: true,
48
- get: function () { return chunkZWV3EBZ7_cjs.renderTemplate; }
48
+ get: function () { return chunkYMTTGHEK_cjs.renderTemplate; }
49
49
  });
50
50
  Object.defineProperty(exports, "sanitizeInput", {
51
51
  enumerable: true,
52
- get: function () { return chunkZWV3EBZ7_cjs.sanitizeInput; }
52
+ get: function () { return chunkYMTTGHEK_cjs.sanitizeInput; }
53
53
  });
54
54
  Object.defineProperty(exports, "sanitizeObject", {
55
55
  enumerable: true,
56
- get: function () { return chunkZWV3EBZ7_cjs.sanitizeObject; }
56
+ get: function () { return chunkYMTTGHEK_cjs.sanitizeObject; }
57
57
  });
58
58
  Object.defineProperty(exports, "templateRenderer", {
59
59
  enumerable: true,
60
- get: function () { return chunkZWV3EBZ7_cjs.templateRenderer; }
60
+ get: function () { return chunkYMTTGHEK_cjs.templateRenderer; }
61
61
  });
62
62
  Object.defineProperty(exports, "generateInstallationId", {
63
63
  enumerable: true,
package/dist/utils.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { c as FilterCondition, d as FilterGroup, F as FilterOperator, f as QueryFilter, Q as QueryFilterBuilder, h as QueryResult, S as SONICJS_VERSION, T as TemplateRenderer, b as buildQuery, e as escapeHtml, g as getCoreVersion, m as metricsTracker, r as renderTemplate, s as sanitizeInput, a as sanitizeObject, t as templateRenderer } from './version-vktVAxhe.cjs';
2
2
  import { b as TelemetryConfig } from './telemetry-UiD1i9GS.cjs';
3
- import { b as BlockDefinitions } from './collection-config-B6gMPunn.cjs';
3
+ import { b as BlockDefinitions } from './collection-config-BF95LgQb.cjs';
4
4
 
5
5
  /**
6
6
  * Slug generation utilities for creating URL-friendly slugs
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { c as FilterCondition, d as FilterGroup, F as FilterOperator, f as QueryFilter, Q as QueryFilterBuilder, h as QueryResult, S as SONICJS_VERSION, T as TemplateRenderer, b as buildQuery, e as escapeHtml, g as getCoreVersion, m as metricsTracker, r as renderTemplate, s as sanitizeInput, a as sanitizeObject, t as templateRenderer } from './version-vktVAxhe.js';
2
2
  import { b as TelemetryConfig } from './telemetry-UiD1i9GS.js';
3
- import { b as BlockDefinitions } from './collection-config-B6gMPunn.js';
3
+ import { b as BlockDefinitions } from './collection-config-BF95LgQb.js';
4
4
 
5
5
  /**
6
6
  * Slug generation utilities for creating URL-friendly slugs
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { QueryFilterBuilder, SONICJS_VERSION, TemplateRenderer, buildQuery, escapeHtml, generateSlug, getBlocksFieldConfig, getCoreVersion, parseBlocksValue, renderTemplate, sanitizeInput, sanitizeObject, templateRenderer } from './chunk-BHNDALCA.js';
1
+ export { QueryFilterBuilder, SONICJS_VERSION, TemplateRenderer, buildQuery, escapeHtml, generateSlug, getBlocksFieldConfig, getCoreVersion, parseBlocksValue, renderTemplate, sanitizeInput, sanitizeObject, templateRenderer } from './chunk-7DL5SPPX.js';
2
2
  export { generateInstallationId, generateProjectId, getDefaultTelemetryConfig, getTelemetryConfig, isTelemetryEnabled, sanitizeErrorMessage, sanitizeRoute, shouldSkipEvent } from './chunk-X7ZAEI5S.js';
3
3
  export { metricsTracker } from './chunk-FICTAGD4.js';
4
4
  import './chunk-V4OQ3NZ2.js';
@@ -0,0 +1,45 @@
1
+ -- AI Search plugin settings
2
+ CREATE TABLE IF NOT EXISTS ai_search_settings (
3
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
4
+ enabled BOOLEAN DEFAULT 0,
5
+ ai_mode_enabled BOOLEAN DEFAULT 1,
6
+ selected_collections TEXT, -- JSON array of collection IDs to index
7
+ dismissed_collections TEXT, -- JSON array of collection IDs user chose not to index
8
+ autocomplete_enabled BOOLEAN DEFAULT 1,
9
+ cache_duration INTEGER DEFAULT 1, -- hours
10
+ results_limit INTEGER DEFAULT 20,
11
+ index_media BOOLEAN DEFAULT 0,
12
+ index_status TEXT, -- JSON object with status per collection
13
+ last_indexed_at INTEGER,
14
+ created_at INTEGER DEFAULT (strftime('%s', 'now') * 1000),
15
+ updated_at INTEGER DEFAULT (strftime('%s', 'now') * 1000)
16
+ );
17
+
18
+ -- Search history/analytics
19
+ CREATE TABLE IF NOT EXISTS ai_search_history (
20
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
21
+ query TEXT NOT NULL,
22
+ mode TEXT, -- 'ai' or 'keyword'
23
+ results_count INTEGER,
24
+ user_id INTEGER,
25
+ created_at INTEGER DEFAULT (strftime('%s', 'now') * 1000)
26
+ );
27
+
28
+ -- Index metadata tracking (per collection)
29
+ CREATE TABLE IF NOT EXISTS ai_search_index_meta (
30
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
31
+ collection_id INTEGER NOT NULL,
32
+ collection_name TEXT NOT NULL, -- Cache collection name for display
33
+ total_items INTEGER DEFAULT 0,
34
+ indexed_items INTEGER DEFAULT 0,
35
+ last_sync_at INTEGER,
36
+ status TEXT DEFAULT 'pending', -- 'pending', 'indexing', 'completed', 'error'
37
+ error_message TEXT,
38
+ UNIQUE(collection_id)
39
+ );
40
+
41
+ -- Indexes for performance
42
+ CREATE INDEX IF NOT EXISTS idx_ai_search_history_created_at ON ai_search_history(created_at);
43
+ CREATE INDEX IF NOT EXISTS idx_ai_search_history_mode ON ai_search_history(mode);
44
+ CREATE INDEX IF NOT EXISTS idx_ai_search_index_meta_collection_id ON ai_search_index_meta(collection_id);
45
+ CREATE INDEX IF NOT EXISTS idx_ai_search_index_meta_status ON ai_search_index_meta(status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonicjs-cms/core",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Core framework for SonicJS headless CMS - Edge-first, TypeScript-native CMS built for Cloudflare Workers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -68,6 +68,7 @@
68
68
  "lint": "eslint src/",
69
69
  "lint:fix": "eslint src/ --fix",
70
70
  "test": "vitest --run",
71
+ "test:cov": "vitest --run --coverage",
71
72
  "test:watch": "vitest",
72
73
  "prepublishOnly": "npm run build"
73
74
  },
@@ -107,6 +108,7 @@
107
108
  "semver": "^7.7.3"
108
109
  },
109
110
  "devDependencies": {
111
+ "@vitest/coverage-v8": "^4.0.5",
110
112
  "@cloudflare/workers-types": "^4.20251014.0",
111
113
  "@types/node": "^24.9.2",
112
114
  "@typescript-eslint/eslint-plugin": "^8.50.0",
@@ -114,7 +116,7 @@
114
116
  "drizzle-orm": "^0.44.7",
115
117
  "eslint": "^9.39.2",
116
118
  "glob": "^10.5.0",
117
- "hono": "^4.10.4",
119
+ "hono": "^4.11.4",
118
120
  "tsup": "^8.5.0",
119
121
  "typescript": "^5.9.3",
120
122
  "vitest": "^4.0.5",
@@ -1,211 +0,0 @@
1
- 'use strict';
2
-
3
- require('hono');
4
- require('zod');
5
-
6
- // src/plugins/sdk/plugin-builder.ts
7
- var PluginBuilder = class _PluginBuilder {
8
- plugin;
9
- constructor(options) {
10
- this.plugin = {
11
- name: options.name,
12
- version: options.version,
13
- description: options.description,
14
- author: options.author,
15
- dependencies: options.dependencies,
16
- routes: [],
17
- middleware: [],
18
- models: [],
19
- services: [],
20
- adminPages: [],
21
- adminComponents: [],
22
- menuItems: [],
23
- hooks: []
24
- };
25
- }
26
- /**
27
- * Create a new plugin builder
28
- */
29
- static create(options) {
30
- return new _PluginBuilder(options);
31
- }
32
- /**
33
- * Add metadata to the plugin
34
- */
35
- metadata(metadata) {
36
- Object.assign(this.plugin, metadata);
37
- return this;
38
- }
39
- /**
40
- * Add routes to plugin
41
- */
42
- addRoutes(routes) {
43
- this.plugin.routes = [...this.plugin.routes || [], ...routes];
44
- return this;
45
- }
46
- /**
47
- * Add a single route to plugin
48
- */
49
- addRoute(path, handler, options) {
50
- const route = {
51
- path,
52
- handler,
53
- ...options
54
- };
55
- this.plugin.routes = [...this.plugin.routes || [], route];
56
- return this;
57
- }
58
- /**
59
- * Add middleware to plugin
60
- */
61
- addMiddleware(middleware) {
62
- this.plugin.middleware = [...this.plugin.middleware || [], ...middleware];
63
- return this;
64
- }
65
- /**
66
- * Add a single middleware to plugin
67
- */
68
- addSingleMiddleware(name, handler, options) {
69
- const middleware = {
70
- name,
71
- handler,
72
- ...options
73
- };
74
- this.plugin.middleware = [...this.plugin.middleware || [], middleware];
75
- return this;
76
- }
77
- /**
78
- * Add models to plugin
79
- */
80
- addModels(models) {
81
- this.plugin.models = [...this.plugin.models || [], ...models];
82
- return this;
83
- }
84
- /**
85
- * Add a single model to plugin
86
- */
87
- addModel(name, options) {
88
- const model = {
89
- name,
90
- ...options
91
- };
92
- this.plugin.models = [...this.plugin.models || [], model];
93
- return this;
94
- }
95
- /**
96
- * Add services to plugin
97
- */
98
- addServices(services) {
99
- this.plugin.services = [...this.plugin.services || [], ...services];
100
- return this;
101
- }
102
- /**
103
- * Add a single service to plugin
104
- */
105
- addService(name, implementation, options) {
106
- const service = {
107
- name,
108
- implementation,
109
- ...options
110
- };
111
- this.plugin.services = [...this.plugin.services || [], service];
112
- return this;
113
- }
114
- /**
115
- * Add admin pages to plugin
116
- */
117
- addAdminPages(pages) {
118
- this.plugin.adminPages = [...this.plugin.adminPages || [], ...pages];
119
- return this;
120
- }
121
- /**
122
- * Add a single admin page to plugin
123
- */
124
- addAdminPage(path, title, component, options) {
125
- const page = {
126
- path,
127
- title,
128
- component,
129
- ...options
130
- };
131
- this.plugin.adminPages = [...this.plugin.adminPages || [], page];
132
- return this;
133
- }
134
- /**
135
- * Add admin components to plugin
136
- */
137
- addComponents(components) {
138
- this.plugin.adminComponents = [...this.plugin.adminComponents || [], ...components];
139
- return this;
140
- }
141
- /**
142
- * Add a single admin component to plugin
143
- */
144
- addComponent(name, template, options) {
145
- const component = {
146
- name,
147
- template,
148
- ...options
149
- };
150
- this.plugin.adminComponents = [...this.plugin.adminComponents || [], component];
151
- return this;
152
- }
153
- /**
154
- * Add menu items to plugin
155
- */
156
- addMenuItems(items) {
157
- this.plugin.menuItems = [...this.plugin.menuItems || [], ...items];
158
- return this;
159
- }
160
- /**
161
- * Add a single menu item to plugin
162
- */
163
- addMenuItem(label, path, options) {
164
- const menuItem = {
165
- label,
166
- path,
167
- ...options
168
- };
169
- this.plugin.menuItems = [...this.plugin.menuItems || [], menuItem];
170
- return this;
171
- }
172
- /**
173
- * Add hooks to plugin
174
- */
175
- addHooks(hooks) {
176
- this.plugin.hooks = [...this.plugin.hooks || [], ...hooks];
177
- return this;
178
- }
179
- /**
180
- * Add a single hook to plugin
181
- */
182
- addHook(name, handler, options) {
183
- const hook = {
184
- name,
185
- handler,
186
- ...options
187
- };
188
- this.plugin.hooks = [...this.plugin.hooks || [], hook];
189
- return this;
190
- }
191
- /**
192
- * Add lifecycle hooks
193
- */
194
- lifecycle(hooks) {
195
- Object.assign(this.plugin, hooks);
196
- return this;
197
- }
198
- /**
199
- * Build the plugin
200
- */
201
- build() {
202
- if (!this.plugin.name || !this.plugin.version) {
203
- throw new Error("Plugin name and version are required");
204
- }
205
- return this.plugin;
206
- }
207
- };
208
-
209
- exports.PluginBuilder = PluginBuilder;
210
- //# sourceMappingURL=chunk-AI2JJIJX.cjs.map
211
- //# sourceMappingURL=chunk-AI2JJIJX.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/plugins/sdk/plugin-builder.ts"],"names":[],"mappings":";;;;;;AAUO,IAAM,aAAA,GAAN,MAAM,cAAA,CAAc;AAAA,EACjB,MAAA;AAAA,EAER,YAAY,OAAA,EAA+B;AACzC,IAAA,IAAA,CAAK,MAAA,GAAS;AAAA,MACZ,MAAM,OAAA,CAAQ,IAAA;AAAA,MACd,SAAS,OAAA,CAAQ,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AAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA,GAAgB;AAEd,IAAA,IAAI,CAAC,IAAA,CAAK,MAAA,CAAO,QAAQ,CAAC,IAAA,CAAK,OAAO,OAAA,EAAS;AAC7C,MAAA,MAAM,IAAI,MAAM,sCAAsC,CAAA;AAAA,IACxD;AAEA,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AACF","file":"chunk-AI2JJIJX.cjs","sourcesContent":["/**\n * Plugin Builder SDK\n * \n * Provides a fluent API for building SonicJS plugins\n */\n\nimport { Hono } from 'hono'\nimport { z } from 'zod'\nimport { Plugin, PluginBuilderOptions, PluginRoutes, PluginMiddleware, PluginModel, PluginService, PluginAdminPage, PluginComponent, PluginHook, PluginMenuItem } from '../types'\n\nexport class PluginBuilder {\n private plugin: Partial<Plugin>\n\n constructor(options: PluginBuilderOptions) {\n this.plugin = {\n name: options.name,\n version: options.version,\n description: options.description,\n author: options.author,\n dependencies: options.dependencies,\n routes: [],\n middleware: [],\n models: [],\n services: [],\n adminPages: [],\n adminComponents: [],\n menuItems: [],\n hooks: []\n }\n }\n\n /**\n * Create a new plugin builder\n */\n static create(options: PluginBuilderOptions): PluginBuilder {\n return new PluginBuilder(options)\n }\n\n /**\n * Add metadata to the plugin\n */\n metadata(metadata: {\n description?: string\n author?: Plugin['author']\n license?: string\n compatibility?: string\n dependencies?: string[]\n }): PluginBuilder {\n Object.assign(this.plugin, metadata)\n return this\n }\n\n /**\n * Add routes to plugin\n */\n addRoutes(routes: PluginRoutes[]): PluginBuilder {\n this.plugin.routes = [...(this.plugin.routes || []), ...routes]\n return this\n }\n\n /**\n * Add a single route to plugin\n */\n addRoute(path: string, handler: Hono, options?: {\n description?: string\n requiresAuth?: boolean\n roles?: string[]\n priority?: number\n }): PluginBuilder {\n const route: PluginRoutes = {\n path,\n handler,\n ...options\n }\n this.plugin.routes = [...(this.plugin.routes || []), route]\n return this\n }\n\n /**\n * Add middleware to plugin\n */\n addMiddleware(middleware: PluginMiddleware[]): PluginBuilder {\n this.plugin.middleware = [...(this.plugin.middleware || []), ...middleware]\n return this\n }\n\n /**\n * Add a single middleware to plugin\n */\n addSingleMiddleware(name: string, handler: any, options?: {\n description?: string\n priority?: number\n routes?: string[]\n global?: boolean\n }): PluginBuilder {\n const middleware: PluginMiddleware = {\n name,\n handler,\n ...options\n }\n this.plugin.middleware = [...(this.plugin.middleware || []), middleware]\n return this\n }\n\n /**\n * Add models to plugin\n */\n addModels(models: PluginModel[]): PluginBuilder {\n this.plugin.models = [...(this.plugin.models || []), ...models]\n return this\n }\n\n /**\n * Add a single model to plugin\n */\n addModel(name: string, options: {\n tableName: string\n schema: z.ZodSchema\n migrations: string[]\n relationships?: PluginModel['relationships']\n extendsContent?: boolean\n }): PluginBuilder {\n const model: PluginModel = {\n name,\n ...options\n }\n this.plugin.models = [...(this.plugin.models || []), model]\n return this\n }\n\n /**\n * Add services to plugin\n */\n addServices(services: PluginService[]): PluginBuilder {\n this.plugin.services = [...(this.plugin.services || []), ...services]\n return this\n }\n\n /**\n * Add a single service to plugin\n */\n addService(name: string, implementation: any, options?: {\n description?: string\n dependencies?: string[]\n singleton?: boolean\n }): PluginBuilder {\n const service: PluginService = {\n name,\n implementation,\n ...options\n }\n this.plugin.services = [...(this.plugin.services || []), service]\n return this\n }\n\n /**\n * Add admin pages to plugin\n */\n addAdminPages(pages: PluginAdminPage[]): PluginBuilder {\n this.plugin.adminPages = [...(this.plugin.adminPages || []), ...pages]\n return this\n }\n\n /**\n * Add a single admin page to plugin\n */\n addAdminPage(path: string, title: string, component: string, options?: {\n description?: string\n permissions?: string[]\n icon?: string\n menuItem?: PluginMenuItem\n }): PluginBuilder {\n const page: PluginAdminPage = {\n path,\n title,\n component,\n ...options\n }\n this.plugin.adminPages = [...(this.plugin.adminPages || []), page]\n return this\n }\n\n /**\n * Add admin components to plugin\n */\n addComponents(components: PluginComponent[]): PluginBuilder {\n this.plugin.adminComponents = [...(this.plugin.adminComponents || []), ...components]\n return this\n }\n\n /**\n * Add a single admin component to plugin\n */\n addComponent(name: string, template: (props: any) => string, options?: {\n description?: string\n propsSchema?: z.ZodSchema\n }): PluginBuilder {\n const component: PluginComponent = {\n name,\n template,\n ...options\n }\n this.plugin.adminComponents = [...(this.plugin.adminComponents || []), component]\n return this\n }\n\n /**\n * Add menu items to plugin\n */\n addMenuItems(items: PluginMenuItem[]): PluginBuilder {\n this.plugin.menuItems = [...(this.plugin.menuItems || []), ...items]\n return this\n }\n\n /**\n * Add a single menu item to plugin\n */\n addMenuItem(label: string, path: string, options?: {\n icon?: string\n order?: number\n parent?: string\n permissions?: string[]\n }): PluginBuilder {\n const menuItem: PluginMenuItem = {\n label,\n path,\n ...options\n }\n this.plugin.menuItems = [...(this.plugin.menuItems || []), menuItem]\n return this\n }\n\n /**\n * Add hooks to plugin\n */\n addHooks(hooks: PluginHook[]): PluginBuilder {\n this.plugin.hooks = [...(this.plugin.hooks || []), ...hooks]\n return this\n }\n\n /**\n * Add a single hook to plugin\n */\n addHook(name: string, handler: any, options?: {\n priority?: number\n description?: string\n }): PluginBuilder {\n const hook: PluginHook = {\n name,\n handler,\n ...options\n }\n this.plugin.hooks = [...(this.plugin.hooks || []), hook]\n return this\n }\n\n /**\n * Add lifecycle hooks\n */\n lifecycle(hooks: {\n install?: Plugin['install']\n uninstall?: Plugin['uninstall']\n activate?: Plugin['activate']\n deactivate?: Plugin['deactivate']\n configure?: Plugin['configure']\n }): PluginBuilder {\n Object.assign(this.plugin, hooks)\n return this\n }\n\n /**\n * Build the plugin\n */\n build(): Plugin {\n // Validate required fields\n if (!this.plugin.name || !this.plugin.version) {\n throw new Error('Plugin name and version are required')\n }\n\n return this.plugin as Plugin\n }\n}\n\n/**\n * Helper functions for common plugin patterns\n */\nexport class PluginHelpers {\n /**\n * Create a REST API route for a model\n */\n static createModelAPI(modelName: string, options?: {\n basePath?: string\n permissions?: {\n read?: string[]\n write?: string[]\n delete?: string[]\n }\n }): Hono {\n const app = new Hono()\n const basePath = options?.basePath || `/${modelName.toLowerCase()}`\n\n // GET /models - List all\n app.get('/', async (c) => {\n // Implementation would depend on the model service\n return c.json({ message: `List ${modelName} items` })\n })\n\n // GET /models/:id - Get by ID\n app.get('/:id', async (c) => {\n const id = c.req.param('id')\n return c.json({ message: `Get ${modelName} with ID: ${id}` })\n })\n\n // POST /models - Create new\n app.post('/', async (c) => {\n return c.json({ message: `Create new ${modelName}` })\n })\n\n // PUT /models/:id - Update\n app.put('/:id', async (c) => {\n const id = c.req.param('id')\n return c.json({ message: `Update ${modelName} with ID: ${id}` })\n })\n\n // DELETE /models/:id - Delete\n app.delete('/:id', async (c) => {\n const id = c.req.param('id')\n return c.json({ message: `Delete ${modelName} with ID: ${id}` })\n })\n\n return app\n }\n\n /**\n * Create an admin CRUD interface for a model\n */\n static createAdminInterface(modelName: string, options?: {\n icon?: string\n permissions?: string[]\n fields?: Array<{\n name: string\n type: string\n label: string\n required?: boolean\n }>\n }): {\n pages: PluginAdminPage[]\n menuItems: PluginMenuItem[]\n } {\n const basePath = `/admin/${modelName.toLowerCase()}`\n const displayName = modelName.charAt(0).toUpperCase() + modelName.slice(1)\n\n const pages: PluginAdminPage[] = [\n {\n path: basePath,\n title: `${displayName} List`,\n component: `${modelName}List`,\n permissions: options?.permissions,\n icon: options?.icon\n },\n {\n path: `${basePath}/new`,\n title: `New ${displayName}`,\n component: `${modelName}Form`,\n permissions: options?.permissions\n },\n {\n path: `${basePath}/:id`,\n title: `Edit ${displayName}`,\n component: `${modelName}Form`,\n permissions: options?.permissions\n }\n ]\n\n const menuItems: PluginMenuItem[] = [\n {\n label: displayName,\n path: basePath,\n icon: options?.icon,\n permissions: options?.permissions\n }\n ]\n\n return { pages, menuItems }\n }\n\n /**\n * Create a database migration for a model\n */\n static createMigration(tableName: string, fields: Array<{\n name: string\n type: 'TEXT' | 'INTEGER' | 'REAL' | 'BLOB'\n nullable?: boolean\n primaryKey?: boolean\n unique?: boolean\n defaultValue?: string\n }>): string {\n const columns = fields.map(field => {\n let definition = `${field.name} ${field.type}`\n \n if (field.primaryKey) definition += ' PRIMARY KEY'\n if (field.unique) definition += ' UNIQUE'\n if (!field.nullable && !field.primaryKey) definition += ' NOT NULL'\n if (field.defaultValue) definition += ` DEFAULT ${field.defaultValue}`\n \n return definition\n }).join(',\\n ')\n\n return `\nCREATE TABLE IF NOT EXISTS ${tableName} (\n ${columns},\n created_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),\n updated_at INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))\n);\n\nCREATE TRIGGER IF NOT EXISTS ${tableName}_updated_at\n AFTER UPDATE ON ${tableName}\nBEGIN\n UPDATE ${tableName} SET updated_at = strftime('%s', 'now') WHERE id = NEW.id;\nEND;\n `.trim()\n }\n\n /**\n * Create a Zod schema for a model\n */\n static createSchema(fields: Array<{\n name: string\n type: 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object'\n optional?: boolean\n required?: boolean\n validation?: any\n items?: any\n properties?: Record<string, any>\n }>): z.ZodSchema {\n const shape: Record<string, z.ZodTypeAny> = {}\n\n const applyValidation = (field: any, schema: z.ZodTypeAny) => {\n if (field.validation) {\n if (field.type === 'string' && field.validation.min) {\n schema = (schema as z.ZodString).min(field.validation.min)\n }\n if (field.type === 'string' && field.validation.max) {\n schema = (schema as z.ZodString).max(field.validation.max)\n }\n if (field.type === 'string' && field.validation.email) {\n schema = (schema as z.ZodString).email()\n }\n if (field.type === 'string' && field.validation.url) {\n schema = (schema as z.ZodString).url()\n }\n }\n return schema\n }\n\n const buildSchema = (field: any): z.ZodTypeAny => {\n let schema: z.ZodTypeAny\n\n switch (field.type) {\n case 'string':\n schema = z.string()\n break\n case 'number':\n schema = z.number()\n break\n case 'boolean':\n schema = z.boolean()\n break\n case 'date':\n schema = z.date()\n break\n case 'array':\n if (field.items?.blocks && typeof field.items.blocks === 'object') {\n const discriminator = typeof field.items.discriminator === 'string' && field.items.discriminator\n ? field.items.discriminator\n : 'blockType'\n const blockSchemas = Object.entries(field.items.blocks).map(([blockName, blockDef]: [string, any]) => {\n const properties = blockDef?.properties && typeof blockDef.properties === 'object'\n ? blockDef.properties\n : {}\n const blockShape: Record<string, z.ZodTypeAny> = {\n [discriminator]: z.literal(blockName)\n }\n\n Object.entries(properties).forEach(([propertyName, propertyConfigRaw]) => {\n const propertyConfig = propertyConfigRaw && typeof propertyConfigRaw === 'object'\n ? propertyConfigRaw as Record<string, any>\n : {}\n const propertySchema = buildSchema({\n ...propertyConfig,\n optional: propertyConfig.required === false\n })\n blockShape[propertyName] = propertySchema\n })\n\n return z.object(blockShape)\n })\n\n if (blockSchemas.length === 1 && blockSchemas[0]) {\n schema = z.array(blockSchemas[0])\n } else if (blockSchemas.length > 1) {\n schema = z.array(z.union(blockSchemas as unknown as [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]))\n } else {\n schema = z.array(z.any())\n }\n break\n }\n if (field.items) {\n schema = z.array(buildSchema(field.items))\n break\n }\n schema = z.array(z.any())\n break\n case 'object':\n if (field.properties && typeof field.properties === 'object') {\n const objectShape: Record<string, z.ZodTypeAny> = {}\n Object.entries(field.properties).forEach(([propertyName, propertyConfigRaw]) => {\n const propertyConfig = propertyConfigRaw && typeof propertyConfigRaw === 'object'\n ? propertyConfigRaw as Record<string, any>\n : {}\n objectShape[propertyName] = buildSchema({\n ...propertyConfig,\n optional: propertyConfig.required === false\n })\n })\n schema = z.object(objectShape)\n break\n }\n schema = z.object({})\n break\n default:\n schema = z.any()\n }\n\n schema = applyValidation(field, schema)\n\n if (field.optional || field.required === false) {\n schema = schema.optional()\n }\n\n return schema\n }\n\n for (const field of fields) {\n shape[field.name] = buildSchema(field)\n }\n\n return z.object(shape)\n }\n}\n\n/**\n * Common plugin templates\n */\nexport class PluginTemplates {\n /**\n * Create a simple content type plugin\n */\n static contentType(name: string, fields: Array<{\n name: string\n type: string\n label: string\n required?: boolean\n }>): Plugin {\n const builder = PluginBuilder.create({\n name: `${name}-content-type`,\n version: '1.0.0',\n description: `${name} content type plugin`\n })\n\n // Create model\n const schema = PluginHelpers.createSchema(\n fields.map(f => ({\n name: f.name,\n type: f.type as any,\n optional: !f.required\n }))\n )\n\n const migration = PluginHelpers.createMigration(\n name.toLowerCase(),\n fields.map(f => ({\n name: f.name,\n type: 'TEXT',\n nullable: !f.required\n }))\n )\n\n builder.addModel(name, {\n tableName: name.toLowerCase(),\n schema,\n migrations: [migration],\n extendsContent: true\n })\n\n // Create API routes\n const apiRoutes = PluginHelpers.createModelAPI(name)\n builder.addRoute(`/api/${name.toLowerCase()}`, apiRoutes)\n\n // Create admin interface\n const { pages, menuItems } = PluginHelpers.createAdminInterface(name, {\n fields\n })\n builder.addAdminPages(pages)\n builder.addMenuItems(menuItems)\n\n return builder.build()\n }\n\n /**\n * Create an analytics plugin\n */\n static analytics(name: string, options?: {\n endpoints?: string[]\n dashboard?: boolean\n }): Plugin {\n const builder = PluginBuilder.create({\n name: `${name}-analytics`,\n version: '1.0.0',\n description: `${name} analytics plugin`\n })\n\n // Add middleware to track requests\n builder.addSingleMiddleware('analytics-tracker', async (c: any, next: any) => {\n const start = Date.now()\n await next()\n const duration = Date.now() - start\n \n // Log analytics data\n console.info(`Analytics: ${c.req.method} ${c.req.path} - ${duration}ms`)\n }, {\n global: true,\n priority: 1\n })\n\n // Add analytics API\n const analyticsAPI = new Hono()\n analyticsAPI.get('/stats', (c) => {\n return c.json({ message: 'Analytics stats' })\n })\n builder.addRoute('/api/analytics', analyticsAPI)\n\n // Add dashboard if requested\n if (options?.dashboard) {\n builder.addAdminPage(\n '/analytics',\n 'Analytics Dashboard',\n 'AnalyticsDashboard',\n {\n description: 'View analytics and statistics',\n icon: 'chart-bar'\n }\n )\n\n builder.addMenuItem('Analytics', '/admin/analytics', {\n icon: 'chart-bar',\n order: 100\n })\n }\n\n return builder.build()\n }\n}\n"]}