@clidey/dory 0.1.0 → 0.2.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 (51) hide show
  1. package/README.md +1 -1
  2. package/docs/api-playground-demo.mdx +119 -0
  3. package/docs/api-reference/openapi.json +366 -0
  4. package/docs/api-reference/operations/create.mdx +5 -0
  5. package/docs/api-reference/operations/delete.mdx +5 -0
  6. package/docs/api-reference/operations/get.mdx +5 -0
  7. package/docs/api-reference/operations/update.mdx +5 -0
  8. package/docs/assets/dory.jpeg +0 -0
  9. package/docs/dory.json +12 -131
  10. package/docs/favicon.svg +75 -0
  11. package/docs/features.mdx +440 -0
  12. package/docs/introduction.mdx +44 -0
  13. package/docs/logo/logo.png +0 -0
  14. package/package.json +3 -2
  15. package/src/mdx/source.tsx +15 -4
  16. package/docs/README.md +0 -2
  17. package/docs/configuration/app-settings/feature-flags.mdx +0 -157
  18. package/docs/configuration/app-settings/user-settings.mdx +0 -201
  19. package/docs/configuration/installation-setup/env-vars.mdx +0 -198
  20. package/docs/configuration/installation-setup/installation.mdx +0 -127
  21. package/docs/integrations/analytics-monitoring/error-tracking.mdx +0 -199
  22. package/docs/integrations/analytics-monitoring/notifications.mdx +0 -189
  23. package/docs/integrations/analytics-monitoring/user-analytics.mdx +0 -182
  24. package/docs/integrations/shopify-integration/shopify-setup.mdx +0 -226
  25. package/docs/integrations/shopify-integration/shopify-webhooks.mdx +0 -207
  26. package/docs/overview/developer-overview/dev-architecture.mdx +0 -292
  27. package/docs/overview/product-intro/app-overview.mdx +0 -167
  28. package/docs/overview/product-intro/architecture.mdx +0 -203
  29. package/docs/overview/product-intro/core-concepts.mdx +0 -267
  30. package/docs/platform-admin/billing-subscriptions/billing.mdx +0 -176
  31. package/docs/platform-admin/system-maintenance/db-migrations.mdx +0 -184
  32. package/docs/platform-admin/system-maintenance/health-monitoring.mdx +0 -222
  33. package/docs/platform-admin/system-maintenance/queue-management.mdx +0 -234
  34. package/docs/platform-admin/user-team-management/teams.mdx +0 -170
  35. package/docs/platform-admin/user-team-management/users.mdx +0 -185
  36. package/docs/support/legal/dependency-analysis.mdx +0 -132
  37. package/docs/support/legal/privacy-terms.mdx +0 -73
  38. package/docs/support/troubleshooting/common-issues.mdx +0 -159
  39. package/docs/usage/api-usage/api-inventory.mdx +0 -213
  40. package/docs/usage/api-usage/api-products.mdx +0 -249
  41. package/docs/usage/api-usage/api-purchase-orders.mdx +0 -289
  42. package/docs/usage/api-usage/api-reports.mdx +0 -227
  43. package/docs/usage/api-usage/api-suppliers.mdx +0 -171
  44. package/docs/usage/api-usage/api-user-management.mdx +0 -171
  45. package/docs/usage/ui-workflows/bundles.mdx +0 -157
  46. package/docs/usage/ui-workflows/demand-planning.mdx +0 -210
  47. package/docs/usage/ui-workflows/favorites.mdx +0 -167
  48. package/docs/usage/ui-workflows/inventory-management.mdx +0 -179
  49. package/docs/usage/ui-workflows/onboarding.mdx +0 -215
  50. package/docs/usage/ui-workflows/purchase-orders.mdx +0 -200
  51. package/docs/usage/ui-workflows/reports.mdx +0 -257
