@adonisjs/core 7.0.0-next.2 → 7.0.0-next.3
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.
|
@@ -45,7 +45,12 @@ export function indexEntities(entities = {}) {
|
|
|
45
45
|
const events = Object.assign({ enabled: true, source: 'app/events', importAlias: '#events' }, entities.events);
|
|
46
46
|
const listeners = Object.assign({ enabled: true, source: 'app/listeners', importAlias: '#listeners' }, entities.listeners);
|
|
47
47
|
const controllers = Object.assign({ enabled: true, source: 'app/controllers', importAlias: '#controllers' }, entities.controllers);
|
|
48
|
-
const transformers = Object.assign({
|
|
48
|
+
const transformers = Object.assign({
|
|
49
|
+
enabled: false,
|
|
50
|
+
source: 'app/transformers',
|
|
51
|
+
importAlias: '#transformers',
|
|
52
|
+
withSharedProps: false,
|
|
53
|
+
}, entities.transformers);
|
|
49
54
|
return {
|
|
50
55
|
run(_, indexGenerator) {
|
|
51
56
|
if (events.enabled) {
|
|
@@ -96,7 +101,7 @@ export function indexEntities(entities = {}) {
|
|
|
96
101
|
},
|
|
97
102
|
transformValue: helpers.toImportPath,
|
|
98
103
|
});
|
|
99
|
-
outputTransformerDataObjects(transformersList, buffer);
|
|
104
|
+
outputTransformerDataObjects(transformersList, buffer, transformers.withSharedProps);
|
|
100
105
|
},
|
|
101
106
|
importAlias: transformers.importAlias,
|
|
102
107
|
output: '.adonisjs/client/data.d.ts',
|
package/build/src/types.d.ts
CHANGED
package/build/src/utils.d.ts
CHANGED
|
@@ -57,4 +57,4 @@ export declare function importTypeScript(app: ApplicationService): Promise<typeo
|
|
|
57
57
|
* // }
|
|
58
58
|
* // }
|
|
59
59
|
*/
|
|
60
|
-
export declare function outputTransformerDataObjects(transformersList: RecursiveFileTree, buffer: Assembler.FileBuffer): Promise<void>;
|
|
60
|
+
export declare function outputTransformerDataObjects(transformersList: RecursiveFileTree, buffer: Assembler.FileBuffer, withSharedProps: boolean): Promise<void>;
|
package/build/src/utils.js
CHANGED
|
@@ -71,9 +71,12 @@ export async function importTypeScript(app) {
|
|
|
71
71
|
* // }
|
|
72
72
|
* // }
|
|
73
73
|
*/
|
|
74
|
-
export async function outputTransformerDataObjects(transformersList, buffer) {
|
|
74
|
+
export async function outputTransformerDataObjects(transformersList, buffer, withSharedProps) {
|
|
75
75
|
const importsBuffer = buffer.create();
|
|
76
|
-
importsBuffer.write(`import { InferData } from '@adonisjs/core/types/transformers'`);
|
|
76
|
+
importsBuffer.write(`import type { InferData, InferVariants } from '@adonisjs/core/types/transformers'`);
|
|
77
|
+
if (withSharedProps) {
|
|
78
|
+
importsBuffer.write(`import type { InferSharedProps } from '@adonisjs/inertia/types'`);
|
|
79
|
+
}
|
|
77
80
|
buffer.writeLine(importsBuffer);
|
|
78
81
|
buffer.write('export namespace Data {').indent();
|
|
79
82
|
/**
|
|
@@ -91,6 +94,9 @@ export async function outputTransformerDataObjects(transformersList, buffer) {
|
|
|
91
94
|
const importName = `${parents.join()}${key}Transformer`;
|
|
92
95
|
importsBuffer.write(`import ${importName} from '${value}'`);
|
|
93
96
|
buffer.write(`export type ${key} = InferData<${importName}>`);
|
|
97
|
+
buffer.write(`export namespace ${key} {`).indent();
|
|
98
|
+
buffer.write(`export type Variants = InferVariants<${importName}>`);
|
|
99
|
+
buffer.dedent().write('}');
|
|
94
100
|
}
|
|
95
101
|
else {
|
|
96
102
|
buffer.write(`export namespace ${key} {`).indent();
|
|
@@ -100,5 +106,9 @@ export async function outputTransformerDataObjects(transformersList, buffer) {
|
|
|
100
106
|
});
|
|
101
107
|
}
|
|
102
108
|
generateNamespaceTree(transformersList, []);
|
|
109
|
+
if (withSharedProps) {
|
|
110
|
+
importsBuffer.write(`import type InertiaMiddleware from '#middleware/inertia_middleware'`);
|
|
111
|
+
buffer.write('export type SharedProps = InferSharedProps<InertiaMiddleware>');
|
|
112
|
+
}
|
|
103
113
|
buffer.dedent().write('}');
|
|
104
114
|
}
|