02-rbor 0.1.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/LICENSE +21 -0
- package/README.md +429 -0
- package/bin/rbor.js +3 -0
- package/dist/analyzers/file-categorizer.d.ts +5 -0
- package/dist/analyzers/file-categorizer.js +269 -0
- package/dist/analyzers/file-categorizer.js.map +1 -0
- package/dist/analyzers/file-categorizer.test.d.ts +1 -0
- package/dist/analyzers/file-categorizer.test.js +155 -0
- package/dist/analyzers/file-categorizer.test.js.map +1 -0
- package/dist/analyzers/graph-builder.d.ts +4 -0
- package/dist/analyzers/graph-builder.js +509 -0
- package/dist/analyzers/graph-builder.js.map +1 -0
- package/dist/analyzers/import-parser.d.ts +8 -0
- package/dist/analyzers/import-parser.js +285 -0
- package/dist/analyzers/import-parser.js.map +1 -0
- package/dist/analyzers/import-parser.test.d.ts +1 -0
- package/dist/analyzers/import-parser.test.js +177 -0
- package/dist/analyzers/import-parser.test.js.map +1 -0
- package/dist/analyzers/index.d.ts +4 -0
- package/dist/analyzers/index.js +28 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/output-formatters.d.ts +11 -0
- package/dist/analyzers/output-formatters.js +451 -0
- package/dist/analyzers/output-formatters.js.map +1 -0
- package/dist/analyzers/yo.d.ts +1 -0
- package/dist/analyzers/yo.js +10 -0
- package/dist/analyzers/yo.js.map +1 -0
- package/dist/app/App.d.ts +1 -0
- package/dist/app/App.js +6 -0
- package/dist/app/App.js.map +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +167 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/analyze-deps.d.ts +12 -0
- package/dist/commands/analyze-deps.js +136 -0
- package/dist/commands/analyze-deps.js.map +1 -0
- package/dist/commands/generate-constant.d.ts +1 -0
- package/dist/commands/generate-constant.js +148 -0
- package/dist/commands/generate-constant.js.map +1 -0
- package/dist/commands/generate-domain.d.ts +2 -0
- package/dist/commands/generate-domain.js +87 -0
- package/dist/commands/generate-domain.js.map +1 -0
- package/dist/commands/generate-endpoint.d.ts +1 -0
- package/dist/commands/generate-endpoint.js +124 -0
- package/dist/commands/generate-endpoint.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.js +32 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list-domains.d.ts +1 -0
- package/dist/commands/list-domains.js +122 -0
- package/dist/commands/list-domains.js.map +1 -0
- package/dist/commands/validate.d.ts +4 -0
- package/dist/commands/validate.js +255 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/layouts/MainLayout.d.ts +1 -0
- package/dist/layouts/MainLayout.js +6 -0
- package/dist/layouts/MainLayout.js.map +1 -0
- package/dist/pages/HomePage.d.ts +1 -0
- package/dist/pages/HomePage.js +6 -0
- package/dist/pages/HomePage.js.map +1 -0
- package/dist/templates/barrel/index.d.ts +1 -0
- package/dist/templates/barrel/index.js +14 -0
- package/dist/templates/barrel/index.js.map +1 -0
- package/dist/templates/component/index.d.ts +1 -0
- package/dist/templates/component/index.js +6 -0
- package/dist/templates/component/index.js.map +1 -0
- package/dist/templates/component/main.d.ts +1 -0
- package/dist/templates/component/main.js +8 -0
- package/dist/templates/component/main.js.map +1 -0
- package/dist/templates/hooks/action.d.ts +1 -0
- package/dist/templates/hooks/action.js +49 -0
- package/dist/templates/hooks/action.js.map +1 -0
- package/dist/templates/hooks/controller.d.ts +1 -0
- package/dist/templates/hooks/controller.js +41 -0
- package/dist/templates/hooks/controller.js.map +1 -0
- package/dist/templates/hooks/data.d.ts +1 -0
- package/dist/templates/hooks/data.js +38 -0
- package/dist/templates/hooks/data.js.map +1 -0
- package/dist/templates/hooks/index.d.ts +3 -0
- package/dist/templates/hooks/index.js +10 -0
- package/dist/templates/hooks/index.js.map +1 -0
- package/dist/templates/index.d.ts +10 -0
- package/dist/templates/index.js +33 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/methods/index.d.ts +1 -0
- package/dist/templates/methods/index.js +85 -0
- package/dist/templates/methods/index.js.map +1 -0
- package/dist/templates/schema/index.d.ts +1 -0
- package/dist/templates/schema/index.js +40 -0
- package/dist/templates/schema/index.js.map +1 -0
- package/dist/templates/services/base-service-axios.d.ts +1 -0
- package/dist/templates/services/base-service-axios.js +77 -0
- package/dist/templates/services/base-service-axios.js.map +1 -0
- package/dist/templates/services/base-service-fetch.d.ts +1 -0
- package/dist/templates/services/base-service-fetch.js +113 -0
- package/dist/templates/services/base-service-fetch.js.map +1 -0
- package/dist/templates/services/base-service-ky.d.ts +1 -0
- package/dist/templates/services/base-service-ky.js +85 -0
- package/dist/templates/services/base-service-ky.js.map +1 -0
- package/dist/templates/services/base-service.d.ts +1 -0
- package/dist/templates/services/base-service.js +92 -0
- package/dist/templates/services/base-service.js.map +1 -0
- package/dist/templates/services/domain-service.d.ts +2 -0
- package/dist/templates/services/domain-service.js +95 -0
- package/dist/templates/services/domain-service.js.map +1 -0
- package/dist/templates/services/index.d.ts +7 -0
- package/dist/templates/services/index.js +23 -0
- package/dist/templates/services/index.js.map +1 -0
- package/dist/templates/services/service-factory.d.ts +4 -0
- package/dist/templates/services/service-factory.js +68 -0
- package/dist/templates/services/service-factory.js.map +1 -0
- package/dist/templates/types/index.d.ts +1 -0
- package/dist/templates/types/index.js +7 -0
- package/dist/templates/types/index.js.map +1 -0
- package/dist/templates/utils/build-url.d.ts +1 -0
- package/dist/templates/utils/build-url.js +72 -0
- package/dist/templates/utils/build-url.js.map +1 -0
- package/dist/templates/utils/endpoints.d.ts +2 -0
- package/dist/templates/utils/endpoints.js +23 -0
- package/dist/templates/utils/endpoints.js.map +1 -0
- package/dist/templates/utils/generateURL.d.ts +1 -0
- package/dist/templates/utils/generateURL.js +40 -0
- package/dist/templates/utils/generateURL.js.map +1 -0
- package/dist/templates/utils/index.d.ts +1 -0
- package/dist/templates/utils/index.js +7 -0
- package/dist/templates/utils/index.js.map +1 -0
- package/dist/types/dependency-graph.d.ts +95 -0
- package/dist/types/dependency-graph.js +13 -0
- package/dist/types/dependency-graph.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.d.ts +16 -0
- package/dist/utils/config.js +145 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/create-file.d.ts +13 -0
- package/dist/utils/create-file.js +159 -0
- package/dist/utils/create-file.js.map +1 -0
- package/dist/utils/dependency-installer.d.ts +5 -0
- package/dist/utils/dependency-installer.js +95 -0
- package/dist/utils/dependency-installer.js.map +1 -0
- package/dist/utils/file-finder.d.ts +6 -0
- package/dist/utils/file-finder.js +80 -0
- package/dist/utils/file-finder.js.map +1 -0
- package/dist/utils/naming.d.ts +11 -0
- package/dist/utils/naming.js +46 -0
- package/dist/utils/naming.js.map +1 -0
- package/dist/utils/naming.test.d.ts +1 -0
- package/dist/utils/naming.test.js +106 -0
- package/dist/utils/naming.test.js.map +1 -0
- package/dist/utils/service-factory-updater.d.ts +2 -0
- package/dist/utils/service-factory-updater.js +87 -0
- package/dist/utils/service-factory-updater.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mainComponentTemplate = void 0;
|
|
4
|
+
var main_1 = require("./main");
|
|
5
|
+
Object.defineProperty(exports, "mainComponentTemplate", { enumerable: true, get: function () { return main_1.mainComponentTemplate; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/component/index.ts"],"names":[],"mappings":";;;AAAA,+BAA+C;AAAtC,6GAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mainComponentTemplate(name: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mainComponentTemplate = mainComponentTemplate;
|
|
4
|
+
const naming_1 = require("../../utils/naming");
|
|
5
|
+
function mainComponentTemplate(name) {
|
|
6
|
+
return `// ${name} UI component\nexport function ${(0, naming_1.toPascalCase)(name)}() {};\n`;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/templates/component/main.ts"],"names":[],"mappings":";;AAEA,sDAEC;AAJD,+CAAkD;AAElD,SAAgB,qBAAqB,CAAC,IAAY;IAChD,OAAO,MAAM,IAAI,kCAAkC,IAAA,qBAAY,EAAC,IAAI,CAAC,UAAU,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function actionHookTemplate(name: string): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actionHookTemplate = actionHookTemplate;
|
|
4
|
+
const naming_1 = require("../../utils/naming");
|
|
5
|
+
const naming_2 = require("../../utils/naming");
|
|
6
|
+
function actionHookTemplate(name) {
|
|
7
|
+
const pascalName = (0, naming_1.toPascalCase)(name);
|
|
8
|
+
const kebabName = (0, naming_2.toKebabCase)(name);
|
|
9
|
+
const upperName = name.replace(/-/g, '_').toUpperCase();
|
|
10
|
+
return `// ${pascalName} Action Hook
|
|
11
|
+
// Provides mutation actions for the ${name} domain.
|
|
12
|
+
// Each action wraps a domain method with React Query's useMutation.
|
|
13
|
+
|
|
14
|
+
// import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
15
|
+
// import { ServiceFactory } from '../../../infrastructure/ServiceFactory';
|
|
16
|
+
// import { create${pascalName}, update${pascalName}, delete${pascalName} } from '../methods/${kebabName}-logic';
|
|
17
|
+
|
|
18
|
+
export const use${pascalName}Action = () => {
|
|
19
|
+
// const queryClient = useQueryClient();
|
|
20
|
+
// const service = ServiceFactory.create('${upperName}');
|
|
21
|
+
|
|
22
|
+
// const createMutation = useMutation({
|
|
23
|
+
// mutationFn: (data: unknown) => create${pascalName}(service, data),
|
|
24
|
+
// onSuccess: () => queryClient.invalidateQueries({ queryKey: ['${kebabName}'] }),
|
|
25
|
+
// });
|
|
26
|
+
|
|
27
|
+
// const updateMutation = useMutation({
|
|
28
|
+
// mutationFn: ({ id, data }: { id: string; data: unknown }) =>
|
|
29
|
+
// update${pascalName}(service, id, data),
|
|
30
|
+
// onSuccess: () => queryClient.invalidateQueries({ queryKey: ['${kebabName}'] }),
|
|
31
|
+
// });
|
|
32
|
+
|
|
33
|
+
// const deleteMutation = useMutation({
|
|
34
|
+
// mutationFn: (id: string) => delete${pascalName}(service, id),
|
|
35
|
+
// onSuccess: () => queryClient.invalidateQueries({ queryKey: ['${kebabName}'] }),
|
|
36
|
+
// });
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
// create: createMutation.mutateAsync,
|
|
40
|
+
// update: updateMutation.mutateAsync,
|
|
41
|
+
// remove: deleteMutation.mutateAsync,
|
|
42
|
+
// isCreating: createMutation.isPending,
|
|
43
|
+
// isUpdating: updateMutation.isPending,
|
|
44
|
+
// isDeleting: deleteMutation.isPending,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/templates/hooks/action.ts"],"names":[],"mappings":";;AAGA,gDA2CC;AA9CD,+CAAkD;AAClD,+CAAiD;AAEjD,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAExD,OAAO,MAAM,UAAU;uCACc,IAAI;;;;;oBAKvB,UAAU,WAAW,UAAU,WAAW,UAAU,uBAAuB,SAAS;;kBAEtF,UAAU;;8CAEkB,SAAS;;;8CAGT,UAAU;sEACc,SAAS;;;;;iBAK9D,UAAU;sEAC2C,SAAS;;;;2CAIpC,UAAU;sEACiB,SAAS;;;;;;;;;;;;CAY9E,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function controllerHookTemplate(name: string): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.controllerHookTemplate = controllerHookTemplate;
|
|
4
|
+
const naming_1 = require("../../utils/naming");
|
|
5
|
+
function controllerHookTemplate(name) {
|
|
6
|
+
const pascalName = (0, naming_1.toPascalCase)(name);
|
|
7
|
+
const kebabName = (0, naming_1.toKebabCase)(name);
|
|
8
|
+
const upperName = name.replace(/-/g, '_').toUpperCase();
|
|
9
|
+
return `// use${pascalName} Hook
|
|
10
|
+
// This hook creates the service object and wires up all domain methods.
|
|
11
|
+
// The component calls this hook to get everything it needs.
|
|
12
|
+
//
|
|
13
|
+
// NOTE: If you need access to the Redux store (or any other global state),
|
|
14
|
+
// access it in THIS hook and pass the values down to your methods.
|
|
15
|
+
// Methods should remain pure async functions — they should not import
|
|
16
|
+
// from the store directly.
|
|
17
|
+
|
|
18
|
+
import { ServiceFactory } from '../../../infrastructure/ServiceFactory';
|
|
19
|
+
import type { ${pascalName}Service } from '../services/${kebabName}-service';
|
|
20
|
+
import {
|
|
21
|
+
get${pascalName}List,
|
|
22
|
+
get${pascalName}ById,
|
|
23
|
+
create${pascalName},
|
|
24
|
+
update${pascalName},
|
|
25
|
+
delete${pascalName},
|
|
26
|
+
} from '../methods/${kebabName}-logic';
|
|
27
|
+
|
|
28
|
+
export const use${pascalName} = () => {
|
|
29
|
+
const service = ServiceFactory.create('${upperName}') as ${pascalName}Service;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
getList: () => get${pascalName}List(service),
|
|
33
|
+
getById: (id: string) => get${pascalName}ById(service, id),
|
|
34
|
+
create: (data: unknown) => create${pascalName}(service, data),
|
|
35
|
+
update: (id: string, data: unknown) => update${pascalName}(service, id, data),
|
|
36
|
+
remove: (id: string) => delete${pascalName}(service, id),
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/templates/hooks/controller.ts"],"names":[],"mappings":";;AAEA,wDAoCC;AAtCD,+CAA+D;AAE/D,SAAgB,sBAAsB,CAAC,IAAY;IACjD,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAExD,OAAO,SAAS,UAAU;;;;;;;;;;gBAUZ,UAAU,+BAA+B,SAAS;;OAE3D,UAAU;OACV,UAAU;UACP,UAAU;UACV,UAAU;UACV,UAAU;qBACC,SAAS;;kBAEZ,UAAU;2CACe,SAAS,SAAS,UAAU;;;wBAG/C,UAAU;kCACA,UAAU;uCACL,UAAU;mDACE,UAAU;oCACzB,UAAU;;;CAG7C,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dataHookTemplate(name: string): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataHookTemplate = dataHookTemplate;
|
|
4
|
+
const naming_1 = require("../../utils/naming");
|
|
5
|
+
const naming_2 = require("../../utils/naming");
|
|
6
|
+
function dataHookTemplate(name) {
|
|
7
|
+
const pascalName = (0, naming_1.toPascalCase)(name);
|
|
8
|
+
const kebabName = (0, naming_2.toKebabCase)(name);
|
|
9
|
+
const upperName = name.replace(/-/g, '_').toUpperCase();
|
|
10
|
+
return `// ${pascalName} Data Hook
|
|
11
|
+
// Fetches server state using React Query.
|
|
12
|
+
// Returns raw data — no formatting, no interpretation.
|
|
13
|
+
|
|
14
|
+
// import { useQuery } from '@tanstack/react-query';
|
|
15
|
+
// import { ServiceFactory } from '../../../infrastructure/ServiceFactory';
|
|
16
|
+
// import { get${pascalName}List, get${pascalName}ById } from '../methods/${kebabName}-logic';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Fetch the ${name} list
|
|
20
|
+
*/
|
|
21
|
+
export const use${pascalName}Data = () => {
|
|
22
|
+
// const service = ServiceFactory.create('${upperName}');
|
|
23
|
+
|
|
24
|
+
// const listQuery = useQuery({
|
|
25
|
+
// queryKey: ['${kebabName}', 'list'],
|
|
26
|
+
// queryFn: () => get${pascalName}List(service),
|
|
27
|
+
// });
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
// items: listQuery.data ?? [],
|
|
31
|
+
// isLoading: listQuery.isLoading,
|
|
32
|
+
// error: listQuery.error,
|
|
33
|
+
// refetch: listQuery.refetch,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../../src/templates/hooks/data.ts"],"names":[],"mappings":";;AAGA,4CAgCC;AAnCD,+CAAkD;AAClD,+CAAiD;AAEjD,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAExD,OAAO,MAAM,UAAU;;;;;;iBAMR,UAAU,YAAY,UAAU,2BAA2B,SAAS;;;eAGtE,IAAI;;kBAED,UAAU;8CACkB,SAAS;;;qBAGlC,SAAS;2BACH,UAAU;;;;;;;;;;CAUpC,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actionHookTemplate = exports.dataHookTemplate = exports.controllerHookTemplate = void 0;
|
|
4
|
+
var controller_1 = require("./controller");
|
|
5
|
+
Object.defineProperty(exports, "controllerHookTemplate", { enumerable: true, get: function () { return controller_1.controllerHookTemplate; } });
|
|
6
|
+
var data_1 = require("./data");
|
|
7
|
+
Object.defineProperty(exports, "dataHookTemplate", { enumerable: true, get: function () { return data_1.dataHookTemplate; } });
|
|
8
|
+
var action_1 = require("./action");
|
|
9
|
+
Object.defineProperty(exports, "actionHookTemplate", { enumerable: true, get: function () { return action_1.actionHookTemplate; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/hooks/index.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AAA7C,oHAAA,sBAAsB,OAAA;AAC/B,+BAA0C;AAAjC,wGAAA,gBAAgB,OAAA;AACzB,mCAA8C;AAArC,4GAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { barrelTemplate } from './barrel/index';
|
|
2
|
+
export { controllerHookTemplate, dataHookTemplate, actionHookTemplate } from './hooks/index';
|
|
3
|
+
export { mainComponentTemplate } from './component/index';
|
|
4
|
+
export { servicesTemplate, baseServiceTemplate, domainServiceTemplate, axiosBaseServiceTemplate, fetchBaseServiceTemplate, kyBaseServiceTemplate, serviceFactoryTemplate, } from './services/index';
|
|
5
|
+
export { methodsTemplate } from './methods/index';
|
|
6
|
+
export { typesTemplate } from './types/index';
|
|
7
|
+
export { utilsTemplate } from './utils/index';
|
|
8
|
+
export { schemaTemplate } from './schema/index';
|
|
9
|
+
export { generateUrlTemplate } from './utils/generateURL';
|
|
10
|
+
export { endpointsTemplate, endpointEntryTemplate } from './utils/endpoints';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.endpointEntryTemplate = exports.endpointsTemplate = exports.generateUrlTemplate = exports.schemaTemplate = exports.utilsTemplate = exports.typesTemplate = exports.methodsTemplate = exports.serviceFactoryTemplate = exports.kyBaseServiceTemplate = exports.fetchBaseServiceTemplate = exports.axiosBaseServiceTemplate = exports.domainServiceTemplate = exports.baseServiceTemplate = exports.servicesTemplate = exports.mainComponentTemplate = exports.actionHookTemplate = exports.dataHookTemplate = exports.controllerHookTemplate = exports.barrelTemplate = void 0;
|
|
4
|
+
var index_1 = require("./barrel/index");
|
|
5
|
+
Object.defineProperty(exports, "barrelTemplate", { enumerable: true, get: function () { return index_1.barrelTemplate; } });
|
|
6
|
+
var index_2 = require("./hooks/index");
|
|
7
|
+
Object.defineProperty(exports, "controllerHookTemplate", { enumerable: true, get: function () { return index_2.controllerHookTemplate; } });
|
|
8
|
+
Object.defineProperty(exports, "dataHookTemplate", { enumerable: true, get: function () { return index_2.dataHookTemplate; } });
|
|
9
|
+
Object.defineProperty(exports, "actionHookTemplate", { enumerable: true, get: function () { return index_2.actionHookTemplate; } });
|
|
10
|
+
var index_3 = require("./component/index");
|
|
11
|
+
Object.defineProperty(exports, "mainComponentTemplate", { enumerable: true, get: function () { return index_3.mainComponentTemplate; } });
|
|
12
|
+
var index_4 = require("./services/index");
|
|
13
|
+
Object.defineProperty(exports, "servicesTemplate", { enumerable: true, get: function () { return index_4.servicesTemplate; } });
|
|
14
|
+
Object.defineProperty(exports, "baseServiceTemplate", { enumerable: true, get: function () { return index_4.baseServiceTemplate; } });
|
|
15
|
+
Object.defineProperty(exports, "domainServiceTemplate", { enumerable: true, get: function () { return index_4.domainServiceTemplate; } });
|
|
16
|
+
Object.defineProperty(exports, "axiosBaseServiceTemplate", { enumerable: true, get: function () { return index_4.axiosBaseServiceTemplate; } });
|
|
17
|
+
Object.defineProperty(exports, "fetchBaseServiceTemplate", { enumerable: true, get: function () { return index_4.fetchBaseServiceTemplate; } });
|
|
18
|
+
Object.defineProperty(exports, "kyBaseServiceTemplate", { enumerable: true, get: function () { return index_4.kyBaseServiceTemplate; } });
|
|
19
|
+
Object.defineProperty(exports, "serviceFactoryTemplate", { enumerable: true, get: function () { return index_4.serviceFactoryTemplate; } });
|
|
20
|
+
var index_5 = require("./methods/index");
|
|
21
|
+
Object.defineProperty(exports, "methodsTemplate", { enumerable: true, get: function () { return index_5.methodsTemplate; } });
|
|
22
|
+
var index_6 = require("./types/index");
|
|
23
|
+
Object.defineProperty(exports, "typesTemplate", { enumerable: true, get: function () { return index_6.typesTemplate; } });
|
|
24
|
+
var index_7 = require("./utils/index");
|
|
25
|
+
Object.defineProperty(exports, "utilsTemplate", { enumerable: true, get: function () { return index_7.utilsTemplate; } });
|
|
26
|
+
var index_8 = require("./schema/index");
|
|
27
|
+
Object.defineProperty(exports, "schemaTemplate", { enumerable: true, get: function () { return index_8.schemaTemplate; } });
|
|
28
|
+
var generateURL_1 = require("./utils/generateURL");
|
|
29
|
+
Object.defineProperty(exports, "generateUrlTemplate", { enumerable: true, get: function () { return generateURL_1.generateUrlTemplate; } });
|
|
30
|
+
var endpoints_1 = require("./utils/endpoints");
|
|
31
|
+
Object.defineProperty(exports, "endpointsTemplate", { enumerable: true, get: function () { return endpoints_1.endpointsTemplate; } });
|
|
32
|
+
Object.defineProperty(exports, "endpointEntryTemplate", { enumerable: true, get: function () { return endpoints_1.endpointEntryTemplate; } });
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":";;;AAAA,wCAAgD;AAAvC,uGAAA,cAAc,OAAA;AAEvB,uCAA6F;AAApF,+GAAA,sBAAsB,OAAA;AAAE,yGAAA,gBAAgB,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAErE,2CAA0D;AAAjD,8GAAA,qBAAqB,OAAA;AAE9B,0CAQ0B;AAPxB,yGAAA,gBAAgB,OAAA;AAChB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA;AACxB,iHAAA,wBAAwB,OAAA;AACxB,8GAAA,qBAAqB,OAAA;AACrB,+GAAA,sBAAsB,OAAA;AAGxB,yCAAkD;AAAzC,wGAAA,eAAe,OAAA;AACxB,uCAA8C;AAArC,sGAAA,aAAa,OAAA;AACtB,uCAA8C;AAArC,sGAAA,aAAa,OAAA;AACtB,wCAAgD;AAAvC,uGAAA,cAAc,OAAA;AAEvB,mDAA0D;AAAjD,kHAAA,mBAAmB,OAAA;AAC5B,+CAA6E;AAApE,8GAAA,iBAAiB,OAAA;AAAE,kHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function methodsTemplate(name: string): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.methodsTemplate = methodsTemplate;
|
|
4
|
+
const naming_1 = require("../../utils/naming");
|
|
5
|
+
function methodsTemplate(name) {
|
|
6
|
+
const pascalName = (0, naming_1.toPascalCase)(name);
|
|
7
|
+
const upperName = name.replace(/-/g, '_').toUpperCase();
|
|
8
|
+
return `// ${pascalName} Logic - Pure async functions (React-independent)
|
|
9
|
+
// Each function receives the service as its first parameter for testability
|
|
10
|
+
|
|
11
|
+
import type { ${pascalName}Service } from '../services/${name}-service';
|
|
12
|
+
import { ${upperName}_ENDPOINTS } from '../utils/constant/${name}-endpoints';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Fetch all ${name} items
|
|
16
|
+
*/
|
|
17
|
+
export const get${pascalName}List = async (
|
|
18
|
+
service: ${pascalName}Service
|
|
19
|
+
): Promise<unknown[]> => {
|
|
20
|
+
const response = await service.get<unknown[]>(
|
|
21
|
+
${upperName}_ENDPOINTS.GET_${upperName}_LIST
|
|
22
|
+
);
|
|
23
|
+
return response?.data || [];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetch a single ${name} by ID
|
|
28
|
+
*/
|
|
29
|
+
export const get${pascalName}ById = async (
|
|
30
|
+
service: ${pascalName}Service,
|
|
31
|
+
id: string
|
|
32
|
+
): Promise<unknown> => {
|
|
33
|
+
const response = await service.get<unknown>(
|
|
34
|
+
${upperName}_ENDPOINTS.GET_${upperName}_BY_ID,
|
|
35
|
+
{ id } // params - will replace :id in endpoint
|
|
36
|
+
);
|
|
37
|
+
return response?.data;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a new ${name}
|
|
42
|
+
*/
|
|
43
|
+
export const create${pascalName} = async (
|
|
44
|
+
service: ${pascalName}Service,
|
|
45
|
+
data: unknown
|
|
46
|
+
): Promise<unknown> => {
|
|
47
|
+
const response = await service.post<unknown>(
|
|
48
|
+
${upperName}_ENDPOINTS.CREATE_${upperName},
|
|
49
|
+
data
|
|
50
|
+
);
|
|
51
|
+
return response?.data;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Update an existing ${name}
|
|
56
|
+
*/
|
|
57
|
+
export const update${pascalName} = async (
|
|
58
|
+
service: ${pascalName}Service,
|
|
59
|
+
id: string,
|
|
60
|
+
data: unknown
|
|
61
|
+
): Promise<unknown> => {
|
|
62
|
+
const response = await service.put<unknown>(
|
|
63
|
+
${upperName}_ENDPOINTS.UPDATE_${upperName},
|
|
64
|
+
data,
|
|
65
|
+
{ id } // params - will replace :id in endpoint
|
|
66
|
+
);
|
|
67
|
+
return response?.data;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Delete a ${name}
|
|
72
|
+
*/
|
|
73
|
+
export const delete${pascalName} = async (
|
|
74
|
+
service: ${pascalName}Service,
|
|
75
|
+
id: string
|
|
76
|
+
): Promise<unknown> => {
|
|
77
|
+
const response = await service.delete<unknown>(
|
|
78
|
+
${upperName}_ENDPOINTS.DELETE_${upperName},
|
|
79
|
+
{ id } // params - will replace :id in endpoint
|
|
80
|
+
);
|
|
81
|
+
return response?.data;
|
|
82
|
+
};
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/methods/index.ts"],"names":[],"mappings":";;AAEA,0CAgFC;AAlFD,+CAAkD;AAElD,SAAgB,eAAe,CAAC,IAAY;IAC1C,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAExD,OAAO,MAAM,UAAU;;;gBAGT,UAAU,+BAA+B,IAAI;WAClD,SAAS,wCAAwC,IAAI;;;eAGjD,IAAI;;kBAED,UAAU;aACf,UAAU;;;MAGjB,SAAS,kBAAkB,SAAS;;;;;;oBAMtB,IAAI;;kBAEN,UAAU;aACf,UAAU;;;;MAIjB,SAAS,kBAAkB,SAAS;;;;;;;kBAOxB,IAAI;;qBAED,UAAU;aAClB,UAAU;;;;MAIjB,SAAS,qBAAqB,SAAS;;;;;;;wBAOrB,IAAI;;qBAEP,UAAU;aAClB,UAAU;;;;;MAKjB,SAAS,qBAAqB,SAAS;;;;;;;;cAQ/B,IAAI;;qBAEG,UAAU;aAClB,UAAU;;;;MAIjB,SAAS,qBAAqB,SAAS;;;;;CAK5C,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function schemaTemplate(name: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schemaTemplate = schemaTemplate;
|
|
4
|
+
const naming_1 = require("../../utils/naming");
|
|
5
|
+
function schemaTemplate(name) {
|
|
6
|
+
const pascalName = (0, naming_1.toPascalCase)(name);
|
|
7
|
+
return `// ${pascalName} Validation Schemas
|
|
8
|
+
// Define your domain entity schemas here using zod.
|
|
9
|
+
// These schemas serve as the single source of truth for data shape and validation.
|
|
10
|
+
|
|
11
|
+
// import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
// export const ${pascalName}Schema = z.object({
|
|
14
|
+
// id: z.string(),
|
|
15
|
+
// // TODO: Add domain-specific fields
|
|
16
|
+
// createdAt: z.string().datetime(),
|
|
17
|
+
// updatedAt: z.string().datetime(),
|
|
18
|
+
// });
|
|
19
|
+
|
|
20
|
+
// /** Inferred TypeScript type from the schema */
|
|
21
|
+
// export type ${pascalName} = z.infer<typeof ${pascalName}Schema>;
|
|
22
|
+
|
|
23
|
+
// /** Schema for creating a new ${name} (omit auto-generated fields) */
|
|
24
|
+
// export const Create${pascalName}Schema = ${pascalName}Schema.omit({
|
|
25
|
+
// id: true,
|
|
26
|
+
// createdAt: true,
|
|
27
|
+
// updatedAt: true,
|
|
28
|
+
// });
|
|
29
|
+
|
|
30
|
+
// export type Create${pascalName} = z.infer<typeof Create${pascalName}Schema>;
|
|
31
|
+
|
|
32
|
+
// /** Schema for updating an existing ${name} (all fields optional) */
|
|
33
|
+
// export const Update${pascalName}Schema = Create${pascalName}Schema.partial();
|
|
34
|
+
|
|
35
|
+
// export type Update${pascalName} = z.infer<typeof Update${pascalName}Schema>;
|
|
36
|
+
|
|
37
|
+
export {};
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/schema/index.ts"],"names":[],"mappings":";;AAEA,wCAmCC;AArCD,+CAAkD;AAElD,SAAgB,cAAc,CAAC,IAAY;IACzC,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IAEtC,OAAO,MAAM,UAAU;;;;;;kBAMP,UAAU;;;;;;;;iBAQX,UAAU,qBAAqB,UAAU;;mCAEvB,IAAI;wBACf,UAAU,YAAY,UAAU;;;;;;uBAMjC,UAAU,2BAA2B,UAAU;;yCAE7B,IAAI;wBACrB,UAAU,kBAAkB,UAAU;;uBAEvC,UAAU,2BAA2B,UAAU;;;CAGrE,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function axiosBaseServiceTemplate(): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.axiosBaseServiceTemplate = axiosBaseServiceTemplate;
|
|
4
|
+
function axiosBaseServiceTemplate() {
|
|
5
|
+
return `import axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
6
|
+
|
|
7
|
+
export interface BaseResponse<T> {
|
|
8
|
+
data: T;
|
|
9
|
+
status: number;
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type RequestConfig = AxiosRequestConfig;
|
|
14
|
+
|
|
15
|
+
export abstract class BaseService {
|
|
16
|
+
protected readonly axios: AxiosInstance;
|
|
17
|
+
|
|
18
|
+
constructor(baseURL?: string) {
|
|
19
|
+
this.axios = axios.create({
|
|
20
|
+
baseURL: baseURL || '',
|
|
21
|
+
timeout: 30000,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
Accept: 'application/json',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
this.setupInterceptors();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private setupInterceptors(): void {
|
|
31
|
+
this.axios.interceptors.request.use(
|
|
32
|
+
(config) => {
|
|
33
|
+
// TODO: Add auth token logic here
|
|
34
|
+
// const token = getToken();
|
|
35
|
+
// if (token) config.headers.Authorization = \`Bearer \${token}\`;
|
|
36
|
+
return config;
|
|
37
|
+
},
|
|
38
|
+
(error) => Promise.reject(error)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
this.axios.interceptors.response.use(
|
|
42
|
+
(response) => response,
|
|
43
|
+
(error) => {
|
|
44
|
+
// TODO: Add error handling logic here
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected async get<T>(endpoint: string, config?: AxiosRequestConfig): Promise<BaseResponse<T>> {
|
|
51
|
+
const response = await this.axios.get<T>(endpoint, config);
|
|
52
|
+
return { data: response.data, status: response.status };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected async post<T>(endpoint: string, data?: unknown, config?: AxiosRequestConfig): Promise<BaseResponse<T>> {
|
|
56
|
+
const response = await this.axios.post<T>(endpoint, data, config);
|
|
57
|
+
return { data: response.data, status: response.status };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected async put<T>(endpoint: string, data?: unknown, config?: AxiosRequestConfig): Promise<BaseResponse<T>> {
|
|
61
|
+
const response = await this.axios.put<T>(endpoint, data, config);
|
|
62
|
+
return { data: response.data, status: response.status };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected async patch<T>(endpoint: string, data?: unknown, config?: AxiosRequestConfig): Promise<BaseResponse<T>> {
|
|
66
|
+
const response = await this.axios.patch<T>(endpoint, data, config);
|
|
67
|
+
return { data: response.data, status: response.status };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected async delete<T>(endpoint: string, config?: AxiosRequestConfig): Promise<BaseResponse<T>> {
|
|
71
|
+
const response = await this.axios.delete<T>(endpoint, config);
|
|
72
|
+
return { data: response.data, status: response.status };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=base-service-axios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-service-axios.js","sourceRoot":"","sources":["../../../src/templates/services/base-service-axios.ts"],"names":[],"mappings":";;AAAA,4DAwEC;AAxED,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsER,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fetchBaseServiceTemplate(): string;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchBaseServiceTemplate = fetchBaseServiceTemplate;
|
|
4
|
+
function fetchBaseServiceTemplate() {
|
|
5
|
+
return `export interface BaseResponse<T> {
|
|
6
|
+
data: T;
|
|
7
|
+
status: number;
|
|
8
|
+
message?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RequestConfig {
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
params?: Record<string, string>;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export abstract class BaseService {
|
|
18
|
+
protected readonly baseURL: string;
|
|
19
|
+
protected readonly defaultHeaders: Record<string, string>;
|
|
20
|
+
|
|
21
|
+
constructor(baseURL?: string) {
|
|
22
|
+
this.baseURL = baseURL || '';
|
|
23
|
+
this.defaultHeaders = {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
Accept: 'application/json',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private buildURL(endpoint: string, params?: Record<string, string>): string {
|
|
30
|
+
const url = new URL(endpoint, this.baseURL || window.location.origin);
|
|
31
|
+
if (params) {
|
|
32
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
33
|
+
url.searchParams.append(key, value);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return url.toString();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private async request<T>(
|
|
40
|
+
endpoint: string,
|
|
41
|
+
options: RequestInit & { params?: Record<string, string> } = {}
|
|
42
|
+
): Promise<BaseResponse<T>> {
|
|
43
|
+
const { params, ...fetchOptions } = options;
|
|
44
|
+
const url = this.buildURL(endpoint, params);
|
|
45
|
+
|
|
46
|
+
const headers = {
|
|
47
|
+
...this.defaultHeaders,
|
|
48
|
+
...this.getAuthHeader(),
|
|
49
|
+
...(options.headers || {}),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const response = await fetch(url, {
|
|
53
|
+
...fetchOptions,
|
|
54
|
+
headers,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
// TODO: Add error handling logic here
|
|
59
|
+
throw new Error(\`HTTP error! status: \${response.status}\`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const data = await response.json();
|
|
63
|
+
return { data, status: response.status };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected getAuthHeader(): Record<string, string> {
|
|
67
|
+
// TODO: Add auth token logic here
|
|
68
|
+
// const token = getToken();
|
|
69
|
+
// return token ? { Authorization: \`Bearer \${token}\` } : {};
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected async get<T>(endpoint: string, config?: RequestConfig): Promise<BaseResponse<T>> {
|
|
74
|
+
return this.request<T>(endpoint, {
|
|
75
|
+
method: 'GET',
|
|
76
|
+
...config,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected async post<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<BaseResponse<T>> {
|
|
81
|
+
return this.request<T>(endpoint, {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
84
|
+
...config,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected async put<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<BaseResponse<T>> {
|
|
89
|
+
return this.request<T>(endpoint, {
|
|
90
|
+
method: 'PUT',
|
|
91
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
92
|
+
...config,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
protected async patch<T>(endpoint: string, data?: unknown, config?: RequestConfig): Promise<BaseResponse<T>> {
|
|
97
|
+
return this.request<T>(endpoint, {
|
|
98
|
+
method: 'PATCH',
|
|
99
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
100
|
+
...config,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
protected async delete<T>(endpoint: string, config?: RequestConfig): Promise<BaseResponse<T>> {
|
|
105
|
+
return this.request<T>(endpoint, {
|
|
106
|
+
method: 'DELETE',
|
|
107
|
+
...config,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=base-service-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-service-fetch.js","sourceRoot":"","sources":["../../../src/templates/services/base-service-fetch.ts"],"names":[],"mappings":";;AAAA,4DA4GC;AA5GD,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0GR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function kyBaseServiceTemplate(): string;
|