@gravito/monolith 2.0.0 → 3.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @gravito/monolith
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @gravito/core@1.2.1
9
+ - @gravito/mass@3.0.1
10
+
11
+ ## 3.0.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+ - @gravito/core@1.2.0
17
+ - @gravito/mass@3.0.0
18
+
3
19
  ## 2.0.0
4
20
 
5
21
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -345,7 +345,9 @@ var FormRequest = class {
345
345
  for (const issue of issues) {
346
346
  const path = Array.isArray(issue.path) ? issue.path.join(".") : issue.path || "root";
347
347
  const key = path.replace(/^\//, "").replace(/\//g, ".");
348
- if (!errors[key]) errors[key] = [];
348
+ if (!errors[key]) {
349
+ errors[key] = [];
350
+ }
349
351
  errors[key].push(issue.message || "Validation failed");
350
352
  }
351
353
  return ctx.json(
@@ -410,8 +412,7 @@ var OrbitMonolith = class {
410
412
  }
411
413
  core.adapter.use("*", async (c, next) => {
412
414
  c.set("content", manager);
413
- await next();
414
- return void 0;
415
+ return await next();
415
416
  });
416
417
  core.logger.info("Orbit Monolith installed \u2B1B\uFE0F");
417
418
  }
package/dist/index.d.cts CHANGED
@@ -4,6 +4,10 @@ import { TSchema } from '@gravito/mass';
4
4
  export { Schema } from '@gravito/mass';
5
5
  import { Hono } from 'hono';
6
6
 
7
+ /**
8
+ * Represents a single content item (file).
9
+ * @public
10
+ */
7
11
  interface ContentItem {
8
12
  slug: string;
9
13
  body: string;
@@ -11,9 +15,17 @@ interface ContentItem {
11
15
  meta: Record<string, any>;
12
16
  raw: string;
13
17
  }
18
+ /**
19
+ * Configuration for a content collection.
20
+ * @public
21
+ */
14
22
  interface CollectionConfig {
15
23
  path: string;
16
24
  }
25
+ /**
26
+ * Manages fetching, parsing, and caching of filesystem-based content.
27
+ * @public
28
+ */
17
29
  declare class ContentManager {
18
30
  private rootDir;
19
31
  private collections;
@@ -67,10 +79,27 @@ declare class Sanitizer {
67
79
  static clean(data: any): any;
68
80
  }
69
81
 
82
+ /**
83
+ * Base class for all Monolith Controllers.
84
+ *
85
+ * Provides basic functionality for calling actions and sanitizing data.
86
+ *
87
+ * @public
88
+ * @since 3.0.0
89
+ */
70
90
  declare abstract class BaseController {
71
91
  protected sanitizer: Sanitizer;
72
92
  call(ctx: GravitoContext, method: string): Promise<Response>;
73
93
  }
94
+ /**
95
+ * Controller class with request context awareness and helper methods.
96
+ *
97
+ * This class provides a more feature-rich base for controllers that
98
+ * need direct access to the request context and common response helpers.
99
+ *
100
+ * @public
101
+ * @since 3.0.0
102
+ */
74
103
  declare abstract class Controller {
75
104
  protected context: GravitoContext;
76
105
  /**
@@ -107,6 +136,15 @@ declare abstract class Controller {
107
136
  static call(method: string): any;
108
137
  }
109
138
 
139
+ /**
140
+ * Base class for Monolith Form Requests.
141
+ *
142
+ * Provides a structured way to handle request validation and authorization
143
+ * for the Monolith architecture.
144
+ *
145
+ * @public
146
+ * @since 3.0.0
147
+ */
110
148
  declare abstract class FormRequest {
111
149
  protected context: GravitoContext;
112
150
  /**
@@ -135,6 +173,10 @@ declare abstract class FormRequest {
135
173
  static middleware(): any;
136
174
  }
137
175
 
176
+ /**
177
+ * Utility for registering resourceful routes.
178
+ * @public
179
+ */
138
180
  declare class RouterHelper {
139
181
  /**
140
182
  * Register standard resource routes for a controller.
@@ -155,10 +197,19 @@ declare module '@gravito/core' {
155
197
  content: ContentManager;
156
198
  }
157
199
  }
200
+ /**
201
+ * Configuration for Orbit Monolith (Content Engine).
202
+ * @public
203
+ */
158
204
  interface ContentConfig {
159
205
  root?: string;
160
206
  collections?: Record<string, CollectionConfig>;
161
207
  }
208
+ /**
209
+ * Orbit Monolith Service.
210
+ * Provides flat-file CMS capabilities to Gravito applications.
211
+ * @public
212
+ */
162
213
  declare class OrbitMonolith implements GravitoOrbit {
163
214
  private config;
164
215
  constructor(config?: ContentConfig);
package/dist/index.d.ts CHANGED
@@ -4,6 +4,10 @@ import { TSchema } from '@gravito/mass';
4
4
  export { Schema } from '@gravito/mass';
5
5
  import { Hono } from 'hono';
6
6
 
7
+ /**
8
+ * Represents a single content item (file).
9
+ * @public
10
+ */
7
11
  interface ContentItem {
8
12
  slug: string;
9
13
  body: string;
@@ -11,9 +15,17 @@ interface ContentItem {
11
15
  meta: Record<string, any>;
12
16
  raw: string;
13
17
  }
18
+ /**
19
+ * Configuration for a content collection.
20
+ * @public
21
+ */
14
22
  interface CollectionConfig {
15
23
  path: string;
16
24
  }
25
+ /**
26
+ * Manages fetching, parsing, and caching of filesystem-based content.
27
+ * @public
28
+ */
17
29
  declare class ContentManager {
18
30
  private rootDir;
19
31
  private collections;
@@ -67,10 +79,27 @@ declare class Sanitizer {
67
79
  static clean(data: any): any;
68
80
  }
69
81
 
82
+ /**
83
+ * Base class for all Monolith Controllers.
84
+ *
85
+ * Provides basic functionality for calling actions and sanitizing data.
86
+ *
87
+ * @public
88
+ * @since 3.0.0
89
+ */
70
90
  declare abstract class BaseController {
71
91
  protected sanitizer: Sanitizer;
72
92
  call(ctx: GravitoContext, method: string): Promise<Response>;
73
93
  }
94
+ /**
95
+ * Controller class with request context awareness and helper methods.
96
+ *
97
+ * This class provides a more feature-rich base for controllers that
98
+ * need direct access to the request context and common response helpers.
99
+ *
100
+ * @public
101
+ * @since 3.0.0
102
+ */
74
103
  declare abstract class Controller {
75
104
  protected context: GravitoContext;
76
105
  /**
@@ -107,6 +136,15 @@ declare abstract class Controller {
107
136
  static call(method: string): any;
108
137
  }
109
138
 
139
+ /**
140
+ * Base class for Monolith Form Requests.
141
+ *
142
+ * Provides a structured way to handle request validation and authorization
143
+ * for the Monolith architecture.
144
+ *
145
+ * @public
146
+ * @since 3.0.0
147
+ */
110
148
  declare abstract class FormRequest {
111
149
  protected context: GravitoContext;
112
150
  /**
@@ -135,6 +173,10 @@ declare abstract class FormRequest {
135
173
  static middleware(): any;
136
174
  }
137
175
 
176
+ /**
177
+ * Utility for registering resourceful routes.
178
+ * @public
179
+ */
138
180
  declare class RouterHelper {
139
181
  /**
140
182
  * Register standard resource routes for a controller.
@@ -155,10 +197,19 @@ declare module '@gravito/core' {
155
197
  content: ContentManager;
156
198
  }
157
199
  }
200
+ /**
201
+ * Configuration for Orbit Monolith (Content Engine).
202
+ * @public
203
+ */
158
204
  interface ContentConfig {
159
205
  root?: string;
160
206
  collections?: Record<string, CollectionConfig>;
161
207
  }
208
+ /**
209
+ * Orbit Monolith Service.
210
+ * Provides flat-file CMS capabilities to Gravito applications.
211
+ * @public
212
+ */
162
213
  declare class OrbitMonolith implements GravitoOrbit {
163
214
  private config;
164
215
  constructor(config?: ContentConfig);
package/dist/index.js CHANGED
@@ -303,7 +303,9 @@ var FormRequest = class {
303
303
  for (const issue of issues) {
304
304
  const path = Array.isArray(issue.path) ? issue.path.join(".") : issue.path || "root";
305
305
  const key = path.replace(/^\//, "").replace(/\//g, ".");
306
- if (!errors[key]) errors[key] = [];
306
+ if (!errors[key]) {
307
+ errors[key] = [];
308
+ }
307
309
  errors[key].push(issue.message || "Validation failed");
308
310
  }
309
311
  return ctx.json(
@@ -368,8 +370,7 @@ var OrbitMonolith = class {
368
370
  }
369
371
  core.adapter.use("*", async (c, next) => {
370
372
  c.set("content", manager);
371
- await next();
372
- return void 0;
373
+ return await next();
373
374
  });
374
375
  core.logger.info("Orbit Monolith installed \u2B1B\uFE0F");
375
376
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/monolith",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Enterprise monolith framework for Gravito Galaxy",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -17,6 +17,7 @@
17
17
  "build": "tsup src/index.ts --format esm,cjs --dts",
18
18
  "test": "bun test",
19
19
  "test:coverage": "bun test --coverage --coverage-threshold=80",
20
+ "test:ci": "bun test --coverage --coverage-threshold=80",
20
21
  "typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck"
21
22
  },
22
23
  "keywords": [
@@ -3,6 +3,10 @@ import { join, parse } from 'node:path'
3
3
  import matter from 'gray-matter'
4
4
  import { marked } from 'marked'
5
5
 
6
+ /**
7
+ * Represents a single content item (file).
8
+ * @public
9
+ */
6
10
  export interface ContentItem {
7
11
  slug: string
8
12
  body: string // The HTML content
@@ -12,10 +16,18 @@ export interface ContentItem {
12
16
  raw: string // The raw markdown
13
17
  }
14
18
 
19
+ /**
20
+ * Configuration for a content collection.
21
+ * @public
22
+ */
15
23
  export interface CollectionConfig {
16
24
  path: string // e.g., 'resources/content/docs'
17
25
  }
18
26
 
27
+ /**
28
+ * Manages fetching, parsing, and caching of filesystem-based content.
29
+ * @public
30
+ */
19
31
  export class ContentManager {
20
32
  private collections = new Map<string, CollectionConfig>()
21
33
  // Simple memory cache: collection:locale:slug -> ContentItem
package/src/Controller.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  import type { GravitoContext } from '@gravito/core'
2
2
  import { Sanitizer } from './Sanitizer.js'
3
3
 
4
+ /**
5
+ * Base class for all Monolith Controllers.
6
+ *
7
+ * Provides basic functionality for calling actions and sanitizing data.
8
+ *
9
+ * @public
10
+ * @since 3.0.0
11
+ */
4
12
  export abstract class BaseController {
5
13
  protected sanitizer = new Sanitizer()
6
14
 
@@ -14,6 +22,15 @@ export abstract class BaseController {
14
22
  }
15
23
  }
16
24
 
25
+ /**
26
+ * Controller class with request context awareness and helper methods.
27
+ *
28
+ * This class provides a more feature-rich base for controllers that
29
+ * need direct access to the request context and common response helpers.
30
+ *
31
+ * @public
32
+ * @since 3.0.0
33
+ */
17
34
  export abstract class Controller {
18
35
  protected context!: GravitoContext
19
36
 
@@ -2,6 +2,15 @@ import type { GravitoContext, GravitoNext } from '@gravito/core'
2
2
  import { type TSchema, validate } from '@gravito/mass'
3
3
  import { Sanitizer } from './Sanitizer.js'
4
4
 
5
+ /**
6
+ * Base class for Monolith Form Requests.
7
+ *
8
+ * Provides a structured way to handle request validation and authorization
9
+ * for the Monolith architecture.
10
+ *
11
+ * @public
12
+ * @since 3.0.0
13
+ */
5
14
  export abstract class FormRequest {
6
15
  protected context!: GravitoContext
7
16
 
@@ -65,7 +74,9 @@ export abstract class FormRequest {
65
74
  for (const issue of issues) {
66
75
  const path = Array.isArray(issue.path) ? issue.path.join('.') : issue.path || 'root'
67
76
  const key = path.replace(/^\//, '').replace(/\//g, '.')
68
- if (!errors[key]) errors[key] = []
77
+ if (!errors[key]) {
78
+ errors[key] = []
79
+ }
69
80
  errors[key].push(issue.message || 'Validation failed')
70
81
  }
71
82
 
package/src/Router.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { Hono } from 'hono'
2
2
 
3
+ /**
4
+ * Utility for registering resourceful routes.
5
+ * @public
6
+ */
3
7
  export class RouterHelper {
4
8
  /**
5
9
  * Register standard resource routes for a controller.
package/src/index.ts CHANGED
@@ -7,11 +7,20 @@ declare module '@gravito/core' {
7
7
  }
8
8
  }
9
9
 
10
+ /**
11
+ * Configuration for Orbit Monolith (Content Engine).
12
+ * @public
13
+ */
10
14
  export interface ContentConfig {
11
15
  root?: string // Defaults to process.cwd()
12
16
  collections?: Record<string, CollectionConfig>
13
17
  }
14
18
 
19
+ /**
20
+ * Orbit Monolith Service.
21
+ * Provides flat-file CMS capabilities to Gravito applications.
22
+ * @public
23
+ */
15
24
  export class OrbitMonolith implements GravitoOrbit {
16
25
  constructor(private config: ContentConfig = {}) {}
17
26
 
@@ -32,8 +41,7 @@ export class OrbitMonolith implements GravitoOrbit {
32
41
  // Inject into request context
33
42
  core.adapter.use('*', async (c, next) => {
34
43
  c.set('content', manager)
35
- await next()
36
- return undefined
44
+ return await next()
37
45
  })
38
46
 
39
47
  core.logger.info('Orbit Monolith installed ⬛️')