@domain-first/project-structure 8.11.0 → 8.13.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 +1 -1
- package/dist/287.js +36 -967
- package/dist/364.js +3 -3
- package/dist/38.js +4 -3
- package/dist/561.js +76 -67
- package/dist/783.js +1115 -0
- package/dist/{201.js → 878.js} +453 -1
- package/dist/agent-cli.d.ts +5 -5
- package/dist/agent-requests.d.ts +9 -9
- package/dist/frontend-modules.d.ts +6 -1
- package/dist/graph.cjs +113 -4
- package/dist/graph.js +1 -1
- package/dist/index.cjs +105 -81
- package/dist/index.js +1 -1
- package/dist/init.cjs +47 -6
- package/dist/init.js +1 -1
- package/dist/integration.cjs +105 -81
- package/dist/integration.js +1 -1
- package/dist/integrations/openapi.d.ts +13 -3
- package/dist/lint.cjs +119 -9
- package/dist/lint.js +1 -1
- package/dist/react-module-move.d.ts +18 -2
- package/dist/react.cjs +161 -133
- package/dist/svelte.cjs +161 -133
- package/dist/upgrade-svelte.d.ts +22 -0
- package/dist/upgrade-svelte.spec.d.ts +1 -0
- package/dist/upgrade.cjs +381 -41
- package/dist/upgrade.js +219 -13
- package/dist/use-cases/scaffold-svelte-modules.d.ts +3 -2
- package/package.json +1 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
- package/skills/df-ps-svelte/SKILL.md +16 -11
- package/skills/df-ps-svelte/references/generators.md +6 -5
- package/dist/115.js +0 -616
package/dist/svelte.cjs
CHANGED
|
@@ -1836,8 +1836,24 @@ const frontendExtensions = {
|
|
|
1836
1836
|
hook: '.svelte.ts'
|
|
1837
1837
|
}
|
|
1838
1838
|
};
|
|
1839
|
+
const frontendLogicNaming = {
|
|
1840
|
+
react: {
|
|
1841
|
+
prefix: 'use',
|
|
1842
|
+
shared: [
|
|
1843
|
+
'hooks'
|
|
1844
|
+
]
|
|
1845
|
+
},
|
|
1846
|
+
svelte: {
|
|
1847
|
+
prefix: 'create',
|
|
1848
|
+
shared: [
|
|
1849
|
+
'shared',
|
|
1850
|
+
'model'
|
|
1851
|
+
]
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1839
1854
|
const kindLayouts = (framework)=>{
|
|
1840
1855
|
const { component, hook } = frontendExtensions[framework];
|
|
1856
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1841
1857
|
return {
|
|
1842
1858
|
page: {
|
|
1843
1859
|
folder: 'pages',
|
|
@@ -1845,7 +1861,7 @@ const kindLayouts = (framework)=>{
|
|
|
1845
1861
|
inFolder: false,
|
|
1846
1862
|
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
1847
1863
|
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
1848
|
-
classPrefix:
|
|
1864
|
+
classPrefix: `(${prefix})?`,
|
|
1849
1865
|
classSuffix: 'Page'
|
|
1850
1866
|
},
|
|
1851
1867
|
widget: {
|
|
@@ -1853,7 +1869,7 @@ const kindLayouts = (framework)=>{
|
|
|
1853
1869
|
nested: true,
|
|
1854
1870
|
inFolder: true,
|
|
1855
1871
|
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
1856
|
-
classPrefix:
|
|
1872
|
+
classPrefix: `(${prefix})?`,
|
|
1857
1873
|
classSuffix: 'Widget|UIModel',
|
|
1858
1874
|
storyTitle: (segments)=>[
|
|
1859
1875
|
'Widgets',
|
|
@@ -1870,12 +1886,12 @@ const kindLayouts = (framework)=>{
|
|
|
1870
1886
|
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
1871
1887
|
},
|
|
1872
1888
|
hook: {
|
|
1873
|
-
folder: '
|
|
1889
|
+
folder: shared.join('/'),
|
|
1874
1890
|
nested: false,
|
|
1875
1891
|
inFolder: false,
|
|
1876
|
-
ownFile: (fileBase)=>new RegExp(
|
|
1877
|
-
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder,
|
|
1878
|
-
classPrefix:
|
|
1892
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
1893
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
1894
|
+
classPrefix: `(${prefix})`,
|
|
1879
1895
|
classSuffix: '(?![\\w$])'
|
|
1880
1896
|
}
|
|
1881
1897
|
};
|
|
@@ -1901,7 +1917,15 @@ const reactKindTitles = {
|
|
|
1901
1917
|
'shared hooks'
|
|
1902
1918
|
]
|
|
1903
1919
|
};
|
|
1904
|
-
const
|
|
1920
|
+
const svelteKindTitles = {
|
|
1921
|
+
...reactKindTitles,
|
|
1922
|
+
hook: [
|
|
1923
|
+
'Shared model',
|
|
1924
|
+
'shared models'
|
|
1925
|
+
]
|
|
1926
|
+
};
|
|
1927
|
+
const frontendKindTitles = (framework)=>'svelte' === framework ? svelteKindTitles : reactKindTitles;
|
|
1928
|
+
const reactModuleName = (kind, rawName, framework = 'react')=>'hook' === kind ? rawName.trim().replace(new RegExp(`^${frontendLogicNaming[framework].prefix}-`), '') : rawName;
|
|
1905
1929
|
const react_module_move_nestedName = (folders, fileBase)=>{
|
|
1906
1930
|
const prefix = `${folders.join('-')}-`;
|
|
1907
1931
|
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
@@ -1940,18 +1964,20 @@ const hookFile = {
|
|
|
1940
1964
|
svelte: /\.svelte\.[jt]s$/
|
|
1941
1965
|
};
|
|
1942
1966
|
const findHooks = (reactFolder, framework)=>{
|
|
1943
|
-
const
|
|
1967
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1968
|
+
const root = external_node_path_default().join(reactFolder, ...shared);
|
|
1944
1969
|
if (!external_node_fs_default().existsSync(root)) return [];
|
|
1945
1970
|
const extension = hookFile[framework];
|
|
1946
|
-
|
|
1947
|
-
|
|
1971
|
+
const ownPrefix = new RegExp(`^${prefix}-`);
|
|
1972
|
+
return external_node_fs_default().readdirSync(root).filter((file)=>ownPrefix.test(file) && extension.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
1973
|
+
const name = file.replace(ownPrefix, '').replace(extension, '');
|
|
1948
1974
|
const content = external_node_fs_default().readFileSync(external_node_path_default().join(root, file), 'utf8');
|
|
1949
1975
|
return {
|
|
1950
1976
|
kind: 'hook',
|
|
1951
1977
|
name,
|
|
1952
1978
|
path: external_node_path_default().join(root, file),
|
|
1953
1979
|
fileBase: name,
|
|
1954
|
-
ClassName: content.match(
|
|
1980
|
+
ClassName: content.match(new RegExp(`export\\s+(?:const|function)\\s+${prefix}(\\w+)\\b`))?.[1] ?? new NestedName(name).ClassName
|
|
1955
1981
|
};
|
|
1956
1982
|
});
|
|
1957
1983
|
};
|
|
@@ -1986,11 +2012,11 @@ const findReactModules = (reactFolder, kind, framework = 'react')=>{
|
|
|
1986
2012
|
});
|
|
1987
2013
|
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
1988
2014
|
};
|
|
1989
|
-
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName)));
|
|
2015
|
+
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName, framework)));
|
|
1990
2016
|
const validateMove = (reactFolder, module, rawName, framework = 'react')=>{
|
|
1991
2017
|
const nameError = NestedName.validate(rawName);
|
|
1992
2018
|
if (true !== nameError) return nameError;
|
|
1993
|
-
if (!
|
|
2019
|
+
if (!frontendKindLayouts(framework)[module.kind].nested && /[\\/]/.test(rawName)) return `UI-kit components and ${frontendKindTitles(framework).hook[1]} have no folders: enter a name without "/"`;
|
|
1994
2020
|
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
1995
2021
|
if (target !== module.path && external_node_fs_default().existsSync(target)) return `${external_node_path_default().relative(reactFolder, target)} already exists`;
|
|
1996
2022
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
@@ -2005,10 +2031,11 @@ const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? ext
|
|
|
2005
2031
|
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
2006
2032
|
const moveReactModule = (projectRoot, reactFolder, module, rawName, route, framework = 'react')=>{
|
|
2007
2033
|
const layout = frontendKindLayouts(framework)[module.kind];
|
|
2008
|
-
const newName = new NestedName(reactModuleName(module.kind, rawName));
|
|
2034
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName, framework));
|
|
2035
|
+
const { prefix } = frontendLogicNaming[framework];
|
|
2009
2036
|
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
2010
2037
|
const newClassName = newName.ClassName;
|
|
2011
|
-
const renameFile = (name)=>name.replace(new RegExp(`^(
|
|
2038
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(${prefix}-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, own = '')=>`${own}${newName.fileName}`);
|
|
2012
2039
|
const oldFolder = layout.inFolder ? module.path : external_node_path_default().dirname(module.path);
|
|
2013
2040
|
const newFolder = layout.inFolder ? target : external_node_path_default().dirname(target);
|
|
2014
2041
|
const ownsPath = (candidate)=>layout.inFolder ? candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`) : external_node_path_default().dirname(candidate) === oldFolder && layout.ownFile(module.fileBase).test(external_node_path_default().basename(candidate));
|
|
@@ -2118,7 +2145,7 @@ const svelteComponentContent = (propsType)=>`
|
|
|
2118
2145
|
let props: ${propsType} = $props()
|
|
2119
2146
|
</script>
|
|
2120
2147
|
`.trim();
|
|
2121
|
-
const svelteStory = (storybookFramework, componentName, componentFile, title)=>`
|
|
2148
|
+
const svelteStory = (storybookFramework, componentName, componentFile, title, propsType)=>`
|
|
2122
2149
|
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
2123
2150
|
import ${componentName} from './${componentFile}'
|
|
2124
2151
|
|
|
@@ -2132,6 +2159,7 @@ export default meta
|
|
|
2132
2159
|
type Story = StoryObj<typeof meta>
|
|
2133
2160
|
|
|
2134
2161
|
export const Default: Story = {
|
|
2162
|
+
// fill required props of ${propsType}
|
|
2135
2163
|
args: {}
|
|
2136
2164
|
}
|
|
2137
2165
|
`.trim();
|
|
@@ -2200,7 +2228,6 @@ const scaffoldSvelteWidget = async (presentationSvelteFolder)=>{
|
|
|
2200
2228
|
].join('/');
|
|
2201
2229
|
const widgetFileName = `${fileName}-widget`;
|
|
2202
2230
|
const uiFileName = `${fileName}-widget-ui`;
|
|
2203
|
-
const uiModelFileName = `use-${fileName}-ui-model`;
|
|
2204
2231
|
if ('monolithic' === widgetType) {
|
|
2205
2232
|
folder.createFile('index.ts', `
|
|
2206
2233
|
export { default as ${ClassName}Widget } from './${widgetFileName}.svelte'
|
|
@@ -2221,15 +2248,15 @@ export type ${ClassName}WidgetUIProps = { }
|
|
|
2221
2248
|
`.trim());
|
|
2222
2249
|
folder.createFile(`${widgetFileName}.svelte`, `
|
|
2223
2250
|
<script lang="ts">
|
|
2224
|
-
import type { ${ClassName}WidgetProps } from './types'
|
|
2251
|
+
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from './types'
|
|
2225
2252
|
import ${ClassName}WidgetUI from './ui/${uiFileName}.svelte'
|
|
2226
|
-
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}.svelte'
|
|
2227
2253
|
|
|
2228
2254
|
let props: ${ClassName}WidgetProps = $props()
|
|
2229
|
-
|
|
2255
|
+
|
|
2256
|
+
const toUIProps = (): ${ClassName}WidgetUIProps => ({})
|
|
2230
2257
|
</script>
|
|
2231
2258
|
|
|
2232
|
-
<${ClassName}WidgetUI {...
|
|
2259
|
+
<${ClassName}WidgetUI {...toUIProps()} />
|
|
2233
2260
|
`.trim());
|
|
2234
2261
|
folder.subitem([
|
|
2235
2262
|
'ui'
|
|
@@ -2243,16 +2270,7 @@ export type ${ClassName}WidgetUIProps = { }
|
|
|
2243
2270
|
const framework = scaffold_svelte_modules_storybookFramework();
|
|
2244
2271
|
if (framework) folder.subitem([
|
|
2245
2272
|
'ui'
|
|
2246
|
-
]).createFile(`${uiFileName}.stories.ts`, svelteStory(framework, `${ClassName}WidgetUI`, `${uiFileName}.svelte`, storyTitle));
|
|
2247
|
-
folder.subitem([
|
|
2248
|
-
'hooks'
|
|
2249
|
-
]).createFile(`${uiModelFileName}.svelte.ts`, `
|
|
2250
|
-
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
2251
|
-
|
|
2252
|
-
export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
|
|
2253
|
-
return {}
|
|
2254
|
-
}
|
|
2255
|
-
`.trim());
|
|
2273
|
+
]).createFile(`${uiFileName}.stories.ts`, svelteStory(framework, `${ClassName}WidgetUI`, `${uiFileName}.svelte`, storyTitle, `${ClassName}WidgetUIProps`));
|
|
2256
2274
|
return;
|
|
2257
2275
|
}
|
|
2258
2276
|
folder.createFile('types.ts', `
|
|
@@ -2266,23 +2284,14 @@ export type ${ClassName}WidgetProps = {
|
|
|
2266
2284
|
`.trim());
|
|
2267
2285
|
folder.createFile(`${widgetFileName}.svelte`, `
|
|
2268
2286
|
<script lang="ts">
|
|
2269
|
-
import type { ${ClassName}WidgetProps } from './types'
|
|
2270
|
-
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}.svelte'
|
|
2287
|
+
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from './types'
|
|
2271
2288
|
|
|
2272
|
-
let { UI, ...
|
|
2273
|
-
|
|
2289
|
+
let { UI, ...rest }: ${ClassName}WidgetProps = $props()
|
|
2290
|
+
|
|
2291
|
+
const toUIProps = (): ${ClassName}WidgetUIProps => ({})
|
|
2274
2292
|
</script>
|
|
2275
2293
|
|
|
2276
|
-
<UI {...
|
|
2277
|
-
`.trim());
|
|
2278
|
-
folder.subitem([
|
|
2279
|
-
'hooks'
|
|
2280
|
-
]).createFile(`${uiModelFileName}.svelte.ts`, `
|
|
2281
|
-
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
2282
|
-
|
|
2283
|
-
export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
|
|
2284
|
-
return {}
|
|
2285
|
-
}
|
|
2294
|
+
<UI {...toUIProps()} />
|
|
2286
2295
|
`.trim());
|
|
2287
2296
|
};
|
|
2288
2297
|
const scaffoldSvelteUIKitComponent = async (presentationSvelteFolder)=>{
|
|
@@ -2301,18 +2310,19 @@ export type { ${ClassName}Props } from './${fileName}.svelte'
|
|
|
2301
2310
|
`.trim());
|
|
2302
2311
|
componentFolder.createFile(`${fileName}.svelte`, svelteComponentContent(`${ClassName}Props`));
|
|
2303
2312
|
const framework = scaffold_svelte_modules_storybookFramework();
|
|
2304
|
-
if (framework) componentFolder.createFile(`${fileName}.stories.ts`, svelteStory(framework, ClassName, `${fileName}.svelte`, `UI-kit/${ClassName}`));
|
|
2313
|
+
if (framework) componentFolder.createFile(`${fileName}.stories.ts`, svelteStory(framework, ClassName, `${fileName}.svelte`, `UI-kit/${ClassName}`, `${ClassName}Props`));
|
|
2305
2314
|
};
|
|
2306
|
-
const
|
|
2315
|
+
const scaffoldSvelteSharedModel = async (presentationSvelteFolder)=>{
|
|
2307
2316
|
const name = await interaction_input({
|
|
2308
2317
|
key: 'name',
|
|
2309
|
-
message: 'Name without "
|
|
2318
|
+
message: 'Name without "create" (e.g. debounce): '
|
|
2310
2319
|
});
|
|
2311
|
-
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^
|
|
2320
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^create-/, ''));
|
|
2312
2321
|
presentationSvelteFolder.subitem([
|
|
2313
|
-
'
|
|
2314
|
-
|
|
2315
|
-
|
|
2322
|
+
'shared',
|
|
2323
|
+
'model'
|
|
2324
|
+
]).createFile(`create-${fileName}.svelte.ts`, `
|
|
2325
|
+
export const create${ClassName} = () => {
|
|
2316
2326
|
return {}
|
|
2317
2327
|
}
|
|
2318
2328
|
`.trim());
|
|
@@ -2510,22 +2520,30 @@ const swaggerPage = (rootFolder, outputPath, withNext = false)=>{
|
|
|
2510
2520
|
});
|
|
2511
2521
|
return withNext ? `'use client'\n\n${page}` : page;
|
|
2512
2522
|
};
|
|
2513
|
-
const
|
|
2523
|
+
const svelteKitStaticFolder = 'static/';
|
|
2524
|
+
const svelteKitStaticUrl = (outputPath)=>outputPath.startsWith(svelteKitStaticFolder) ? `/${outputPath.slice(svelteKitStaticFolder.length)}` : void 0;
|
|
2525
|
+
const svelteSwaggerPage = (rootFolder, outputPath, url)=>`
|
|
2514
2526
|
<script lang="ts" module>
|
|
2515
2527
|
export type SwaggerPageProps = {}
|
|
2516
2528
|
</script>
|
|
2517
2529
|
|
|
2518
2530
|
<script lang="ts">
|
|
2519
|
-
import 'swagger-ui
|
|
2520
|
-
import {
|
|
2521
|
-
import
|
|
2531
|
+
import 'swagger-ui-dist/swagger-ui.css'
|
|
2532
|
+
import type { SwaggerUIBundle as SwaggerUIBundleType } from 'swagger-ui-dist'
|
|
2533
|
+
import { onMount } from 'svelte'${url ? '' : `
|
|
2534
|
+
import spec from '${specImportOf(swaggerPagePath(rootFolder, 'svelte'), outputPath)}'`}
|
|
2522
2535
|
|
|
2523
2536
|
let props: SwaggerPageProps = $props()
|
|
2524
2537
|
let container: HTMLDivElement
|
|
2525
2538
|
|
|
2526
2539
|
onMount(async () => {
|
|
2527
|
-
|
|
2528
|
-
|
|
2540
|
+
// Self-contained bundle: React is bundled inside, no react deps in the project
|
|
2541
|
+
const { default: SwaggerUIBundle } = (await import(
|
|
2542
|
+
// @ts-expect-error -- swagger-ui-dist ships no types for this entry point
|
|
2543
|
+
'swagger-ui-dist/swagger-ui-bundle.js'
|
|
2544
|
+
)) as { default: SwaggerUIBundleType }
|
|
2545
|
+
|
|
2546
|
+
SwaggerUIBundle({ domNode: container, ${url ? `url: '${url}'` : 'spec'}, displayOperationId: true })
|
|
2529
2547
|
})
|
|
2530
2548
|
</script>
|
|
2531
2549
|
|
|
@@ -2537,8 +2555,8 @@ const swaggerPackages = {
|
|
|
2537
2555
|
types: '@types/swagger-ui-react'
|
|
2538
2556
|
},
|
|
2539
2557
|
svelte: {
|
|
2540
|
-
dependency: 'swagger-ui',
|
|
2541
|
-
types: '@types/swagger-ui'
|
|
2558
|
+
dependency: 'swagger-ui-dist',
|
|
2559
|
+
types: '@types/swagger-ui-dist'
|
|
2542
2560
|
}
|
|
2543
2561
|
};
|
|
2544
2562
|
const openapiScripts = {
|
|
@@ -2625,15 +2643,16 @@ const addOpenapi = async ()=>{
|
|
|
2625
2643
|
if (!generatorFile.exists || generatorFile.data !== content) generatorFile.data = content;
|
|
2626
2644
|
const routeFile = withSwaggerPage && 'react' === framework && usesNext() ? `${nextAppFolder(root)}/swagger/page.tsx` : withSwaggerPage && 'svelte' === framework && usesSvelteKit() ? `${svelteKitRoutesFolder(root)}/swagger/+page.svelte` : void 0;
|
|
2627
2645
|
let routeHint;
|
|
2646
|
+
const specUrl = 'svelte' === framework && usesSvelteKit() ? svelteKitStaticUrl(splitPath(outputPath).join('/')) : void 0;
|
|
2628
2647
|
if (withSwaggerPage) {
|
|
2629
2648
|
const pagePath = external_node_path_default().join(root, swaggerPagePath(rootFolder, framework));
|
|
2630
2649
|
const pageFile = new file_system_File(pagePath);
|
|
2631
|
-
const page = 'svelte' === framework ? svelteSwaggerPage(rootFolder, splitPath(outputPath).join('/')) : swaggerPage(rootFolder, splitPath(outputPath).join('/'), !!routeFile);
|
|
2650
|
+
const page = 'svelte' === framework ? svelteSwaggerPage(rootFolder, splitPath(outputPath).join('/'), specUrl) : swaggerPage(rootFolder, splitPath(outputPath).join('/'), !!routeFile);
|
|
2632
2651
|
if (!pageFile.exists || pageFile.data !== page) pageFile.data = page;
|
|
2633
2652
|
if (routeFile) routeHint = ('svelte' === framework ? scaffoldSvelteKitRoute : scaffoldNextRoute)(new NestedName('swagger'), pagePath);
|
|
2634
2653
|
}
|
|
2635
2654
|
const packages = swaggerPackages[framework ?? 'react'];
|
|
2636
|
-
const resolveJsonModule = withSwaggerPage ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
|
|
2655
|
+
const resolveJsonModule = withSwaggerPage && !specUrl ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
|
|
2637
2656
|
const hasRestHandlers = new file_system_File(external_node_path_default().join(root, rootFolder, 'presentation', 'rest', 'index.ts')).exists;
|
|
2638
2657
|
const missingExtractorPackages = withExtractor ? extractorPackages.filter((name)=>!dependencies[name]) : [];
|
|
2639
2658
|
return [
|
|
@@ -2847,7 +2866,7 @@ const addOrval = async ()=>{
|
|
|
2847
2866
|
message: 'Generate:',
|
|
2848
2867
|
choices: [
|
|
2849
2868
|
{
|
|
2850
|
-
name: 'svelte' === framework ? 'Svelte Query
|
|
2869
|
+
name: 'svelte' === framework ? 'Svelte Query (createQuery)' : 'React Query hooks',
|
|
2851
2870
|
value: 'hooks',
|
|
2852
2871
|
checked: true
|
|
2853
2872
|
},
|
|
@@ -5114,7 +5133,7 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
5114
5133
|
aggregate: agent_requests_name.optional()
|
|
5115
5134
|
})
|
|
5116
5135
|
]);
|
|
5117
|
-
const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnion('operation', [
|
|
5136
|
+
const frontendRequestSchema = (router, shared)=>external_zod_default().discriminatedUnion('operation', [
|
|
5118
5137
|
agent_requests_operation('page', {
|
|
5119
5138
|
...common,
|
|
5120
5139
|
name: agent_requests_nestedName
|
|
@@ -5132,7 +5151,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5132
5151
|
...common,
|
|
5133
5152
|
name: agent_requests_name
|
|
5134
5153
|
}),
|
|
5135
|
-
agent_requests_operation(
|
|
5154
|
+
agent_requests_operation(shared, {
|
|
5136
5155
|
...common,
|
|
5137
5156
|
name: agent_requests_name
|
|
5138
5157
|
}),
|
|
@@ -5156,7 +5175,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5156
5175
|
module: agent_requests_name,
|
|
5157
5176
|
name: agent_requests_name
|
|
5158
5177
|
}),
|
|
5159
|
-
agent_requests_operation(
|
|
5178
|
+
agent_requests_operation(`move-${shared}`, {
|
|
5160
5179
|
...common,
|
|
5161
5180
|
module: agent_requests_name,
|
|
5162
5181
|
name: agent_requests_name
|
|
@@ -5165,7 +5184,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5165
5184
|
...common,
|
|
5166
5185
|
module: agent_requests_name
|
|
5167
5186
|
}),
|
|
5168
|
-
agent_requests_operation(
|
|
5187
|
+
agent_requests_operation(`delete-${shared}`, {
|
|
5169
5188
|
...common,
|
|
5170
5189
|
module: agent_requests_name
|
|
5171
5190
|
}),
|
|
@@ -5175,8 +5194,8 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5175
5194
|
name: agent_requests_nestedName
|
|
5176
5195
|
})
|
|
5177
5196
|
]);
|
|
5178
|
-
const reactRequestSchema = frontendRequestSchema('Next.js');
|
|
5179
|
-
const svelteRequestSchema = frontendRequestSchema('SvelteKit');
|
|
5197
|
+
const reactRequestSchema = frontendRequestSchema('Next.js', 'shared-hook');
|
|
5198
|
+
const svelteRequestSchema = frontendRequestSchema('SvelteKit', 'shared-model');
|
|
5180
5199
|
const agent_requests_relativePath = external_zod_default().string().regex(/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*$/).refine((value)=>!value.split('/').some((part)=>'.' === part || '..' === part), 'Use a project-relative path without . or .. segments.');
|
|
5181
5200
|
const integrationRequestSchema = agent_requests_operation('add', {
|
|
5182
5201
|
...common,
|
|
@@ -5284,11 +5303,11 @@ const frameworkTitles = {
|
|
|
5284
5303
|
const deleteReactModuleUseCase = async (presentationReactFolder, kind, framework = 'react')=>{
|
|
5285
5304
|
const reactFolder = presentationReactFolder.path;
|
|
5286
5305
|
const modules = findReactModules(reactFolder, kind, framework);
|
|
5287
|
-
if (!modules.length) return void report(`No ${
|
|
5306
|
+
if (!modules.length) return void report(`No ${frontendKindTitles(framework)[kind][1]} generated by ${frameworkTitles[framework].cli} were found.`);
|
|
5288
5307
|
const module = await interaction_select({
|
|
5289
5308
|
key: 'module',
|
|
5290
5309
|
id: (value)=>value.name,
|
|
5291
|
-
message: `${
|
|
5310
|
+
message: `${frontendKindTitles(framework)[kind][0]} to delete:`,
|
|
5292
5311
|
choices: modules.map((value)=>({
|
|
5293
5312
|
name: value.name,
|
|
5294
5313
|
value,
|
|
@@ -5454,11 +5473,11 @@ const promptRouteMove = async (root, page, newName, framework)=>{
|
|
|
5454
5473
|
const moveReactModuleUseCase = async (presentationReactFolder, kind, framework = 'react')=>{
|
|
5455
5474
|
const reactFolder = presentationReactFolder.path;
|
|
5456
5475
|
const modules = findReactModules(reactFolder, kind, framework);
|
|
5457
|
-
if (!modules.length) return void report(`No ${
|
|
5476
|
+
if (!modules.length) return void report(`No ${frontendKindTitles(framework)[kind][1]} generated by ${frameworkTitles[framework].cli} were found.`);
|
|
5458
5477
|
const module = await interaction_select({
|
|
5459
5478
|
key: 'module',
|
|
5460
5479
|
id: (value)=>value.name,
|
|
5461
|
-
message: `${
|
|
5480
|
+
message: `${frontendKindTitles(framework)[kind][0]}:`,
|
|
5462
5481
|
choices: modules.map((value)=>({
|
|
5463
5482
|
name: value.name,
|
|
5464
5483
|
value,
|
|
@@ -6812,17 +6831,22 @@ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps
|
|
|
6812
6831
|
break;
|
|
6813
6832
|
}
|
|
6814
6833
|
};
|
|
6834
|
+
const sharedLogicOperation = {
|
|
6835
|
+
react: 'shared-hook',
|
|
6836
|
+
svelte: 'shared-model'
|
|
6837
|
+
};
|
|
6815
6838
|
const frontendOperations = (folder, framework)=>{
|
|
6839
|
+
const shared = sharedLogicOperation[framework];
|
|
6816
6840
|
const scaffold = 'svelte' === framework ? {
|
|
6817
6841
|
page: scaffoldSveltePage,
|
|
6818
6842
|
widget: scaffoldSvelteWidget,
|
|
6819
6843
|
'ui-kit-component': scaffoldSvelteUIKitComponent,
|
|
6820
|
-
|
|
6844
|
+
shared: scaffoldSvelteSharedModel
|
|
6821
6845
|
} : {
|
|
6822
6846
|
page: scaffoldReactPage,
|
|
6823
6847
|
widget: scaffoldReactWidget,
|
|
6824
6848
|
'ui-kit-component': scaffoldReactUIKitComponent,
|
|
6825
|
-
|
|
6849
|
+
shared: scaffoldReactSharedHook
|
|
6826
6850
|
};
|
|
6827
6851
|
const move = (kind)=>()=>moveReactModuleUseCase(folder, kind, framework);
|
|
6828
6852
|
const remove = (kind)=>()=>deleteReactModuleUseCase(folder, kind, framework);
|
|
@@ -6830,67 +6854,71 @@ const frontendOperations = (folder, framework)=>{
|
|
|
6830
6854
|
page: ()=>scaffold.page(folder),
|
|
6831
6855
|
widget: ()=>scaffold.widget(folder),
|
|
6832
6856
|
'ui-kit-component': ()=>scaffold['ui-kit-component'](folder),
|
|
6833
|
-
|
|
6857
|
+
[shared]: ()=>scaffold.shared(folder),
|
|
6834
6858
|
'move-page': move('page'),
|
|
6835
6859
|
'move-widget': move('widget'),
|
|
6836
6860
|
'move-ui-kit-component': move('ui-kit'),
|
|
6837
|
-
|
|
6861
|
+
[`move-${shared}`]: move('hook'),
|
|
6838
6862
|
'delete-page': remove('page'),
|
|
6839
6863
|
'delete-widget': remove('widget'),
|
|
6840
6864
|
'delete-ui-kit-component': remove('ui-kit'),
|
|
6841
|
-
|
|
6865
|
+
[`delete-${shared}`]: remove('hook')
|
|
6842
6866
|
};
|
|
6843
6867
|
};
|
|
6844
|
-
const frontendMenu =
|
|
6845
|
-
[
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6868
|
+
const frontendMenu = (framework)=>{
|
|
6869
|
+
const shared = sharedLogicOperation[framework];
|
|
6870
|
+
const title = 'svelte' === framework ? 'shared model' : 'shared hook';
|
|
6871
|
+
return [
|
|
6872
|
+
[
|
|
6873
|
+
'New widget',
|
|
6874
|
+
'widget'
|
|
6875
|
+
],
|
|
6876
|
+
[
|
|
6877
|
+
'New page',
|
|
6878
|
+
'page'
|
|
6879
|
+
],
|
|
6880
|
+
[
|
|
6881
|
+
'New UI-kit component',
|
|
6882
|
+
'ui-kit-component'
|
|
6883
|
+
],
|
|
6884
|
+
[
|
|
6885
|
+
`New ${title}`,
|
|
6886
|
+
shared
|
|
6887
|
+
],
|
|
6888
|
+
[
|
|
6889
|
+
'Move or rename widget',
|
|
6890
|
+
'move-widget'
|
|
6891
|
+
],
|
|
6892
|
+
[
|
|
6893
|
+
'Move or rename page',
|
|
6894
|
+
'move-page'
|
|
6895
|
+
],
|
|
6896
|
+
[
|
|
6897
|
+
'Move or rename UI-kit component',
|
|
6898
|
+
'move-ui-kit-component'
|
|
6899
|
+
],
|
|
6900
|
+
[
|
|
6901
|
+
`Move or rename ${title}`,
|
|
6902
|
+
`move-${shared}`
|
|
6903
|
+
],
|
|
6904
|
+
[
|
|
6905
|
+
'Delete widget',
|
|
6906
|
+
'delete-widget'
|
|
6907
|
+
],
|
|
6908
|
+
[
|
|
6909
|
+
'Delete page',
|
|
6910
|
+
'delete-page'
|
|
6911
|
+
],
|
|
6912
|
+
[
|
|
6913
|
+
'Delete UI-kit component',
|
|
6914
|
+
'delete-ui-kit-component'
|
|
6915
|
+
],
|
|
6916
|
+
[
|
|
6917
|
+
`Delete ${title}`,
|
|
6918
|
+
`delete-${shared}`
|
|
6919
|
+
]
|
|
6920
|
+
];
|
|
6921
|
+
};
|
|
6894
6922
|
const requireProject = ()=>{
|
|
6895
6923
|
try {
|
|
6896
6924
|
return new project_root_ProjectRoot().path;
|
|
@@ -6934,7 +6962,7 @@ const frontendModules = (root, rootFolder, framework)=>[
|
|
|
6934
6962
|
'ui-kit',
|
|
6935
6963
|
'hook'
|
|
6936
6964
|
].flatMap((kind)=>findReactModules(external_node_path_default().join(root, rootFolder, 'presentation', framework), kind, framework).map((module)=>({
|
|
6937
|
-
kind,
|
|
6965
|
+
kind: 'svelte' === framework && 'hook' === kind ? 'model' : kind,
|
|
6938
6966
|
name: module.name,
|
|
6939
6967
|
file: external_node_path_default().relative(root, module.path).split(external_node_path_default().sep).join('/')
|
|
6940
6968
|
})));
|
|
@@ -7122,9 +7150,9 @@ const executeFrontend = async (request, framework)=>{
|
|
|
7122
7150
|
'presentation',
|
|
7123
7151
|
framework
|
|
7124
7152
|
]);
|
|
7125
|
-
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' :
|
|
7153
|
+
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' : /-shared-(hook|model)$/.test(operation) ? 'hook' : void 0;
|
|
7126
7154
|
const kind = /^(move|delete)-/.test(request.operation) ? kindOf(request.operation) : void 0;
|
|
7127
|
-
if (kind && !findReactModules(folder.path, kind, framework).length) throw new RequestError('TARGET_NOT_FOUND', `No ${frameworkTitles[framework].title} ${
|
|
7155
|
+
if (kind && !findReactModules(folder.path, kind, framework).length) throw new RequestError('TARGET_NOT_FOUND', `No ${frameworkTitles[framework].title} ${frontendKindTitles(framework)[kind][1]} here.`);
|
|
7128
7156
|
return frontendOperations(folder, framework)[request.operation]();
|
|
7129
7157
|
};
|
|
7130
7158
|
const executeAgentRequest = async (command, value)=>{
|
|
@@ -7246,7 +7274,7 @@ Needs frontend.react in domain-first.project-structure.config.json.`,
|
|
|
7246
7274
|
help: `Usage: df-svelte
|
|
7247
7275
|
|
|
7248
7276
|
Scaffolds Svelte 5 modules of a Domain-First project: pages, widgets, UI-kit
|
|
7249
|
-
components and shared
|
|
7277
|
+
components and shared models (create… in .svelte.ts), and moves, renames or deletes
|
|
7250
7278
|
them. With SvelteKit, pages get their routes in src/routes.
|
|
7251
7279
|
Needs frontend.svelte in domain-first.project-structure.config.json.`,
|
|
7252
7280
|
notConfigured: 'Svelte is not configured: run df-init --section frontend.'
|
|
@@ -7292,7 +7320,7 @@ Options:
|
|
|
7292
7320
|
]);
|
|
7293
7321
|
const operation = await (0, prompts_namespaceObject.select)({
|
|
7294
7322
|
message: 'Module: ',
|
|
7295
|
-
choices: frontendMenu.map(([name, value])=>({
|
|
7323
|
+
choices: frontendMenu(framework).map(([name, value])=>({
|
|
7296
7324
|
name,
|
|
7297
7325
|
value
|
|
7298
7326
|
}))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { UpgradeStep } from './upgrade-steps';
|
|
2
|
+
/**
|
|
3
|
+
* Regenerates the Svelte Swagger UI page on `swagger-ui-dist`: `swagger-ui`
|
|
4
|
+
* renders with the project's React, and React 19 (brought by Storybook)
|
|
5
|
+
* has no `createRoot` in `react-dom`, so the page fails in the browser.
|
|
6
|
+
*/
|
|
7
|
+
export declare const svelteSwaggerPageStep: UpgradeStep;
|
|
8
|
+
/** Packages of the old Svelte Swagger UI page, to replace by hand. */
|
|
9
|
+
export declare const svelteSwaggerPackagesStep: UpgradeStep;
|
|
10
|
+
/**
|
|
11
|
+
* Svelte has no hooks: shared hooks move to `shared/model/create-*.svelte.ts`,
|
|
12
|
+
* `useN` becomes `createN`, and imports follow.
|
|
13
|
+
*/
|
|
14
|
+
export declare const svelteModelsStep: UpgradeStep;
|
|
15
|
+
/**
|
|
16
|
+
* Widgets map their props to UI props with `toUIProps`, called in the
|
|
17
|
+
* markup, so Svelte re-runs it on every change: a UI model file that only
|
|
18
|
+
* maps props moves into the widget and is deleted.
|
|
19
|
+
*/
|
|
20
|
+
export declare const svelteToUIPropsStep: UpgradeStep;
|
|
21
|
+
/** UI models with logic of their own: state, getters, other imports. */
|
|
22
|
+
export declare const svelteToUIPropsManualStep: UpgradeStep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|