nextjs-studio 1.0.5 → 1.0.6

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.
Binary file
@@ -0,0 +1,117 @@
1
+ import { C as ContentEntry, F as FieldDefinition, T as TextField, L as LongTextField, N as NumberField, B as BooleanField, D as DateField, I as ISODate, S as SelectField, M as MultiSelectField, U as UrlField, H as HttpUrl, E as EmailField, a as Email, b as MediaField, c as MediaPath, O as ObjectField, A as ArrayField, d as IdField, e as ID, f as SlugField, g as Slug, R as RelationField, h as FormulaField, i as StatusField, j as CreatedTimeField, k as UpdatedTimeField, l as CollectionSchema, m as BaseField } from '../query-builder-BOu-D7a1.js';
2
+ export { n as Collection, o as CollectionConfig, p as CollectionTypeMap, q as EntryResult, r as FieldType, Q as QueryOptions, s as QueryResult, t as StudioConfig, u as queryCollection } from '../query-builder-BOu-D7a1.js';
3
+
4
+ /**
5
+ * @context Core layer — draft filter at src/core/draft-filter.ts
6
+ * @does Provides utilities to detect and filter draft content entries
7
+ * @depends src/shared/types.ts
8
+ * @do Add new draft detection heuristics here
9
+ * @dont Import from CLI or UI; access filesystem
10
+ */
11
+
12
+ declare function isDraft(entry: ContentEntry): boolean;
13
+ declare function filterDrafts(entries: ContentEntry[]): ContentEntry[];
14
+
15
+ /**
16
+ * @context Core layer — frontmatter binder at src/core/frontmatter-binder.ts
17
+ * @does Replaces {frontmatter.X} tokens in MDX body with actual frontmatter values
18
+ * @depends none
19
+ * @do Add new token patterns or transformation rules here
20
+ * @dont Import from CLI or UI; access filesystem
21
+ */
22
+ /**
23
+ * Replaces `{frontmatter.X}` tokens in the body with values from the data object.
24
+ * Supports dot-notation for nested values (e.g. `{frontmatter.author.name}`).
25
+ */
26
+ declare function bindFrontmatter(body: string, data: Record<string, unknown>): string;
27
+ /**
28
+ * Extracts all frontmatter token paths from the body.
29
+ */
30
+ declare function extractFrontmatterTokens(body: string): string[];
31
+
32
+ /**
33
+ * @context Core layer — locale parser at src/core/locale-parser.ts
34
+ * @does Extracts locale codes from filenames using the convention `slug.locale.mdx`
35
+ * @depends none
36
+ * @do Add new locale detection strategies here
37
+ * @dont Import from CLI or UI; access filesystem
38
+ */
39
+ /**
40
+ * Parses locale from a filename.
41
+ * Supports `post.pt.mdx`, `post.en-US.mdx` patterns.
42
+ * Returns undefined for files without a locale suffix.
43
+ */
44
+ declare function parseLocaleFromFilename(filename: string): string | undefined;
45
+ /**
46
+ * Removes the locale suffix from a slug.
47
+ * Handles both pre-slugify (`.pt`) and post-slugify (`-pt`) formats,
48
+ * since `@sindresorhus/slugify` converts dots to dashes.
49
+ * `post.pt` → `post`, `post-pt` → `post`, `post` → `post`
50
+ */
51
+ declare function stripLocaleFromSlug(slug: string, locale?: string): string;
52
+
53
+ /**
54
+ * @context Shared layer — schema inference types at src/shared/schema-types.ts
55
+ * @does Provides TypeScript utility types to infer typed data shapes from CollectionSchema
56
+ * @depends src/shared/fields.ts
57
+ * @do Add new schema-level inference utilities here
58
+ * @dont Import from CLI or UI; contain runtime logic or field definitions
59
+ */
60
+
61
+ /** Infer the TypeScript value type for a single field definition. */
62
+ type InferFieldValue<F extends FieldDefinition> = F extends TextField ? string : F extends LongTextField ? string : F extends NumberField ? number : F extends BooleanField ? boolean : F extends DateField ? F["includeTime"] extends true ? Date : ISODate : F extends SelectField ? F["options"][number]["value"] : F extends MultiSelectField ? Array<F["options"][number]["value"]> : F extends UrlField ? HttpUrl : F extends EmailField ? Email : F extends MediaField ? MediaPath : F extends ObjectField ? InferObjectFields<F["fields"]> : F extends ArrayField ? Array<InferObjectFields<F["itemFields"]>> : F extends IdField ? ID : F extends SlugField ? Slug : F extends RelationField ? F["multiple"] extends true ? ID[] : ID : F extends FormulaField ? F["resultType"] extends "number" ? number : F["resultType"] extends "boolean" ? boolean : string : F extends StatusField ? F["options"][number]["value"] : F extends CreatedTimeField ? Date : F extends UpdatedTimeField ? Date : never;
63
+ /**
64
+ * Infer a record type from an array of field definitions.
65
+ * Fields marked `required: false` become optional (`T | undefined`).
66
+ */
67
+ type InferObjectFields<Fields extends FieldDefinition[]> = {
68
+ [F in Fields[number] as F["name"]]: F extends {
69
+ required: false;
70
+ } ? InferFieldValue<F> | undefined : InferFieldValue<F>;
71
+ };
72
+ /**
73
+ * Infer the full data shape of a collection from its schema.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * const blogSchema = {
78
+ * collection: "blog",
79
+ * fields: [
80
+ * { name: "title", type: "text", required: true },
81
+ * { name: "published", type: "boolean" },
82
+ * ],
83
+ * } satisfies CollectionSchema;
84
+ *
85
+ * type BlogData = InferSchemaData<typeof blogSchema>;
86
+ * // => { title: string; published: boolean }
87
+ * ```
88
+ */
89
+ type InferSchemaData<S extends CollectionSchema> = InferObjectFields<S["fields"]>;
90
+
91
+ /**
92
+ * @context Shared layer — field label utilities at src/shared/field-utils.ts
93
+ * @does Resolves human-readable labels for field definitions and raw key strings
94
+ * @depends src/shared/fields.ts
95
+ * @do Add field-related utility functions here
96
+ * @dont Import from CLI or UI; contain field type definitions or schema logic
97
+ */
98
+
99
+ /**
100
+ * Resolve the human-readable label for a field.
101
+ *
102
+ * When the field definition has an explicit `label`, that is returned as-is.
103
+ * Otherwise the `name` (camelCase / kebab-case / snake_case) is converted to Title Case:
104
+ *
105
+ * @example
106
+ * fieldLabel({ name: "siteName", type: "text" }) // "Site Name"
107
+ * fieldLabel({ name: "created_at", type: "date" }) // "Created At"
108
+ * fieldLabel({ name: "bio", type: "long-text", label: "About" }) // "About"
109
+ */
110
+ declare function fieldLabel(field: Pick<BaseField, "name" | "label">): string;
111
+ /**
112
+ * Resolve the label for a raw key string (no field definition available).
113
+ * Useful for dynamic keys that have no schema entry.
114
+ */
115
+ declare function keyLabel(name: string): string;
116
+
117
+ export { CollectionSchema, ContentEntry, FieldDefinition, type InferFieldValue, type InferSchemaData, bindFrontmatter, extractFrontmatterTokens, fieldLabel, filterDrafts, isDraft, keyLabel, parseLocaleFromFilename, stripLocaleFromSlug };
@@ -0,0 +1,136 @@
1
+ import { v as FileInfo, w as DirectoryFileEntry, t as StudioConfig, C as ContentEntry, n as Collection } from '../query-builder-BOu-D7a1.js';
2
+ export { o as CollectionConfig, p as CollectionTypeMap, Q as QueryOptions, s as QueryResult, u as queryCollection } from '../query-builder-BOu-D7a1.js';
3
+
4
+ /**
5
+ * @context Shared layer — FS adapter interface at src/shared/fs-adapter.interface.ts
6
+ * @does Defines the IFsAdapter contract so Core can perform I/O without depending on CLI
7
+ * @depends src/shared/types.ts
8
+ * @do Add new I/O methods here when Core needs them; keep the interface minimal
9
+ * @dont Import from CLI or UI; contain implementation logic
10
+ */
11
+
12
+ interface IFsAdapter {
13
+ readFile(filePath: string): Promise<string>;
14
+ writeFile(filePath: string, content: string): Promise<void>;
15
+ deleteFile(filePath: string): Promise<void>;
16
+ exists(filePath: string): Promise<boolean>;
17
+ getStats(filePath: string): Promise<FileInfo>;
18
+ listFiles(dirPath: string, extensions?: readonly string[]): Promise<string[]>;
19
+ listDirectories(dirPath: string): Promise<string[]>;
20
+ readBuffer(filePath: string): Promise<Buffer>;
21
+ writeBuffer(filePath: string, data: Buffer): Promise<void>;
22
+ listAllFiles(dirPath: string): Promise<DirectoryFileEntry[]>;
23
+ join(...segments: string[]): string;
24
+ basename(filePath: string): string;
25
+ extname(filePath: string): string;
26
+ relative(from: string, to: string): string;
27
+ normalizeSlug(relativePath: string, ext: string): string;
28
+ readFileSync(filePath: string): string;
29
+ existsSync(filePath: string): boolean;
30
+ listFilesSync(dirPath: string, extensions?: readonly string[]): string[];
31
+ listDirectoriesSync(dirPath: string): string[];
32
+ }
33
+
34
+ /**
35
+ * @context Core layer — filesystem adapter at src/core/fs-adapter.ts
36
+ * @does Implements IFsAdapter; abstracts all file read/write/list operations behind a single interface
37
+ * @depends src/shared/types.ts, src/shared/constants.ts, src/shared/fs-adapter.interface.ts
38
+ * @do Add new I/O operations here; all file access must go through this adapter
39
+ * @dont Import UI components, run HTTP requests, or contain business logic
40
+ */
41
+
42
+ declare class FsAdapter implements IFsAdapter {
43
+ private readonly basePath;
44
+ constructor(basePath: string);
45
+ private resolve;
46
+ readFile(filePath: string): Promise<string>;
47
+ writeFile(filePath: string, content: string): Promise<void>;
48
+ deleteFile(filePath: string): Promise<void>;
49
+ exists(filePath: string): Promise<boolean>;
50
+ getStats(filePath: string): Promise<FileInfo>;
51
+ listFiles(dirPath: string, extensions?: readonly string[]): Promise<string[]>;
52
+ listDirectories(dirPath: string): Promise<string[]>;
53
+ readBuffer(filePath: string): Promise<Buffer>;
54
+ writeBuffer(filePath: string, data: Buffer): Promise<void>;
55
+ listAllFiles(dirPath: string): Promise<DirectoryFileEntry[]>;
56
+ join(...segments: string[]): string;
57
+ basename(filePath: string): string;
58
+ extname(filePath: string): string;
59
+ relative(from: string, to: string): string;
60
+ normalizeSlug(relativePath: string, ext: string): string;
61
+ readFileSync(filePath: string): string;
62
+ existsSync(filePath: string): boolean;
63
+ listFilesSync(dirPath: string, extensions?: readonly string[]): string[];
64
+ listDirectoriesSync(dirPath: string): string[];
65
+ }
66
+
67
+ /**
68
+ * @context Core layer — content indexer at src/core/indexer.ts
69
+ * @does Scans the contents directory, parses MDX/JSON files, and builds an in-memory index
70
+ * @depends src/shared/types.ts, src/shared/constants.ts, src/shared/fs-adapter.interface.ts, src/core/parsers/, src/core/schema-inferrer.ts
71
+ * @do Add new file type handling here; extend indexCollection for new collection behaviors
72
+ * @dont Import from CLI or UI; instantiate FsAdapter; access the filesystem directly
73
+ */
74
+
75
+ declare class ContentIndex {
76
+ private readonly entries;
77
+ private readonly collections;
78
+ private readonly fs;
79
+ constructor(fsAdapter: IFsAdapter);
80
+ build(config?: StudioConfig): Promise<void>;
81
+ buildSync(config?: StudioConfig): void;
82
+ getCollection(name: string): ContentEntry[];
83
+ getCollections(): Collection[];
84
+ clear(): void;
85
+ updateEntry(collectionName: string, entry: ContentEntry): void;
86
+ removeEntry(collectionName: string, slug: string): void;
87
+ private updateCollectionMeta;
88
+ private indexCollection;
89
+ private indexCollectionSync;
90
+ private scanDir;
91
+ private scanDirSync;
92
+ private buildMdxEntry;
93
+ private buildJsonEntries;
94
+ private readOrdering;
95
+ private readOrderingSync;
96
+ private applyOrdering;
97
+ private detectCollectionType;
98
+ }
99
+
100
+ /**
101
+ * @context Core layer — content store at src/core/content-store.ts
102
+ * @does Manages a singleton ContentIndex; exposes loadContent() and getStore() for consumers
103
+ * @depends src/core/indexer.ts, src/shared/types.ts
104
+ * @do Use this as the single access point for in-memory indexed content
105
+ * @dont Import from CLI or UI; contain parsing or I/O logic; import fs-adapter at top level
106
+ */
107
+
108
+ declare function loadContent(fsAdapter: IFsAdapter, config?: StudioConfig): Promise<ContentIndex>;
109
+ declare function loadContentSync(fsAdapter: IFsAdapter, config?: StudioConfig): ContentIndex;
110
+
111
+ /**
112
+ * @context Core layer — config loader at src/core/config-loader.ts
113
+ * @does Resolves and loads studio.config.ts/.js from the project root using dynamic import
114
+ * @depends src/shared/constants.ts, src/shared/types.ts
115
+ * @do Add new config resolution strategies or validation here
116
+ * @dont Import from CLI or UI; access content files
117
+ */
118
+
119
+ /**
120
+ * Resolves the config file path from the project root.
121
+ * Returns undefined if no config file is found.
122
+ */
123
+ declare function resolveConfigPath(projectRoot: string): string | undefined;
124
+ /**
125
+ * Loads the studio config from the project root.
126
+ * Tries CONFIG_FILENAMES in order, uses dynamic import().
127
+ * Returns empty config if no file found or loading fails.
128
+ */
129
+ declare function loadStudioConfig(projectRoot: string): Promise<StudioConfig>;
130
+ /**
131
+ * Loads config from a specific file path.
132
+ * Uses tsx's tsImport for .ts files so TypeScript configs work at runtime.
133
+ */
134
+ declare function loadConfigFromPath(configPath: string): Promise<StudioConfig>;
135
+
136
+ export { Collection, ContentEntry, ContentIndex, FsAdapter, StudioConfig, loadConfigFromPath, loadContent, loadContentSync, loadStudioConfig, resolveConfigPath };