@@ -0,0 +1,440 @@
1
+ ---
2
+ title: 'Features'
3
+ description: 'Overview of available components and features'
4
+ ---
5
+
6
+ ## Headings Examples
7
+
8
+ ```mdx
9
+ # Heading 1
10
+ ```
11
+ # Heading 1
12
+
13
+ ```mdx
14
+ ## Heading 2
15
+ ```
16
+ # Heading 2
17
+
18
+ ```mdx
19
+ ### Heading 3
20
+ ```
21
+ # Heading 3
22
+ ```mdx
23
+ #### Heading 4
24
+ ```
25
+ # Heading 4
26
+ ```mdx
27
+ ##### Heading 5
28
+ ```
29
+ # Heading 5
30
+ ```mdx
31
+ ###### Heading 6
32
+ ```
33
+ # Heading 6
34
+
35
+ <br />
36
+
37
+ ## Lists Examples
38
+
39
+ ```mdx
40
+ - List item 1
41
+ - List item 2
42
+ - List item 3
43
+ ```
44
+
45
+ - List item 1
46
+ - List item 2
47
+ - List item 3
48
+
49
+ ```mdx
50
+ 1. List item 1
51
+ 2. List item 2
52
+ 3. List item 3
53
+ ```
54
+
55
+ 1. List item 1
56
+ 2. List item 2
57
+ 3. List item 3
58
+
59
+
60
+
61
+ <br />
62
+
63
+ ### Images
64
+
65
+ ```mdx
66
+ <img src="./assets/dory.jpeg" alt="Example image" className="object-cover w-64 h-64" />
67
+ ```
68
+
69
+ <img src="./assets/dory.jpeg" alt="Example image" className="object-cover w-64 h-64" />
70
+
71
+
72
+ <br />
73
+ <br />
74
+ <br />
75
+
76
+ ## Code Components
77
+
78
+ ### Code Block
79
+ ```typescript
80
+ function example() {
81
+ return "Hello World";
82
+ }
83
+ ```
84
+
85
+ ### Code Group Block
86
+
87
+ <CodeGroup>
88
+ ```typescript
89
+ function example(): string {
90
+ return "Hello World";
91
+ }
92
+ ```
93
+ ```javascript
94
+ function example() {
95
+ return "Hello World";
96
+ }
97
+ ```
98
+ </CodeGroup>
99
+
100
+
101
+ <br />
102
+ <br />
103
+ <br />
104
+
105
+
106
+ ## Interactive Components
107
+
108
+ ### Mermaid
109
+
110
+ ```mdx
111
+ mermaid
112
+ graph TD
113
+
114
+ %% Main Start
115
+ Start([Start Process]) --> Validate[Validate Input]
116
+
117
+ %% Decision Point
118
+ Validate -->|Valid| ProcessData{Is Data Clean?}
119
+ Validate -->|Invalid| Error[Show Error Message]
120
+
121
+ %% Clean Data Branch
122
+ ProcessData -->|Yes| Clean[Clean Data]
123
+ Clean --> Analyze[Analyze Data]
124
+
125
+ %% Dirty Data Branch
126
+ ProcessData -->|No| Notify[Notify User]
127
+ Notify --> Wait[Wait for Input]
128
+ Wait --> Validate
129
+
130
+ %% Parallel Branches After Analysis
131
+ Analyze --> Split1 & Split2
132
+
133
+ subgraph Parallel Tasks
134
+ Split1[Generate Report] --> Merge
135
+ Split2[Update Dashboard] --> Merge
136
+ end
137
+
138
+ Merge --> Decision2{Is More Input Needed?}
139
+ Decision2 -->|Yes| WaitMore[Wait for More Input]
140
+ WaitMore --> Validate
141
+ Decision2 -->|No| End([End Process])
142
+
143
+ %% Style and Class Definitions
144
+ classDef decision fill:#f9f,stroke:#333,stroke-width:2px;
145
+ class ProcessData,Decision2 decision;
146
+
147
+ ```
148
+
149
+ <strong>
150
+ <p>Note: Mermaid should be inside a code block with type "mermaid"</p>
151
+ </strong>
152
+
153
+ ```mermaid
154
+ graph TD
155
+
156
+ %% Main Start
157
+ Start([Start Process]) --> Validate[Validate Input]
158
+
159
+ %% Decision Point
160
+ Validate -->|Valid| ProcessData{Is Data Clean?}
161
+ Validate -->|Invalid| Error[Show Error Message]
162
+
163
+ %% Clean Data Branch
164
+ ProcessData -->|Yes| Clean[Clean Data]
165
+ Clean --> Analyze[Analyze Data]
166
+
167
+ %% Dirty Data Branch
168
+ ProcessData -->|No| Notify[Notify User]
169
+ Notify --> Wait[Wait for Input]
170
+ Wait --> Validate
171
+
172
+ %% Parallel Branches After Analysis
173
+ Analyze --> Split1 & Split2
174
+
175
+ subgraph Parallel Tasks
176
+ Split1[Generate Report] --> Merge
177
+ Split2[Update Dashboard] --> Merge
178
+ end
179
+
180
+ Merge --> Decision2{Is More Input Needed?}
181
+ Decision2 -->|Yes| WaitMore[Wait for More Input]
182
+ WaitMore --> Validate
183
+ Decision2 -->|No| End([End Process])
184
+
185
+ %% Style and Class Definitions
186
+ classDef decision fill:#f9f,stroke:#333,stroke-width:2px;
187
+ class ProcessData,Decision2 decision;
188
+
189
+ ```
190
+
191
+ ### Accordion
192
+
193
+ ```mdx
194
+ <AccordionGroup>
195
+ <Accordion title="First Section" icon="DocumentIcon">
196
+ This is the content of the first accordion section.
197
+ </Accordion>
198
+ <Accordion title="Second Section" icon="CodeBracketIcon">
199
+ This is the content of the second accordion section.
200
+ </Accordion>
201
+ </AccordionGroup>
202
+ ```
203
+
204
+ <AccordionGroup>
205
+ <Accordion title="First Section" icon="DocumentIcon">
206
+ This is the content of the first accordion section.
207
+ </Accordion>
208
+ <Accordion title="Second Section" icon="CodeBracketIcon">
209
+ This is the content of the second accordion section.
210
+ </Accordion>
211
+ </AccordionGroup>
212
+
213
+ ### Callouts
214
+
215
+ ```mdx
216
+ <Note>
217
+ This is a note callout with important information.
218
+ </Note>
219
+ ```
220
+
221
+ <Note>
222
+ This is a note callout with important information.
223
+ </Note>
224
+
225
+ ```mdx
226
+ <Warning>
227
+ This is a warning callout for critical information.
228
+ </Warning>
229
+ ```
230
+
231
+ <Warning>
232
+ This is a warning callout for critical information.
233
+ </Warning>
234
+
235
+ ```mdx
236
+ <Info>
237
+ This is an info callout for general information.
238
+ </Info>
239
+ ```
240
+
241
+ <Info>
242
+ This is an info callout for general information.
243
+ </Info>
244
+
245
+ ```mdx
246
+ <Tip>
247
+ This is a tip callout for helpful suggestions.
248
+ </Tip>
249
+ ```
250
+
251
+ <Tip>
252
+ This is a tip callout for helpful suggestions.
253
+ </Tip>
254
+
255
+ ```mdx
256
+ <Check>
257
+ This is a check callout for completed items.
258
+ </Check>
259
+ ```
260
+
261
+ <Check>
262
+ This is a check callout for completed items.
263
+ </Check>
264
+
265
+
266
+ <br />
267
+
268
+ ### Cards
269
+ ```mdx
270
+ <CardGroup cols={2}>
271
+ <Card
272
+ title="Example Card"
273
+ description="This is an example card component with an icon and title."
274
+ icon="FileText"
275
+ href="#"
276
+ />
277
+ <Card
278
+ title="Another Card"
279
+ description="This is another example card with different content."
280
+ icon="Code"
281
+ href="#"
282
+ />
283
+ </CardGroup>
284
+ ```
285
+
286
+ <CardGroup cols={2}>
287
+ <Card
288
+ title="Example Card"
289
+ description="This is an example card component with an icon and title."
290
+ icon="FileText"
291
+ href="#"
292
+ />
293
+ <Card
294
+ title="Another Card"
295
+ description="This is another example card with different content."
296
+ icon="Code"
297
+ href="#"
298
+ />
299
+ </CardGroup>
300
+
301
+ <br />
302
+
303
+ ### Expandable
304
+
305
+ ```mdx
306
+ <Expandable title="Click to Expand">
307
+ This is an expandable section that can be toggled.
308
+ </Expandable>
309
+ ```
310
+
311
+ <Expandable title="Click to Expand">
312
+ This is an expandable section that can be toggled.
313
+ </Expandable>
314
+
315
+ ### Source
316
+
317
+ ```mdx
318
+ <Source url="https://github.com/clidey/dory" paths={[
319
+ { path: "src/mdx/source.tsx", range: "1-46" },
320
+ { path: "docs/features.mdx", range: "318-322" },
321
+ ]} />
322
+ ```
323
+
324
+ <Source url="https://github.com/clidey/dory" paths={[
325
+ { path: "src/mdx/source.tsx", range: "1-46" },
326
+ { path: "docs/features.mdx", range: "318-322" },
327
+ ]} />
328
+
329
+ <br />
330
+ <br />
331
+ <br />
332
+
333
+
334
+ ## Special Components
335
+
336
+ ### Grids
337
+
338
+ #### Rows
339
+ ```mdx
340
+ <Row cols={2}>
341
+ <Icon icon="FileText" />
342
+ <Icon icon="CheckCircle" />
343
+ </Row>
344
+ ```
345
+
346
+ <Row cols={2}>
347
+ <Icon icon="FileText" />
348
+ <Icon icon="CheckCircle" />
349
+ </Row>
350
+
351
+ <br />
352
+
353
+ #### Columns
354
+
355
+ ```mdx
356
+ <Col>
357
+ <Icon icon="FileText" />
358
+ <Icon icon="FileText" />
359
+ </Col>
360
+ ```
361
+
362
+ <Col>
363
+ <Icon icon="FileText" />
364
+ <Icon icon="FileText" />
365
+ </Col>
366
+
367
+ <br />
368
+ <br />
369
+ <br />
370
+
371
+ ### Latex
372
+
373
+ ```mdx
374
+ <Latex>
375
+ E = mc^2
376
+ </Latex>
377
+ ```
378
+
379
+ <Latex>
380
+ E = mc^2
381
+ </Latex>
382
+
383
+ <br />
384
+ <br />
385
+ <br />
386
+
387
+ ### Tables
388
+
389
+ ```mdx
390
+ | Property | Description |
391
+ | -------- | ------------------------------------- |
392
+ | Name | Full name of user |
393
+ | Age | Reported age |
394
+ | Joined | Whether the user joined the community |
395
+ ```
396
+
397
+ | Property | Description |
398
+ | -------- | ------------------------------------- |
399
+ | Name | Full name of user |
400
+ | Age | Reported age |
401
+ | Joined | Whether the user joined the community |
402
+
403
+
404
+ ### Steps
405
+
406
+ ```mdx
407
+ <Steps>
408
+ <Step title="First Step">
409
+ This is the first step in the process.
410
+ </Step>
411
+ <Step title="Second Step">
412
+ This is the second step in the process.
413
+ </Step>
414
+ </Steps>
415
+ ```
416
+
417
+ <Steps>
418
+ <Step title="First Step">
419
+ This is the first step in the process.
420
+ </Step>
421
+ <Step title="Second Step">
422
+ This is the second step in the process.
423
+ </Step>
424
+ </Steps>
425
+
426
+ ### Icons
427
+
428
+ ```mdx
429
+ <Col rows={2}>
430
+ <Icon icon="Code" />
431
+ <Icon icon="FileText" />
432
+ <Icon icon="CheckCircle" />
433
+ </Col>
434
+ ```
435
+
436
+ <Row cols={3}>
437
+ <Icon icon="Code" />
438
+ <Icon icon="FileText" />
439
+ <Icon icon="CheckCircle" />
440
+ </Row>
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: 'Introduction'
3
+ description: 'Welcome to Docucod and Dory documentation'
4
+ ---
5
+
6
+ # Introduction
7
+
8
+ ## Welcome to Docucod and Dory
9
+
10
+ This documentation is powered by two complementary tools:
11
+
12
+ 1. **Docucod** - An AI-powered documentation assistant that automatically generates and maintains documentation
13
+ 2. **Dory** - A lightweight static site generator specifically designed to deploy Docucod-generated documentation
14
+
15
+ ## What is Docucod?
16
+
17
+ Docucod analyzes your codebase and automatically:
18
+ - Generates comprehensive documentation
19
+ - Updates existing documentation when code changes
20
+ - Maintains consistent style and formatting
21
+ - Ensures accuracy and completeness
22
+
23
+ ## What is Dory?
24
+
25
+ Dory is a lightweight static site generator built for developers who want fast, clean, and customizable documentation. It was created specifically to deploy Docucod-generated documentation with:
26
+
27
+ - 🧠 **Simple** — Drop in `.mdx` files and configure one `dory.json`
28
+ - ⚡ **Fast** — Instant hot reload in dev, quick static builds for prod
29
+ - 🌐 **Portable** — No SSR, no lock-in, deploy anywhere
30
+ - 🧩 **Flexible** — Hackable theme, readable codebase, minimal magic
31
+
32
+ ## Documentation Structure
33
+
34
+ This documentation is organized to help you:
35
+ - Get started quickly with both Docucod and Dory
36
+ - Understand core concepts and features
37
+ - Follow best practices and examples
38
+ - Find detailed API references
39
+
40
+ Let's begin exploring Docucod and Dory's capabilities!
41
+
42
+ <br/>
43
+ <br/>
44
+ <br/>
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clidey/dory",
3
3
  "private": false,
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "type": "module",
6
6
  "description": "A CLI tool for building and previewing documentation sites",
