@domain-first/project-structure 8.10.0 → 8.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/dist/115.js +142 -141
- package/dist/201.js +10 -1
- package/dist/287.js +983 -434
- package/dist/364.js +79 -0
- package/dist/38.js +29 -13
- package/dist/561.js +167 -93
- package/dist/agent-cli.d.ts +13 -2
- package/dist/agent-requests.d.ts +76 -2
- package/dist/config-file.d.ts +25 -1
- package/dist/frontend-cli.d.ts +3 -0
- package/dist/frontend-modules.d.ts +9 -0
- package/dist/graph.cjs +10 -1
- package/dist/index.cjs +3470 -2913
- package/dist/init.cjs +325 -83
- package/dist/integration.cjs +3470 -2913
- package/dist/integrations/openapi.d.ts +9 -2
- package/dist/integrations/orval.d.ts +31 -4
- package/dist/integrations/rest-endpoint-generator.d.ts +11 -7
- package/dist/integrations/storybook.d.ts +19 -1
- package/dist/lint.cjs +40 -15
- package/dist/lint.js +1 -1
- package/dist/page-router.d.ts +18 -0
- package/dist/react-module-move.d.ts +27 -12
- package/dist/react.cjs +1577 -993
- package/dist/react.js +2 -102
- package/dist/rest-adapters.d.ts +13 -0
- package/dist/svelte-agent-cli.spec.d.ts +1 -0
- package/dist/svelte.cjs +7311 -0
- package/dist/svelte.d.ts +2 -0
- package/dist/svelte.js +3 -0
- package/dist/sveltekit-app.d.ts +7 -0
- package/dist/upgrade-steps.d.ts +6 -1
- package/dist/upgrade.cjs +12 -2
- package/dist/use-cases/add-integration.d.ts +1 -1
- package/dist/use-cases/delete-react-module.d.ts +4 -4
- package/dist/use-cases/index.d.ts +1 -0
- package/dist/use-cases/move-react-module.d.ts +2 -2
- package/dist/use-cases/rest-endpoint-generator.d.ts +6 -4
- package/dist/use-cases/scaffold-svelte-modules.d.ts +22 -0
- package/package.json +2 -1
- package/skills/df-ps-implement/SKILL.md +3 -3
- package/skills/df-ps-plan-feature/SKILL.md +2 -2
- package/skills/df-ps-scaffold/SKILL.md +11 -10
- package/skills/df-ps-scaffold/references/agent-mode.md +1 -1
- package/skills/df-ps-scaffold/references/agent-operations.md +8 -4
- package/skills/df-ps-scaffold/references/generators.md +1 -1
- package/skills/df-ps-scaffold/references/work-plan.md +1 -1
- package/skills/df-ps-svelte/SKILL.md +49 -0
- package/skills/df-ps-svelte/references/generators.md +56 -0
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import type { FrontendFramework } from '../react-module-move';
|
|
1
2
|
export declare const openapiScriptPath = "scripts/generate-openapi.ts";
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
3
|
+
/** The static assets folder of Next.js or SvelteKit, so the app can serve it. */
|
|
4
|
+
export declare const defaultOpenapiPath: () => "public/openapi.json" | "static/openapi.json" | "openapi.json";
|
|
5
|
+
export declare const swaggerPagePath: (rootFolder: string, framework?: FrontendFramework) => string;
|
|
4
6
|
/**
|
|
5
7
|
* A React page rendering the OpenAPI document with Swagger UI. With
|
|
6
8
|
* Next.js it is a client component: Swagger UI keeps state and its App
|
|
7
9
|
* Router route is a server component.
|
|
8
10
|
*/
|
|
9
11
|
export declare const swaggerPage: (rootFolder: string, outputPath: string, withNext?: boolean) => string;
|
|
12
|
+
/**
|
|
13
|
+
* A Svelte page rendering the OpenAPI document with Swagger UI. Swagger UI
|
|
14
|
+
* needs the browser, so it is loaded on mount and never runs during SSR.
|
|
15
|
+
*/
|
|
16
|
+
export declare const svelteSwaggerPage: (rootFolder: string, outputPath: string) => string;
|
|
10
17
|
export declare const openapiScripts: {
|
|
11
18
|
openapi: string;
|
|
12
19
|
};
|
|
@@ -1,14 +1,41 @@
|
|
|
1
|
+
import type { FrontendFramework } from '../react-module-move';
|
|
1
2
|
export type OrvalTarget = 'hooks' | 'client';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Query hooks go to the data layer of the frontend framework (React Query
|
|
5
|
+
* or Svelte Query), the typed client to the shared one.
|
|
6
|
+
*/
|
|
7
|
+
export declare const dataLayerFolder: (rootFolder: string, target: OrvalTarget, framework?: FrontendFramework) => string;
|
|
8
|
+
export declare const orvalScripts: (rootFolder: string, targets: OrvalTarget[], framework?: FrontendFramework) => {
|
|
5
9
|
'client:orval': string;
|
|
6
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* The base URL of requests, read at runtime: `NEXT_PUBLIC_API_BASE_URL`
|
|
13
|
+
* with Next.js, `VITE_API_BASE_URL` with Svelte, both empty by default, so
|
|
14
|
+
* requests go to the app's own origin.
|
|
15
|
+
*/
|
|
16
|
+
export declare const orvalBaseUrls: {
|
|
17
|
+
readonly next: "process.env.NEXT_PUBLIC_API_BASE_URL ?? \"\"";
|
|
18
|
+
readonly svelte: "import.meta.env.VITE_API_BASE_URL ?? \"\"";
|
|
19
|
+
};
|
|
20
|
+
export type OrvalBaseUrl = keyof typeof orvalBaseUrls;
|
|
7
21
|
/**
|
|
8
22
|
* Orval resolves paths relative to the config, which lives in the data layer
|
|
9
23
|
* folder next to the generated code. `mutatorPath` is relative to the config.
|
|
10
24
|
*/
|
|
11
|
-
export declare const orvalConfig: (rootFolder: string, openapiPath: string,
|
|
25
|
+
export declare const orvalConfig: (rootFolder: string, openapiPath: string, baseUrlSource: OrvalBaseUrl | undefined, target?: OrvalTarget, mutatorPath?: string, framework?: FrontendFramework) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Orval picks the Svelte Query API by the version it finds in a
|
|
28
|
+
* package.json: this one declares version 6, so the hooks use runes.
|
|
29
|
+
*/
|
|
30
|
+
export declare const svelteQueryPackageJsonFile = "orval.package.json";
|
|
31
|
+
export declare const svelteQueryPackageJson: string;
|
|
12
32
|
export declare const orvalMutator = "/** Error of the generated requests, with the parsed response body. */\nexport class ApiError<Body = unknown> extends Error {\n constructor(\n public readonly status: number,\n public readonly body: Body\n ) {\n super(`API error ${status}`);\n this.name = 'ApiError';\n }\n}\n\n/** Error type of the generated requests, typed per endpoint by Orval. */\nexport type ErrorType<Body> = ApiError<Body>;\n\n/** Every generated request goes through here: add auth headers, token refresh, logging. */\nexport const customInstance = async <T>(\n url: string,\n init?: RequestInit\n): Promise<T> => {\n const response = await fetch(url, init);\n const text = await response.text();\n const body = text ? JSON.parse(text) : undefined;\n\n if (!response.ok) {\n throw new ApiError(response.status, body);\n }\n\n return body as T;\n};\n";
|
|
13
33
|
export declare const queryProvider = "'use client';\n\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { type FC, type ReactNode, useState } from 'react';\n\nexport const QueryProvider: FC<{ children: ReactNode }> = ({ children }) => {\n // One client per browser session; a module-level client would be shared between requests on the server\n const [queryClient] = useState(() => new QueryClient());\n\n return (\n <QueryClientProvider client={queryClient}>\n {children}\n </QueryClientProvider>\n );\n};\n";
|
|
34
|
+
/**
|
|
35
|
+
* The Svelte Query provider. With SvelteKit, queries run only in the
|
|
36
|
+
* browser: a page rendered on the server has no client of its own yet.
|
|
37
|
+
*/
|
|
38
|
+
export declare const svelteQueryProvider: (withSvelteKit: boolean) => string;
|
|
39
|
+
/** The root SvelteKit layout wrapping every page in the query provider. */
|
|
40
|
+
export declare const svelteKitQueryLayout: (providerImport: string) => string;
|
|
14
41
|
export declare const addOrval: () => Promise<string[]>;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import { type RestAdapter } from '../rest-adapters';
|
|
1
2
|
/**
|
|
2
3
|
* The catch-all route serving every endpoint, relative to the project root.
|
|
3
4
|
*/
|
|
4
5
|
export declare const nextRoutePath: (root: string) => string;
|
|
6
|
+
/** The adapter of the configured framework: Next.js or SvelteKit. */
|
|
7
|
+
export declare const frameworkRestAdapter: () => RestAdapter | undefined;
|
|
5
8
|
/**
|
|
6
|
-
* Offered only when the config selects Next.js (or the caller
|
|
9
|
+
* Offered only when the config selects Next.js or SvelteKit (or the caller
|
|
10
|
+
* names the framework's adapter).
|
|
7
11
|
*/
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
}) => Promise<
|
|
12
|
+
export declare const askRestAdapter: ({ adapter }?: {
|
|
13
|
+
adapter?: RestAdapter;
|
|
14
|
+
}) => Promise<RestAdapter | undefined>;
|
|
11
15
|
/**
|
|
12
|
-
* The Shared Kernel endpoint generator and, with
|
|
16
|
+
* The Shared Kernel endpoint generator and, with a framework adapter, the
|
|
13
17
|
* catch-all route. Existing files are kept: the generator is edited by
|
|
14
18
|
* hand.
|
|
15
19
|
*/
|
|
16
|
-
export declare const scaffoldRestEndpointGeneratorFiles: ({
|
|
17
|
-
|
|
20
|
+
export declare const scaffoldRestEndpointGeneratorFiles: ({ adapter }: {
|
|
21
|
+
adapter?: RestAdapter;
|
|
18
22
|
}) => string[];
|
|
19
23
|
export declare const addRestEndpointGenerator: () => Promise<string[]>;
|
|
20
24
|
export declare const restEndpointGeneratorApplied: () => boolean;
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
export declare const storybookFrameworkPackage = "@storybook/react-vite";
|
|
2
|
+
export declare const svelteStorybookPackages: {
|
|
3
|
+
readonly svelte: "@storybook/svelte-vite";
|
|
4
|
+
readonly sveltekit: "@storybook/sveltekit";
|
|
5
|
+
};
|
|
6
|
+
/** The Storybook framework of a frontend choice; Next.js uses React + Vite. */
|
|
7
|
+
export declare const storybookPackageFor: (framework: "react" | "next" | "svelte" | "sveltekit") => "@storybook/react-vite" | "@storybook/svelte-vite" | "@storybook/sveltekit";
|
|
8
|
+
/** How the Storybook integration is named in menus. */
|
|
9
|
+
export declare const storybookTitle: () => "Storybook (SvelteKit)" | "Storybook (Svelte + Vite)" | "Storybook (React + Vite)";
|
|
10
|
+
/** The Storybook config folder relative to the root folder. */
|
|
11
|
+
export declare const storybookFolder: () => string;
|
|
12
|
+
/**
|
|
13
|
+
* Svelte + Vite needs the Svelte plugin unless the project's Vite config
|
|
14
|
+
* has it; SvelteKit's framework reads the project's Vite config.
|
|
15
|
+
*/
|
|
16
|
+
export declare const svelteStorybookFiles: (relativeProjectRoot: string, frameworkPackage: (typeof svelteStorybookPackages)[keyof typeof svelteStorybookPackages]) => {
|
|
17
|
+
'main.ts': string;
|
|
18
|
+
'preview.ts': string;
|
|
19
|
+
};
|
|
2
20
|
export declare const storybookFiles: (relativeProjectRoot: string) => {
|
|
3
21
|
'main.ts': string;
|
|
4
22
|
'preview.ts': string;
|
|
5
23
|
};
|
|
6
|
-
export declare const storybookScripts: (rootFolder: string) => {
|
|
24
|
+
export declare const storybookScripts: (rootFolder: string, family?: "react" | "svelte") => {
|
|
7
25
|
storybook: string;
|
|
8
26
|
'build-storybook': string;
|
|
9
27
|
};
|
package/dist/lint.cjs
CHANGED
|
@@ -246,6 +246,7 @@ const lintChecks = [
|
|
|
246
246
|
'layers',
|
|
247
247
|
'dependencies',
|
|
248
248
|
'react',
|
|
249
|
+
'svelte',
|
|
249
250
|
'clock',
|
|
250
251
|
'config'
|
|
251
252
|
];
|
|
@@ -290,8 +291,16 @@ const reactConfigSchema = external_zod_default().object({
|
|
|
290
291
|
]).optional(),
|
|
291
292
|
storybookFramework: external_zod_default().string().optional()
|
|
292
293
|
}).passthrough();
|
|
294
|
+
const svelteConfigSchema = external_zod_default().object({
|
|
295
|
+
framework: external_zod_default()["enum"]([
|
|
296
|
+
'svelte',
|
|
297
|
+
'sveltekit'
|
|
298
|
+
]).optional(),
|
|
299
|
+
storybookFramework: external_zod_default().string().optional()
|
|
300
|
+
}).passthrough();
|
|
293
301
|
const frontendConfigSchema = external_zod_default().object({
|
|
294
|
-
react: reactConfigSchema.optional()
|
|
302
|
+
react: reactConfigSchema.optional(),
|
|
303
|
+
svelte: svelteConfigSchema.optional()
|
|
295
304
|
}).passthrough();
|
|
296
305
|
const configSchema = external_zod_default().object({
|
|
297
306
|
project: projectConfigSchema,
|
|
@@ -759,7 +768,7 @@ const sourceFiles = (folder)=>{
|
|
|
759
768
|
}).flatMap((entry)=>{
|
|
760
769
|
const entryPath = external_node_path_default().join(folder, entry.name);
|
|
761
770
|
if (entry.isDirectory()) return 'node_modules' === entry.name ? [] : sourceFiles(entryPath);
|
|
762
|
-
return /\.(c|m)?tsx
|
|
771
|
+
return /\.((c|m)?tsx?|svelte)$/.test(entry.name) && !entry.name.endsWith('.d.ts') ? [
|
|
763
772
|
entryPath
|
|
764
773
|
] : [];
|
|
765
774
|
});
|
|
@@ -825,10 +834,22 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
825
834
|
const root = external_node_path_default().resolve(projectRoot, rootFolder);
|
|
826
835
|
const contextsFolder = external_node_path_default().join(root, 'bounded-contexts');
|
|
827
836
|
const sharedFolder = external_node_path_default().join(root, 'shared-kernel');
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
837
|
+
const frontends = [
|
|
838
|
+
'react',
|
|
839
|
+
'svelte'
|
|
840
|
+
].map((framework)=>{
|
|
841
|
+
const folder = external_node_path_default().join(root, 'presentation', framework);
|
|
842
|
+
return {
|
|
843
|
+
check: framework,
|
|
844
|
+
label: `presentation/${framework}`,
|
|
845
|
+
folder,
|
|
846
|
+
uiKit: external_node_path_default().join(folder, 'ui-kit'),
|
|
847
|
+
widgets: external_node_path_default().join(folder, 'widgets'),
|
|
848
|
+
hooks: external_node_path_default().join(folder, 'hooks'),
|
|
849
|
+
widgetFile: 'svelte' === framework ? '-widget.svelte' : '-widget.tsx'
|
|
850
|
+
};
|
|
851
|
+
});
|
|
852
|
+
const frontendOf = (file)=>frontends.find((frontend)=>inside(frontend.folder, file));
|
|
832
853
|
const inMemoryDbFile = external_node_path_default().join(sharedFolder, 'infrastructure', 'services', 'in-memory-db-infrastructure-service.ts');
|
|
833
854
|
const aliases = readAliases(projectRoot);
|
|
834
855
|
const violations = [];
|
|
@@ -858,16 +879,18 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
858
879
|
].includes(part) && !/-repository(\.tsx?)?$/.test(external_node_path_default().basename(target));
|
|
859
880
|
const widgetFolders = new Map();
|
|
860
881
|
const isWidgetFolder = (folder)=>{
|
|
861
|
-
if (!widgetFolders.has(folder)) widgetFolders.set(folder, external_node_fs_default().existsSync(folder) && external_node_fs_default().statSync(folder).isDirectory() && external_node_fs_default().readdirSync(folder).some((name)=>name.endsWith(
|
|
882
|
+
if (!widgetFolders.has(folder)) widgetFolders.set(folder, external_node_fs_default().existsSync(folder) && external_node_fs_default().statSync(folder).isDirectory() && external_node_fs_default().readdirSync(folder).some((name)=>frontends.some(({ widgetFile })=>name.endsWith(widgetFile))));
|
|
862
883
|
return widgetFolders.get(folder);
|
|
863
884
|
};
|
|
864
885
|
const widgetOf = (file)=>{
|
|
886
|
+
const widgetsFolder = frontendOf(file)?.widgets;
|
|
887
|
+
if (!widgetsFolder) return;
|
|
865
888
|
for(let folder = file; inside(widgetsFolder, folder); folder = external_node_path_default().dirname(folder))if (isWidgetFolder(folder)) return folder;
|
|
866
889
|
};
|
|
867
890
|
const files = [
|
|
868
891
|
contextsFolder,
|
|
869
892
|
sharedFolder,
|
|
870
|
-
|
|
893
|
+
...frontends.map(({ folder })=>folder)
|
|
871
894
|
].flatMap(sourceFiles);
|
|
872
895
|
for (const file of files){
|
|
873
896
|
const source = external_node_fs_default().readFileSync(file, 'utf8');
|
|
@@ -881,6 +904,7 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
881
904
|
text: external_node_path_default().basename(file)
|
|
882
905
|
});
|
|
883
906
|
const ownContext = contextOf(file);
|
|
907
|
+
const frontend = frontendOf(file);
|
|
884
908
|
const directWiring = ownContext && from?.segments[0] === 'wiring' && readWiredModule(file, boundedContextPath(contextsFolder, ownContext))?.implementations.some((implementation)=>isCrossContextImplementation(implementation.file));
|
|
885
909
|
const report = (check, rule, imported)=>violations.push({
|
|
886
910
|
check,
|
|
@@ -900,9 +924,10 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
900
924
|
} else if (inside(sharedFolder, file)) {
|
|
901
925
|
const allowed = !to || 'shared-kernel' === to.owner || 'domain' === to.segments[0] && 'errors' === to.segments[1] || file === inMemoryDbFile && isDomainModel(to.segments, target);
|
|
902
926
|
if (!allowed) report('shared-kernel', '[shared-kernel] imports a bounded context outside its domain/errors (and domain models for the in-memory DB):', imported);
|
|
903
|
-
} else if (inside(
|
|
904
|
-
const [area] = inside(
|
|
905
|
-
const
|
|
927
|
+
} else if (frontend && (inside(frontend.uiKit, file) || inside(frontend.hooks, file))) {
|
|
928
|
+
const [area] = inside(frontend.folder, target) ?? [];
|
|
929
|
+
const inUiKit = inside(frontend.uiKit, file);
|
|
930
|
+
const forbidden = inUiKit ? [
|
|
906
931
|
'widgets',
|
|
907
932
|
'pages'
|
|
908
933
|
] : [
|
|
@@ -910,11 +935,11 @@ const importViolations = (projectRoot, rootFolder, rules)=>{
|
|
|
910
935
|
'widgets',
|
|
911
936
|
'pages'
|
|
912
937
|
];
|
|
913
|
-
if (targetContext || forbidden.includes(area)) report(
|
|
914
|
-
} else if (targetContext && !(imported.typeOnly && to?.segments[0] === 'presentation' && 'rest' === to.segments[1])) report(
|
|
938
|
+
if (targetContext || forbidden.includes(area)) report(frontend.check, inUiKit ? `[${frontend.label}/ui-kit] imports a bounded context, widget or page:` : `[${frontend.label}/hooks] a shared hook imports a bounded context, UI-kit, widget or page:`, imported);
|
|
939
|
+
} else if (frontend && targetContext && !(imported.typeOnly && to?.segments[0] === 'presentation' && 'rest' === to.segments[1])) report(frontend.check, `[${frontend.label}] imports a context other than \`import type\` from presentation/rest:`, imported);
|
|
915
940
|
const ownWidget = widgetOf(file);
|
|
916
941
|
const targetWidget = widgetOf(target);
|
|
917
|
-
if (ownWidget && targetWidget && targetWidget !== ownWidget) report(
|
|
942
|
+
if (frontend && ownWidget && targetWidget && targetWidget !== ownWidget) report(frontend.check, `[${frontend.label}/widgets] a widget imports another widget:`, imported);
|
|
918
943
|
if (!from || !to) continue;
|
|
919
944
|
if (crossContextAllowed) continue;
|
|
920
945
|
if (isSpec(file)) continue;
|
|
@@ -1046,7 +1071,7 @@ const help = `Usage: df-lint [rootFolder]
|
|
|
1046
1071
|
|
|
1047
1072
|
Reports what breaks the Domain-First rules in the project:
|
|
1048
1073
|
bounded context isolation, layers, dependency rules (imports and wiring),
|
|
1049
|
-
React modules, and reading the time or environment variables without
|
|
1074
|
+
React and Svelte modules, and reading the time or environment variables without
|
|
1050
1075
|
the clock and config ports.
|
|
1051
1076
|
rootFolder defaults to the one in domain-first.project-structure.config.json,
|
|
1052
1077
|
whose optional \`backend.rules\` change the dependency rules and turn checks off.
|
package/dist/lint.js
CHANGED
|
@@ -6,7 +6,7 @@ const help = `Usage: df-lint [rootFolder]
|
|
|
6
6
|
|
|
7
7
|
Reports what breaks the Domain-First rules in the project:
|
|
8
8
|
bounded context isolation, layers, dependency rules (imports and wiring),
|
|
9
|
-
React modules, and reading the time or environment variables without
|
|
9
|
+
React and Svelte modules, and reading the time or environment variables without
|
|
10
10
|
the clock and config ports.
|
|
11
11
|
rootFolder defaults to the one in domain-first.project-structure.config.json,
|
|
12
12
|
whose optional \`backend.rules\` change the dependency rules and turn checks off.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FrontendFramework } from './react-module-move';
|
|
2
|
+
/**
|
|
3
|
+
* The file-based router pages get routes in: the Next.js App Router for
|
|
4
|
+
* React, SvelteKit for Svelte. Undefined without one.
|
|
5
|
+
*/
|
|
6
|
+
export type PageRouter = {
|
|
7
|
+
title: 'Next.js' | 'SvelteKit';
|
|
8
|
+
/** The routes folder relative to the project root. */
|
|
9
|
+
folder: (root: string) => string;
|
|
10
|
+
/** The file of a route that renders the page. */
|
|
11
|
+
pageFile: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const pageRouter: (framework: FrontendFramework) => PageRouter | undefined;
|
|
14
|
+
/** How messages name modules of each framework. */
|
|
15
|
+
export declare const frameworkTitles: Record<FrontendFramework, {
|
|
16
|
+
title: string;
|
|
17
|
+
cli: string;
|
|
18
|
+
}>;
|
|
@@ -2,6 +2,16 @@ import { type MovePlan } from './module-move';
|
|
|
2
2
|
import { NestedName } from './nested-name';
|
|
3
3
|
export type { MovePlan } from './module-move';
|
|
4
4
|
export type ReactModuleKind = 'page' | 'widget' | 'ui-kit' | 'hook';
|
|
5
|
+
/**
|
|
6
|
+
* Frontend modules of `presentation/react` and `presentation/svelte` share
|
|
7
|
+
* kinds and layouts; only file extensions and routes differ.
|
|
8
|
+
*/
|
|
9
|
+
export type FrontendFramework = 'react' | 'svelte';
|
|
10
|
+
/** Extensions of components (pages, widgets, UI-kit) and shared hooks. */
|
|
11
|
+
export declare const frontendExtensions: Record<FrontendFramework, {
|
|
12
|
+
component: string;
|
|
13
|
+
hook: string;
|
|
14
|
+
}>;
|
|
5
15
|
export type ReactModule = {
|
|
6
16
|
kind: ReactModuleKind;
|
|
7
17
|
/** Name, nested for pages and widgets, e.g. `admin/users`. */
|
|
@@ -30,15 +40,17 @@ type ReactKindLayout = {
|
|
|
30
40
|
storyTitle?: (segments: string[]) => string;
|
|
31
41
|
};
|
|
32
42
|
export declare const reactKindLayouts: Record<ReactModuleKind, ReactKindLayout>;
|
|
43
|
+
export declare const svelteKindLayouts: Record<ReactModuleKind, ReactKindLayout>;
|
|
44
|
+
export declare const frontendKindLayouts: (framework: FrontendFramework) => Record<ReactModuleKind, ReactKindLayout>;
|
|
33
45
|
/** How menus name each kind, singular and plural. */
|
|
34
46
|
export declare const reactKindTitles: Record<ReactModuleKind, [string, string]>;
|
|
35
47
|
/** A hook's name is entered without `use-`, as its generator takes it. */
|
|
36
48
|
export declare const reactModuleName: (kind: ReactModuleKind, rawName: string) => string;
|
|
37
|
-
export declare const findReactModules: (reactFolder: string, kind: ReactModuleKind) => ReactModule[];
|
|
38
|
-
export declare const validateMove: (reactFolder: string, module: ReactModule, rawName: string) => string | true;
|
|
39
|
-
/** A Next.js App Router route folder moved with a page. */
|
|
49
|
+
export declare const findReactModules: (reactFolder: string, kind: ReactModuleKind, framework?: FrontendFramework) => ReactModule[];
|
|
50
|
+
export declare const validateMove: (reactFolder: string, module: ReactModule, rawName: string, framework?: FrontendFramework) => string | true;
|
|
51
|
+
/** A Next.js App Router or SvelteKit route folder moved with a page. */
|
|
40
52
|
export type RouteMove = {
|
|
41
|
-
/** The
|
|
53
|
+
/** The routes folder, e.g. `<root>/app` or `<root>/src/routes`. */
|
|
42
54
|
appFolder: string;
|
|
43
55
|
from: string;
|
|
44
56
|
to: string;
|
|
@@ -53,14 +65,17 @@ export declare const routeFiles: (folder: string) => string[];
|
|
|
53
65
|
/**
|
|
54
66
|
* Stages the move with pending changes: files of the module, its imports
|
|
55
67
|
* of other files, and every import of it in the project. With `route`, the
|
|
56
|
-
* files of that
|
|
68
|
+
* files of that route folder move too.
|
|
57
69
|
*/
|
|
58
|
-
export declare const moveReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, rawName: string, route?: RouteMove) => MovePlan;
|
|
70
|
+
export declare const moveReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, rawName: string, route?: RouteMove, framework?: FrontendFramework) => MovePlan;
|
|
71
|
+
/** The file of a route that renders its page, by framework. */
|
|
72
|
+
export declare const routePageFile: Record<FrontendFramework, string>;
|
|
59
73
|
/**
|
|
60
|
-
* The route folder of a page with Next.js: `<
|
|
61
|
-
* `page.tsx` renders the page. Undefined for
|
|
74
|
+
* The route folder of a page with Next.js or SvelteKit: `<routes>/<name>/`
|
|
75
|
+
* when its `page.tsx` (`+page.svelte`) renders the page. Undefined for
|
|
76
|
+
* other routes or none.
|
|
62
77
|
*/
|
|
63
|
-
export declare const pageRouteFolder: (appFolder: string, page: ReactModule) => string | undefined;
|
|
78
|
+
export declare const pageRouteFolder: (appFolder: string, page: ReactModule, framework?: FrontendFramework) => string | undefined;
|
|
64
79
|
export type ReactDeleteResult = {
|
|
65
80
|
/** Files outside the module that still import it: [file, import]. */
|
|
66
81
|
usedBy: [string, string][];
|
|
@@ -70,10 +85,10 @@ export type ReactDeleteResult = {
|
|
|
70
85
|
};
|
|
71
86
|
/**
|
|
72
87
|
* Stages the deletion of a page or widget with its files, and with `route`
|
|
73
|
-
* the files of that
|
|
74
|
-
*
|
|
88
|
+
* the files of that route folder too. Nothing is staged while other files
|
|
89
|
+
* still import the module; those imports are returned instead.
|
|
75
90
|
*/
|
|
76
91
|
export declare const deleteReactModule: (projectRoot: string, reactFolder: string, module: ReactModule, route?: {
|
|
77
92
|
appFolder: string;
|
|
78
93
|
folder: string;
|
|
79
|
-
}) => ReactDeleteResult;
|
|
94
|
+
}, framework?: FrontendFramework) => ReactDeleteResult;
|