api-core-lib 12.0.89 → 12.0.92
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/dist/cli.cjs +18 -11
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -447,10 +447,11 @@ import type { ${schemasToImport.join(", ")} } from './types';
|
|
|
447
447
|
}
|
|
448
448
|
const indexFilePath = import_path.default.join(moduleOutputPath, "index.ts");
|
|
449
449
|
const initialIndexContent = `// This file is auto-generated. Do not edit directly.
|
|
450
|
+
// This file is the main entry point for client-side code.
|
|
450
451
|
|
|
451
452
|
` + createdFileExports.map((e) => `export * from './${e}';`).join("\n");
|
|
452
453
|
import_fs.default.writeFileSync(indexFilePath, initialIndexContent);
|
|
453
|
-
console.log(import_chalk.default.gray(` \u2713 index.ts (Initial)`));
|
|
454
|
+
console.log(import_chalk.default.gray(` \u2713 index.ts (Initial Client Entry Point)`));
|
|
454
455
|
const moduleBaseName = module2.moduleName.replace(/Api$/, "");
|
|
455
456
|
const camelCaseModuleName = toCamelCase(moduleBaseName);
|
|
456
457
|
let endpointsContent = `// This file is auto-generated. Do not edit directly.
|
|
@@ -513,7 +514,6 @@ import { createApiModuleContext, useApiModule, UseApiModuleOptions } from 'api-c
|
|
|
513
514
|
import { apiClient } from '@/lib/api-core/clientApi'; // Assuming a fixed path
|
|
514
515
|
import { ${module2.moduleName}, ${module2.moduleName} as TModuleType } from './config';
|
|
515
516
|
|
|
516
|
-
// 1. Create the strongly-typed context, provider, and consumer hook
|
|
517
517
|
const {
|
|
518
518
|
Provider,
|
|
519
519
|
useContext: use${moduleBaseName}Context
|
|
@@ -521,7 +521,6 @@ const {
|
|
|
521
521
|
|
|
522
522
|
export { use${moduleBaseName}Context };
|
|
523
523
|
|
|
524
|
-
// 2. Create a custom Provider that encapsulates the useApiModule logic
|
|
525
524
|
type Options = Parameters<typeof useApiModule>[2];
|
|
526
525
|
|
|
527
526
|
interface ${moduleBaseName}ProviderProps {
|
|
@@ -540,7 +539,7 @@ export function ${moduleBaseName}Provider({ children, options = {} }: ${moduleBa
|
|
|
540
539
|
const contextFileName = `${camelCaseModuleName}.context.tsx`;
|
|
541
540
|
import_fs.default.writeFileSync(import_path.default.join(moduleOutputPath, contextFileName), contextFileContent.trim());
|
|
542
541
|
console.log(import_chalk.default.gray(` \u2713 ${contextFileName} (Strongly-Typed Context & Provider)`));
|
|
543
|
-
const
|
|
542
|
+
const serverHelperContent = `// This file is auto-generated. For server-side use only.
|
|
544
543
|
|
|
545
544
|
import { createServerApi } from 'api-core-lib/server';
|
|
546
545
|
import { serverApiClient } from '@/lib/api-core/serverApi'; // Assuming a fixed path
|
|
@@ -553,17 +552,25 @@ export const create${moduleBaseName}ServerApi = () => {
|
|
|
553
552
|
return createServerApi(serverApiClient, ${module2.moduleName});
|
|
554
553
|
};
|
|
555
554
|
`;
|
|
556
|
-
import_fs.default.writeFileSync(import_path.default.join(moduleOutputPath, `${camelCaseModuleName}.server.ts`),
|
|
555
|
+
import_fs.default.writeFileSync(import_path.default.join(moduleOutputPath, `${camelCaseModuleName}.server.ts`), serverHelperContent.trim());
|
|
557
556
|
console.log(import_chalk.default.gray(` \u2713 ${camelCaseModuleName}.server.ts (Server-Side Helper)`));
|
|
558
|
-
const
|
|
557
|
+
const clientExports = [
|
|
559
558
|
`
|
|
560
|
-
// Generated API helpers`,
|
|
559
|
+
// Generated API client helpers`,
|
|
561
560
|
`export * from './${camelCaseModuleName}.endpoints';`,
|
|
562
|
-
`export * from './${camelCaseModuleName}.context'
|
|
563
|
-
`export * from './${camelCaseModuleName}.server';`
|
|
561
|
+
`export * from './${camelCaseModuleName}.context';`
|
|
564
562
|
].join("\n");
|
|
565
|
-
import_fs.default.appendFileSync(indexFilePath,
|
|
566
|
-
console.log(import_chalk.default.gray(` \u2713 index.ts (Updated with helpers)`));
|
|
563
|
+
import_fs.default.appendFileSync(indexFilePath, clientExports);
|
|
564
|
+
console.log(import_chalk.default.gray(` \u2713 index.ts (Updated with client helpers)`));
|
|
565
|
+
const serverEntryPointContent = `// This file is auto-generated. For server-side use only.
|
|
566
|
+
// It serves as the entry point for server-specific utilities.
|
|
567
|
+
|
|
568
|
+
export * from './${camelCaseModuleName}.server';
|
|
569
|
+
// Also exporting endpoints, as they are environment-agnostic and useful on the server.
|
|
570
|
+
export * from './${camelCaseModuleName}.endpoints';
|
|
571
|
+
`;
|
|
572
|
+
import_fs.default.writeFileSync(import_path.default.join(moduleOutputPath, "server.ts"), serverEntryPointContent);
|
|
573
|
+
console.log(import_chalk.default.gray(` \u2713 server.ts (New Server Entry Point)`));
|
|
567
574
|
}
|
|
568
575
|
function _propToMock(prop) {
|
|
569
576
|
if (prop.example) return prop.example;
|