7
7
  "keywords": [
@@ -27,7 +27,8 @@
27
27
  "scripts": {
28
28
  "dev": "vite",
29
29
  "build": "tsc -b && vite build",
30
- "preview": "vite preview"
30
+ "preview": "vite preview",
31
+ "publish": "npm publish --access public"
31
32
  },
32
33
  "dependencies": {
33
34
  "@algolia/autocomplete-core": "^1.19.2",
@@ -1,6 +1,6 @@
1
1
  type PathRange = {
2
2
  path: string;
3
- range: string;
3
+ range?: string;
4
4
  };
5
5
 
6
6
  type SourceProps = {
@@ -10,7 +10,18 @@ type SourceProps = {
10
10
  };
11
11
 
12
12
  export const Source = ({ url, branch = "main", paths }: SourceProps) => {
13
- const createSourceUrl = (path: string, range: string) => {
13
+ const createSourceUrl = (path: string, range?: string) => {
14
+ if (!range) {
15
+ if (url.includes('github.com')) {
16
+ return `${url}/blob/${branch}/${path}`;
17
+ } else if (url.includes('bitbucket.org')) {
18
+ return `${url}/src/${branch}/${path}`;
19
+ } else if (url.includes('gitlab.com')) {
20
+ return `${url}/-/blob/${branch}/${path}`;
21
+ }
22
+ return url;
23
+ }
24
+
14
25
  const [start, end] = range.split('-');
15
26
 
16
27
  if (url.includes('github.com')) {
@@ -29,7 +40,7 @@ export const Source = ({ url, branch = "main", paths }: SourceProps) => {
29
40
  <p className="text-sm text-slate-900 dark:text-white">Sources:</p>
30
41
  <ul className="list-none pl-0 flex flex-wrap gap-2 mt-2">
31
42
  {paths.map(({ path, range }) => (
32
- <li key={path + range}>
43
+ <li key={path + (range || '')}>
33
44
  <a
34
45
  href={createSourceUrl(path, range)}
35
46
  target="_blank"
@@ -37,7 +48,7 @@ export const Source = ({ url, branch = "main", paths }: SourceProps) => {
37
48
  className="rounded px-3 py-1 font-mono text-sm text-slate-700 dark:text-slate-400 hover:opacity-80 transition-colors border border-slate-200 dark:border-slate-700"
38
49
  >
39
50
  {path}
40
- <span className="ml-2 opacity-70">{range}</span>
51
+ {range && <span className="ml-2 opacity-70">{range}</span>}
41
52
  </a>
42
53
  </li>
43
54
  ))}
package/docs/README.md DELETED
@@ -1,2 +0,0 @@
1
- # genie-internal
2
- Created via Docucod
@@ -1,157 +0,0 @@
1
- ---
2
- title: 'Feature Flags'
3
- description: 'Manage and understand feature flags affecting the application behavior.'
4
- ---
5
-
6
- # Feature Flags
7
-
8
- ## Purpose and Scope
9
-
10
- The Feature Flags module provides a centralized mechanism to enable or disable specific features within the Genie application dynamically. This approach allows controlled rollout, testing, and gradual adoption of new functionalities without deploying new code versions.
11
-
12
- This module primarily parses and validates feature flag configurations from environment variables and exposes them for use throughout the web and API services.
13
-
14
- ## Technical Overview
15
-
16
- Feature Flags are defined and validated using the `zod` schema validation library to ensure that flag values comply with expected types. Flags can generally be boolean or strings convertible to booleans (`"true"`), permitting flexibility in how environment variables are specified.
17
-
18
- The parsing logic safely attempts to read environment variables, falling back to an empty object on failure and capturing exceptions with Sentry for monitoring.
19
-
20
- ### Key Locations
21
-
22
- - **Web client feature flags:** Defined and parsed in `apps/web/src/utils/feature-flags.ts`.
23
- - **API service feature flags:** Defined under API config schemas in `apps/api/src/config/schemas/index.ts`.
24
-
25
-
26
- ## Core Concepts and Responsibilities
27
-
28
- - **Feature Flags Schema:** A set of typed mappings that describe each flag's expected type and optional presence.
29
- - Flags can be a boolean or a string (`"true"` interpreted as `true`) or undefined.
30
- - Certain flags have additional typed definitions such as arrays, e.g., `DEMAND_PLANNER_SHOP_ALLOW_LIST` which is an optional array of strings.
31
-
32
- - **Error Handling:** Parsing errors are logged to Sentry via `Sentry.captureException(error)` to facilitate early detection of misconfiguration.
33
-
34
- - **Environmental Scope:** Flags are read from environment variables prefixed with `NEXT_PUBLIC_FEATURE_FLAGS` for frontend exposure or `FEATURE_FLAGS` for the backend.
35
-
36
- - **Security and Scope:** Flags must be explicitly defined in environment configuration, preventing undefined or unexpected flags from being used.
37
-
38
- ## Code Structure
39
-
40
- ### `apps/web/src/utils/feature-flags.ts`
41
-
42
- This file implements the feature flag parsing logic for the web frontend.
43
-
44
- - `flagSchema`: Accepts either a boolean or a string representing booleans and transforms the string to a boolean.
45
- - `featureFlagsSchema`: Defines known feature flags such as `UI_PAGE`, `DEMAND_PLANNER`, `MOV`, `PAYMENT_TERMS`, and others. Some flags are booleans, others arrays of strings.
46
- - `parseFeatureFlags()`:
47
- - Attempts to JSON parse the environment variable `NEXT_PUBLIC_FEATURE_FLAGS`.
48
- - Validates it against the schema.
49
- - On error, logs to Sentry and returns an empty object.
50
- - `FEATURE_FLAGS`: Exported constant representing the parsed flags for app-wide consumption.
51
-
52
- ```ts
53
- import { z } from "zod";
54
- import * as Sentry from "@sentry/nextjs";
55
-
56
- const flagSchema = z.union([
57
- z.boolean(),
58
- z.string().transform((val) => val === "true")
59
- ]).optional();
60
-
61
- const featureFlagsSchema = z.object({
62
- UI_PAGE: flagSchema,
63
- DEMAND_PLANNER: flagSchema,
64
- DEMAND_PLANNER_SHOP_ALLOW_LIST: z.array(z.string()).optional(),
65
- MOV: flagSchema,
66
- PAYMENT_TERMS: flagSchema,
67
- MANUAL_STATUS: flagSchema,
68
- REPORTS_ALERTS: flagSchema,
69
- PAYMENTS_PAGE: flagSchema,
70
- });
71
-
72
- type FeatureFlags = z.infer<typeof featureFlagsSchema>;
73
-
74
- const parseFeatureFlags = (): FeatureFlags => {
75
- try {
76
- return featureFlagsSchema.parse(
77
- JSON.parse(process.env.NEXT_PUBLIC_FEATURE_FLAGS || "{}")
78
- );
79
- } catch (error) {
80
- Sentry.captureException(error);
81
- return {};
82
- }
83
- };
84
-
85
- export const FEATURE_FLAGS = parseFeatureFlags();
86
- ```
87
-
88
- ### `apps/api/src/config/schemas/index.ts`
89
-
90
- This file extends feature flag support within the API backend.
91
-
92
- - The API uses a similar schema (`featureFlagSchema`) that accepts booleans or strings convertible to booleans.
93
- - `featureFlagsSchema` is defined but currently empty (`z.object({} satisfies Record<string, typeof featureFlagSchema>)`).
94
- - The `FEATURE_FLAGS` environment variable is parsed and coerced to a string, then JSON parsed and validated.
95
-
96
- The config schema merges the feature flags, along with many other env vars, into a consolidated validation schema.
97
-
98
- ```ts
99
- const featureFlagSchema = z.union([
100
- z.boolean(),
101
- z.string().transform((value) => value === "true")
102
- ]).optional();
103
-
104
- const featureFlagsSchema = z.object(
105
- {} satisfies Record<string, typeof featureFlagSchema>
106
- );
107
-
108
- export type FeatureFlags = z.infer<typeof featureFlagsSchema>;
109
-
110
- export const configSchema = z.object({
111
- // ... other config fields ...
112
- FEATURE_FLAGS: z.coerce.string().optional().transform((jsonString = "{}") =>
113
- featureFlagsSchema.parse(JSON.parse(jsonString))
114
- ),
115
- // ... other config fields ...
116
- }).merge(databaseConfigSchema).strip();
117
- ```
118
-
119
- ## Environment & Configuration
120
-
121
- ### Environment Variables
122
-
123
- - `NEXT_PUBLIC_FEATURE_FLAGS` (frontend): JSON string representing flags.
124
- - `FEATURE_FLAGS` (API backend): JSON string representing flags.
125
-
126
- Example environment value for frontend (simplified):
127
-
128
- ```json
129
- {
130
- "UI_PAGE": true,
131
- "DEMAND_PLANNER": "true",
132
- "DEMAND_PLANNER_SHOP_ALLOW_LIST": ["shop1", "shop2"],
133
- "MOV": false
134
- }
135
- ```
136
-
137
- The environment variable must be valid JSON and correctly typed for each feature flag.
138
-
139
- ## Integration & System Boundaries
140
-
141
- - **Web UI:** Uses parsed `FEATURE_FLAGS` to enable/disable UI features.
142
- - **API:** Reads feature flags from environment on startup to alter backend behavior.
143
- - **Error Logging:** Parsing issues send errors to Sentry for diagnosis.
144
-
145
- ## Observability & Error Handling
146
-
147
- - Parsing errors of feature flags are monitored via Sentry.
148
- - Apps fall back gracefully to default empty flags on error, ensuring stability.
149
-
150
- ## Summary
151
-
152
- This feature flags module provides a robust, type-safe approach to managing application features dynamically through environment configuration. It ensures flags are validated on startup and exposes them as constants for consistent use across frontend and backend components.
153
-
154
- ## References
155
-
156
- - [Feature Flags in Web Frontend](apps/web/src/utils/feature-flags.ts)
157
- - [Feature Flags in API Config](apps/api/src/config/schemas/index.ts)