@microsoft/managed-apps-codegen 0.2.1
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 +153 -0
- package/README.md +37 -0
- package/dist/CodegenProject.d.ts +26 -0
- package/dist/CodegenProject.d.ts.map +1 -0
- package/dist/CodegenProject.js +140 -0
- package/dist/CodegenProject.js.map +1 -0
- package/dist/Connector/generateConnectorModel.d.ts +13 -0
- package/dist/Connector/generateConnectorModel.d.ts.map +1 -0
- package/dist/Connector/generateConnectorModel.js +163 -0
- package/dist/Connector/generateConnectorModel.js.map +1 -0
- package/dist/Connector/generateConnectorService.d.ts +15 -0
- package/dist/Connector/generateConnectorService.d.ts.map +1 -0
- package/dist/Connector/generateConnectorService.js +331 -0
- package/dist/Connector/generateConnectorService.js.map +1 -0
- package/dist/Connector/index.d.ts +6 -0
- package/dist/Connector/index.d.ts.map +1 -0
- package/dist/Connector/index.js +6 -0
- package/dist/Connector/index.js.map +1 -0
- package/dist/Dataverse/generateDataverseModel.d.ts +18 -0
- package/dist/Dataverse/generateDataverseModel.d.ts.map +1 -0
- package/dist/Dataverse/generateDataverseModel.js +226 -0
- package/dist/Dataverse/generateDataverseModel.js.map +1 -0
- package/dist/Dataverse/generateDataverseService.d.ts +17 -0
- package/dist/Dataverse/generateDataverseService.d.ts.map +1 -0
- package/dist/Dataverse/generateDataverseService.js +323 -0
- package/dist/Dataverse/generateDataverseService.js.map +1 -0
- package/dist/Dataverse/index.d.ts +6 -0
- package/dist/Dataverse/index.d.ts.map +1 -0
- package/dist/Dataverse/index.js +6 -0
- package/dist/Dataverse/index.js.map +1 -0
- package/dist/SharePointTabular/generateSharepointTabularModel.d.ts +16 -0
- package/dist/SharePointTabular/generateSharepointTabularModel.d.ts.map +1 -0
- package/dist/SharePointTabular/generateSharepointTabularModel.js +130 -0
- package/dist/SharePointTabular/generateSharepointTabularModel.js.map +1 -0
- package/dist/SharePointTabular/index.d.ts +5 -0
- package/dist/SharePointTabular/index.d.ts.map +1 -0
- package/dist/SharePointTabular/index.js +5 -0
- package/dist/SharePointTabular/index.js.map +1 -0
- package/dist/SqlStoredProc/generateSqlStoredProcModel.d.ts +16 -0
- package/dist/SqlStoredProc/generateSqlStoredProcModel.d.ts.map +1 -0
- package/dist/SqlStoredProc/generateSqlStoredProcModel.js +38 -0
- package/dist/SqlStoredProc/generateSqlStoredProcModel.js.map +1 -0
- package/dist/SqlStoredProc/generateSqlStoredProcService.d.ts +16 -0
- package/dist/SqlStoredProc/generateSqlStoredProcService.d.ts.map +1 -0
- package/dist/SqlStoredProc/generateSqlStoredProcService.js +89 -0
- package/dist/SqlStoredProc/generateSqlStoredProcService.js.map +1 -0
- package/dist/SqlStoredProc/index.d.ts +6 -0
- package/dist/SqlStoredProc/index.d.ts.map +1 -0
- package/dist/SqlStoredProc/index.js +6 -0
- package/dist/SqlStoredProc/index.js.map +1 -0
- package/dist/Tabular/generateCommonModels.d.ts +11 -0
- package/dist/Tabular/generateCommonModels.d.ts.map +1 -0
- package/dist/Tabular/generateCommonModels.js +27 -0
- package/dist/Tabular/generateCommonModels.js.map +1 -0
- package/dist/Tabular/generateTabularModel.d.ts +15 -0
- package/dist/Tabular/generateTabularModel.d.ts.map +1 -0
- package/dist/Tabular/generateTabularModel.js +31 -0
- package/dist/Tabular/generateTabularModel.js.map +1 -0
- package/dist/Tabular/generateTabularService.d.ts +19 -0
- package/dist/Tabular/generateTabularService.d.ts.map +1 -0
- package/dist/Tabular/generateTabularService.js +165 -0
- package/dist/Tabular/generateTabularService.js.map +1 -0
- package/dist/Tabular/index.d.ts +7 -0
- package/dist/Tabular/index.d.ts.map +1 -0
- package/dist/Tabular/index.js +7 -0
- package/dist/Tabular/index.js.map +1 -0
- package/dist/defaultPrettierConfig.d.ts +6 -0
- package/dist/defaultPrettierConfig.d.ts.map +1 -0
- package/dist/defaultPrettierConfig.js +10 -0
- package/dist/defaultPrettierConfig.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/constants.d.ts +9 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +9 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/dataverseUtils.d.ts +61 -0
- package/dist/shared/dataverseUtils.d.ts.map +1 -0
- package/dist/shared/dataverseUtils.js +138 -0
- package/dist/shared/dataverseUtils.js.map +1 -0
- package/dist/shared/flowUtils.d.ts +11 -0
- package/dist/shared/flowUtils.d.ts.map +1 -0
- package/dist/shared/flowUtils.js +16 -0
- package/dist/shared/flowUtils.js.map +1 -0
- package/dist/shared/nameUtils.d.ts +33 -0
- package/dist/shared/nameUtils.d.ts.map +1 -0
- package/dist/shared/nameUtils.js +180 -0
- package/dist/shared/nameUtils.js.map +1 -0
- package/dist/shared/project.d.ts +22 -0
- package/dist/shared/project.d.ts.map +1 -0
- package/dist/shared/project.js +5 -0
- package/dist/shared/project.js.map +1 -0
- package/dist/shared/schemaUtils.d.ts +32 -0
- package/dist/shared/schemaUtils.d.ts.map +1 -0
- package/dist/shared/schemaUtils.js +110 -0
- package/dist/shared/schemaUtils.js.map +1 -0
- package/dist/shared/sqlStoredProcUtils.d.ts +11 -0
- package/dist/shared/sqlStoredProcUtils.d.ts.map +1 -0
- package/dist/shared/sqlStoredProcUtils.js +19 -0
- package/dist/shared/sqlStoredProcUtils.js.map +1 -0
- package/dist/shared/swaggerUtils.d.ts +12 -0
- package/dist/shared/swaggerUtils.d.ts.map +1 -0
- package/dist/shared/swaggerUtils.js +12 -0
- package/dist/shared/swaggerUtils.js.map +1 -0
- package/dist/shared/typeUtils.d.ts +22 -0
- package/dist/shared/typeUtils.d.ts.map +1 -0
- package/dist/shared/typeUtils.js +94 -0
- package/dist/shared/typeUtils.js.map +1 -0
- package/dist/shared/types.d.ts +24 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import type { ICodegenContext } from '../shared/types.js';
|
|
5
|
+
interface GenerateServiceContext {
|
|
6
|
+
parentContext: ICodegenContext;
|
|
7
|
+
primaryKey: string;
|
|
8
|
+
hasLookupColumns: boolean;
|
|
9
|
+
multiSelectPicklistFields: string[];
|
|
10
|
+
fileColumnNames: string[];
|
|
11
|
+
imageColumnNames: string[];
|
|
12
|
+
serviceFilePath: string;
|
|
13
|
+
dataSourcesFilePath: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function generateDataverseService({ parentContext, primaryKey, hasLookupColumns, multiSelectPicklistFields, fileColumnNames, imageColumnNames, serviceFilePath, dataSourcesFilePath, }: GenerateServiceContext): Promise<void>;
|
|
16
|
+
export default generateDataverseService;
|
|
17
|
+
//# sourceMappingURL=generateDataverseService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDataverseService.d.ts","sourceRoot":"","sources":["../../src/Dataverse/generateDataverseService.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,UAAU,sBAAsB;IAC9B,aAAa,EAAE,eAAe,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyUxC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Scope } from 'ts-morph';
|
|
5
|
+
import { convertToValidIdentifier } from '../shared/nameUtils.js';
|
|
6
|
+
export async function generateDataverseService({ parentContext, primaryKey, hasLookupColumns, multiSelectPicklistFields, fileColumnNames, imageColumnNames, serviceFilePath, dataSourcesFilePath, }) {
|
|
7
|
+
const { modelName, dataSourceName, project } = parentContext;
|
|
8
|
+
const serviceName = `${convertToValidIdentifier(modelName)}Service`;
|
|
9
|
+
// When there are lookup columns the model generator emits a separate ModelNameBase interface
|
|
10
|
+
// for write operations (create/update) and ModelName extends it for read operations.
|
|
11
|
+
// When there are none, a single ModelName interface covers all operations.
|
|
12
|
+
const writeTypeName = hasLookupColumns
|
|
13
|
+
? `${convertToValidIdentifier(modelName)}Base`
|
|
14
|
+
: convertToValidIdentifier(modelName);
|
|
15
|
+
const readTypeName = convertToValidIdentifier(modelName);
|
|
16
|
+
const id = convertToValidIdentifier(modelName);
|
|
17
|
+
const fileColumnNameType = `${id}FileColumnName`;
|
|
18
|
+
const imageColumnNameType = `${id}ImageColumnName`;
|
|
19
|
+
const uploadColumnNameType = `${id}UploadColumnName`;
|
|
20
|
+
const hasFileColumns = fileColumnNames.length > 0;
|
|
21
|
+
const hasImageColumns = imageColumnNames.length > 0;
|
|
22
|
+
const hasFileOrImageColumns = hasFileColumns || hasImageColumns;
|
|
23
|
+
const hasMultiSelectFields = multiSelectPicklistFields.length > 0;
|
|
24
|
+
const createParamType = primaryKey !== '' ? `Omit<${writeTypeName}, '${primaryKey}'>` : writeTypeName;
|
|
25
|
+
const updateParamType = primaryKey !== '' ? `Partial<Omit<${writeTypeName}, '${primaryKey}'>>` : writeTypeName;
|
|
26
|
+
const sourceFile = await project.createFile('service', serviceFilePath, '');
|
|
27
|
+
// External package imports — fixMissingImports cannot resolve these.
|
|
28
|
+
const dataValueImports = ['getClient'];
|
|
29
|
+
if (hasMultiSelectFields) {
|
|
30
|
+
dataValueImports.push('deserializeMultiSelectPicklistFields', 'serializeMultiSelectPicklistFields');
|
|
31
|
+
}
|
|
32
|
+
sourceFile.addImportDeclaration({
|
|
33
|
+
moduleSpecifier: '@microsoft/managed-apps/data',
|
|
34
|
+
namedImports: dataValueImports,
|
|
35
|
+
});
|
|
36
|
+
sourceFile.addImportDeclaration({
|
|
37
|
+
moduleSpecifier: '@microsoft/managed-apps/data',
|
|
38
|
+
namedImports: ['IOperationResult'],
|
|
39
|
+
isTypeOnly: true,
|
|
40
|
+
});
|
|
41
|
+
sourceFile.addImportDeclaration({
|
|
42
|
+
moduleSpecifier: '@microsoft/managed-apps/data/metadata/dataverse',
|
|
43
|
+
namedImports: ['EntityMetadata', 'GetEntityMetadataOptions'],
|
|
44
|
+
isTypeOnly: true,
|
|
45
|
+
});
|
|
46
|
+
sourceFile.addImportDeclaration({
|
|
47
|
+
moduleSpecifier: dataSourcesFilePath,
|
|
48
|
+
defaultImport: 'dataSources',
|
|
49
|
+
});
|
|
50
|
+
// Internal in-project type imports - fixMissingImports would auto-add these at commit time,
|
|
51
|
+
// but it cannot detect that these are type-only imports. We add them explicitly to make them type-only.
|
|
52
|
+
sourceFile.addImportDeclaration({
|
|
53
|
+
moduleSpecifier: sourceFile.getRelativePathAsModuleSpecifierTo(project.getSourceFile('commonModel')),
|
|
54
|
+
namedImports: ['IGetAllOptions', 'IGetOptions'],
|
|
55
|
+
isTypeOnly: true,
|
|
56
|
+
});
|
|
57
|
+
const modelNamedImports = hasLookupColumns ? [writeTypeName, readTypeName] : [readTypeName];
|
|
58
|
+
if (hasFileColumns) {
|
|
59
|
+
modelNamedImports.push(fileColumnNameType);
|
|
60
|
+
}
|
|
61
|
+
if (hasImageColumns) {
|
|
62
|
+
modelNamedImports.push(imageColumnNameType);
|
|
63
|
+
}
|
|
64
|
+
if (hasFileOrImageColumns) {
|
|
65
|
+
modelNamedImports.push(uploadColumnNameType);
|
|
66
|
+
}
|
|
67
|
+
sourceFile.addImportDeclaration({
|
|
68
|
+
moduleSpecifier: sourceFile.getRelativePathAsModuleSpecifierTo(project.getSourceFile('model')),
|
|
69
|
+
namedImports: modelNamedImports,
|
|
70
|
+
isTypeOnly: true,
|
|
71
|
+
});
|
|
72
|
+
const multiSelectFieldsInitializer = `[${multiSelectPicklistFields.map((f) => `'${f}'`).join(', ')}] as const`;
|
|
73
|
+
sourceFile.addClass({
|
|
74
|
+
name: serviceName,
|
|
75
|
+
isExported: true,
|
|
76
|
+
properties: [
|
|
77
|
+
{
|
|
78
|
+
name: 'dataSourceName',
|
|
79
|
+
isStatic: true,
|
|
80
|
+
isReadonly: true,
|
|
81
|
+
scope: Scope.Private,
|
|
82
|
+
initializer: `'${dataSourceName.toLowerCase()}'`,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'client',
|
|
86
|
+
isStatic: true,
|
|
87
|
+
isReadonly: true,
|
|
88
|
+
scope: Scope.Private,
|
|
89
|
+
initializer: 'getClient(dataSources)',
|
|
90
|
+
},
|
|
91
|
+
// Emitted only when the entity has MultiSelectPicklist columns. Used as the field list
|
|
92
|
+
// passed to serializeMultiSelectPicklistFields / deserializeMultiSelectPicklistFields.
|
|
93
|
+
...(hasMultiSelectFields
|
|
94
|
+
? [
|
|
95
|
+
{
|
|
96
|
+
name: 'multiSelectPicklistFields',
|
|
97
|
+
isStatic: true,
|
|
98
|
+
isReadonly: true,
|
|
99
|
+
scope: Scope.Private,
|
|
100
|
+
initializer: multiSelectFieldsInitializer,
|
|
101
|
+
},
|
|
102
|
+
]
|
|
103
|
+
: []),
|
|
104
|
+
],
|
|
105
|
+
methods: [
|
|
106
|
+
{
|
|
107
|
+
name: 'create',
|
|
108
|
+
isStatic: true,
|
|
109
|
+
isAsync: true,
|
|
110
|
+
scope: Scope.Public,
|
|
111
|
+
parameters: [{ name: 'record', type: createParamType }],
|
|
112
|
+
returnType: `Promise<IOperationResult<${readTypeName}>>`,
|
|
113
|
+
statements: hasMultiSelectFields
|
|
114
|
+
? [
|
|
115
|
+
`const result = await ${serviceName}.client.createRecordAsync<Record<string, unknown>, ${readTypeName}>(${serviceName}.dataSourceName, serializeMultiSelectPicklistFields(record as Record<string, unknown>, ${serviceName}.multiSelectPicklistFields));`,
|
|
116
|
+
`if (result.data) { deserializeMultiSelectPicklistFields(result.data as Record<string, unknown>, ${serviceName}.multiSelectPicklistFields); }`,
|
|
117
|
+
'return result;',
|
|
118
|
+
]
|
|
119
|
+
: [
|
|
120
|
+
`const result = await ${serviceName}.client.createRecordAsync<${createParamType}, ${readTypeName}>(${serviceName}.dataSourceName, record);`,
|
|
121
|
+
'return result;',
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'update',
|
|
126
|
+
isStatic: true,
|
|
127
|
+
isAsync: true,
|
|
128
|
+
scope: Scope.Public,
|
|
129
|
+
parameters: [
|
|
130
|
+
{ name: 'id', type: 'string' },
|
|
131
|
+
{ name: 'changedFields', type: updateParamType },
|
|
132
|
+
],
|
|
133
|
+
returnType: `Promise<IOperationResult<${readTypeName}>>`,
|
|
134
|
+
statements: hasMultiSelectFields
|
|
135
|
+
? [
|
|
136
|
+
`const result = await ${serviceName}.client.updateRecordAsync<Record<string, unknown>, ${readTypeName}>(${serviceName}.dataSourceName, id, serializeMultiSelectPicklistFields(changedFields as Record<string, unknown>, ${serviceName}.multiSelectPicklistFields));`,
|
|
137
|
+
`if (result.data) { deserializeMultiSelectPicklistFields(result.data as Record<string, unknown>, ${serviceName}.multiSelectPicklistFields); }`,
|
|
138
|
+
'return result;',
|
|
139
|
+
]
|
|
140
|
+
: [
|
|
141
|
+
`const result = await ${serviceName}.client.updateRecordAsync<${updateParamType}, ${readTypeName}>(${serviceName}.dataSourceName, id, changedFields);`,
|
|
142
|
+
'return result;',
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'delete',
|
|
147
|
+
isStatic: true,
|
|
148
|
+
isAsync: true,
|
|
149
|
+
scope: Scope.Public,
|
|
150
|
+
parameters: [{ name: 'id', type: 'string' }],
|
|
151
|
+
returnType: 'Promise<void>',
|
|
152
|
+
statements: [
|
|
153
|
+
`await ${serviceName}.client.deleteRecordAsync(${serviceName}.dataSourceName, id);`,
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'get',
|
|
158
|
+
isStatic: true,
|
|
159
|
+
isAsync: true,
|
|
160
|
+
scope: Scope.Public,
|
|
161
|
+
parameters: [
|
|
162
|
+
{ name: 'id', type: 'string' },
|
|
163
|
+
{ name: 'options', type: 'IGetOptions', hasQuestionToken: true },
|
|
164
|
+
],
|
|
165
|
+
returnType: `Promise<IOperationResult<${readTypeName}>>`,
|
|
166
|
+
statements: hasMultiSelectFields
|
|
167
|
+
? [
|
|
168
|
+
`const result = await ${serviceName}.client.retrieveRecordAsync<${readTypeName}>(${serviceName}.dataSourceName, id, options);`,
|
|
169
|
+
`if (result.data) { deserializeMultiSelectPicklistFields(result.data as Record<string, unknown>, ${serviceName}.multiSelectPicklistFields); }`,
|
|
170
|
+
'return result;',
|
|
171
|
+
]
|
|
172
|
+
: [
|
|
173
|
+
`const result = await ${serviceName}.client.retrieveRecordAsync<${readTypeName}>(${serviceName}.dataSourceName, id, options);`,
|
|
174
|
+
'return result;',
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'getAll',
|
|
179
|
+
isStatic: true,
|
|
180
|
+
isAsync: true,
|
|
181
|
+
scope: Scope.Public,
|
|
182
|
+
parameters: [{ name: 'options', type: 'IGetAllOptions', hasQuestionToken: true }],
|
|
183
|
+
returnType: `Promise<IOperationResult<${readTypeName}[]>>`,
|
|
184
|
+
statements: hasMultiSelectFields
|
|
185
|
+
? [
|
|
186
|
+
`const result = await ${serviceName}.client.retrieveMultipleRecordsAsync<${readTypeName}>(${serviceName}.dataSourceName, options);`,
|
|
187
|
+
`result.data?.forEach(record => deserializeMultiSelectPicklistFields(record as Record<string, unknown>, ${serviceName}.multiSelectPicklistFields));`,
|
|
188
|
+
'return result;',
|
|
189
|
+
]
|
|
190
|
+
: [
|
|
191
|
+
`const result = await ${serviceName}.client.retrieveMultipleRecordsAsync<${readTypeName}>(${serviceName}.dataSourceName, options);`,
|
|
192
|
+
'return result;',
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'getMetadata',
|
|
197
|
+
isStatic: true,
|
|
198
|
+
scope: Scope.Public,
|
|
199
|
+
parameters: [
|
|
200
|
+
{
|
|
201
|
+
name: 'options',
|
|
202
|
+
type: `GetEntityMetadataOptions<${readTypeName}>`,
|
|
203
|
+
initializer: '{}',
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
returnType: `Promise<IOperationResult<Partial<EntityMetadata>>>`,
|
|
207
|
+
statements: [
|
|
208
|
+
`return ${serviceName}.client.executeAsync({`,
|
|
209
|
+
` dataverseRequest: {`,
|
|
210
|
+
` action: 'getEntityMetadata',`,
|
|
211
|
+
` parameters: {`,
|
|
212
|
+
` tableName: ${serviceName}.dataSourceName,`,
|
|
213
|
+
` options: options as GetEntityMetadataOptions,`,
|
|
214
|
+
` },`,
|
|
215
|
+
` },`,
|
|
216
|
+
`});`,
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
...(hasFileOrImageColumns
|
|
220
|
+
? [
|
|
221
|
+
{
|
|
222
|
+
name: 'upload',
|
|
223
|
+
isStatic: true,
|
|
224
|
+
isAsync: true,
|
|
225
|
+
scope: Scope.Public,
|
|
226
|
+
parameters: [
|
|
227
|
+
{ name: 'id', type: 'string' },
|
|
228
|
+
{ name: 'columnName', type: uploadColumnNameType },
|
|
229
|
+
{ name: 'file', type: 'File' },
|
|
230
|
+
{ name: 'fileDisplayName', type: 'string', hasQuestionToken: true },
|
|
231
|
+
],
|
|
232
|
+
returnType: 'Promise<IOperationResult<void>>',
|
|
233
|
+
statements: [
|
|
234
|
+
'const arrayBuffer = await file.arrayBuffer();',
|
|
235
|
+
'const data = new Uint8Array(arrayBuffer);',
|
|
236
|
+
`const result = await ${serviceName}.client.uploadFileToRecord(`,
|
|
237
|
+
` ${serviceName}.dataSourceName,`,
|
|
238
|
+
` id,`,
|
|
239
|
+
` columnName,`,
|
|
240
|
+
` fileDisplayName || file.name,`,
|
|
241
|
+
` data,`,
|
|
242
|
+
`);`,
|
|
243
|
+
'return result;',
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
]
|
|
247
|
+
: []),
|
|
248
|
+
...(hasFileColumns
|
|
249
|
+
? [
|
|
250
|
+
{
|
|
251
|
+
name: 'downloadFile',
|
|
252
|
+
isStatic: true,
|
|
253
|
+
isAsync: true,
|
|
254
|
+
scope: Scope.Public,
|
|
255
|
+
parameters: [
|
|
256
|
+
{ name: 'id', type: 'string' },
|
|
257
|
+
{ name: 'columnName', type: fileColumnNameType },
|
|
258
|
+
],
|
|
259
|
+
returnType: 'Promise<IOperationResult<Uint8Array>>',
|
|
260
|
+
statements: [
|
|
261
|
+
`const result = await ${serviceName}.client.downloadFileFromRecord(`,
|
|
262
|
+
` ${serviceName}.dataSourceName,`,
|
|
263
|
+
` id,`,
|
|
264
|
+
` columnName,`,
|
|
265
|
+
`);`,
|
|
266
|
+
'return result;',
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
]
|
|
270
|
+
: []),
|
|
271
|
+
...(hasImageColumns
|
|
272
|
+
? [
|
|
273
|
+
{
|
|
274
|
+
name: 'downloadImage',
|
|
275
|
+
isStatic: true,
|
|
276
|
+
isAsync: true,
|
|
277
|
+
scope: Scope.Public,
|
|
278
|
+
parameters: [
|
|
279
|
+
{ name: 'id', type: 'string' },
|
|
280
|
+
{ name: 'columnName', type: imageColumnNameType },
|
|
281
|
+
{ name: 'fullSize', type: 'boolean', initializer: 'false' },
|
|
282
|
+
],
|
|
283
|
+
returnType: 'Promise<IOperationResult<Uint8Array>>',
|
|
284
|
+
statements: [
|
|
285
|
+
`const result = await ${serviceName}.client.downloadImageFromRecord(`,
|
|
286
|
+
` ${serviceName}.dataSourceName,`,
|
|
287
|
+
` id,`,
|
|
288
|
+
` columnName,`,
|
|
289
|
+
` fullSize,`,
|
|
290
|
+
`);`,
|
|
291
|
+
'return result;',
|
|
292
|
+
],
|
|
293
|
+
},
|
|
294
|
+
]
|
|
295
|
+
: []),
|
|
296
|
+
...(hasFileOrImageColumns
|
|
297
|
+
? [
|
|
298
|
+
{
|
|
299
|
+
name: 'deleteFileOrImage',
|
|
300
|
+
isStatic: true,
|
|
301
|
+
isAsync: true,
|
|
302
|
+
scope: Scope.Public,
|
|
303
|
+
parameters: [
|
|
304
|
+
{ name: 'id', type: 'string' },
|
|
305
|
+
{ name: 'columnName', type: uploadColumnNameType },
|
|
306
|
+
],
|
|
307
|
+
returnType: 'Promise<IOperationResult<void>>',
|
|
308
|
+
statements: [
|
|
309
|
+
`const result = await ${serviceName}.client.deleteFileOrImageFromRecord(`,
|
|
310
|
+
` ${serviceName}.dataSourceName,`,
|
|
311
|
+
` id,`,
|
|
312
|
+
` columnName,`,
|
|
313
|
+
`);`,
|
|
314
|
+
'return result;',
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
]
|
|
318
|
+
: []),
|
|
319
|
+
],
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
export default generateDataverseService;
|
|
323
|
+
//# sourceMappingURL=generateDataverseService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDataverseService.js","sourceRoot":"","sources":["../../src/Dataverse/generateDataverseService.ts"],"names":[],"mappings":"AAAA;;GA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J,gBAAgB;yBACjB;qBACF;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,qBAAqB;gBACvB,CAAC,CAAC;oBACE;wBACE,IAAI,EAAE,mBAAmB;wBACzB,QAAQ,EAAE,IAAI;wBACd,OAAO,EAAE,IAAI;wBACb,KAAK,EAAE,KAAK,CAAC,MAAM;wBACnB,UAAU,EAAE;4BACV,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;4BAC9B,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,oBAAoB,EAAE;yBACnD;wBACD,UAAU,EAAE,iCAAiC;wBAC7C,UAAU,EAAE;4BACV,wBAAwB,WAAW,sCAAsC;4BACzE,KAAK,WAAW,kBAAkB;4BAClC,OAAO;4BACP,eAAe;4BACf,IAAI;4BACJ,gBAAgB;yBACjB;qBACF;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC,CAAC;AACL,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Dataverse/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Dataverse/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import type { ICodegenContext } from '../shared/types.js';
|
|
5
|
+
import type { JsonObject } from '../types.js';
|
|
6
|
+
interface GenerateSharepointTabularModelContext {
|
|
7
|
+
parentContext: ICodegenContext;
|
|
8
|
+
schema: JsonObject;
|
|
9
|
+
modelFilePath: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function generateSharepointTabularModel({ parentContext, schema, modelFilePath, }: GenerateSharepointTabularModelContext): Promise<{
|
|
12
|
+
primaryKey: string;
|
|
13
|
+
hasReferenceEntities: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export default generateSharepointTabularModel;
|
|
16
|
+
//# sourceMappingURL=generateSharepointTabularModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateSharepointTabularModel.d.ts","sourceRoot":"","sources":["../../src/SharePointTabular/generateSharepointTabularModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,UAAU,qCAAqC;IAC7C,aAAa,EAAE,eAAe,CAAC;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,8BAA8B,CAAC,EACnD,aAAa,EACb,MAAM,EACN,aAAa,GACd,EAAE,qCAAqC,GAAG,OAAO,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC,CAgHD;AAkCD,eAAe,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { convertToValidIdentifier, formatPropertyName, normalizePropertyName, } from '../shared/nameUtils.js';
|
|
5
|
+
import { getRequiredFields, getTabularItemsFromSchema, isJsonObject, isSharepointChoiceColumn, mapJsonTypeToTypeScript, } from '../shared/schemaUtils.js';
|
|
6
|
+
import { determineTypeScriptType } from '../shared/typeUtils.js';
|
|
7
|
+
export async function generateSharepointTabularModel({ parentContext, schema, modelFilePath, }) {
|
|
8
|
+
const { modelName, project } = parentContext;
|
|
9
|
+
const items = getTabularItemsFromSchema(schema);
|
|
10
|
+
let propertiesNode = {};
|
|
11
|
+
if (isJsonObject(items.properties)) {
|
|
12
|
+
propertiesNode = items.properties;
|
|
13
|
+
}
|
|
14
|
+
const requiredFields = getRequiredFields(items);
|
|
15
|
+
// Build reference entity mapping from schema.referencedEntities
|
|
16
|
+
const referenceEntityMapping = {};
|
|
17
|
+
if (isJsonObject(schema.referencedEntities)) {
|
|
18
|
+
for (const key of Object.keys(schema.referencedEntities)) {
|
|
19
|
+
referenceEntityMapping[key] = key + 'Value';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const hasReferenceEntities = Object.keys(referenceEntityMapping).length > 0;
|
|
23
|
+
// Detect primary key (raw property name, before formatting)
|
|
24
|
+
let primaryKey = '';
|
|
25
|
+
for (const [propName, propValue] of Object.entries(propertiesNode)) {
|
|
26
|
+
if (isJsonObject(propValue) && propValue['x-ms-keyType'] === 'primary') {
|
|
27
|
+
primaryKey = propName;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const sourceFile = await project.createFile('model', modelFilePath, '');
|
|
32
|
+
// Emit ${key}Value interfaces for each referencedEntity key that exists in properties
|
|
33
|
+
for (const [key, valueName] of Object.entries(referenceEntityMapping)) {
|
|
34
|
+
if (!(key in propertiesNode))
|
|
35
|
+
continue;
|
|
36
|
+
const propValue = propertiesNode[key];
|
|
37
|
+
if (!isJsonObject(propValue))
|
|
38
|
+
continue;
|
|
39
|
+
addReferenceEntityValueInterface(sourceFile, valueName, propValue);
|
|
40
|
+
}
|
|
41
|
+
// Emit ${modelName}Base interface — properties NOT in referenceEntityMapping
|
|
42
|
+
const baseProperties = Object.entries(propertiesNode)
|
|
43
|
+
.filter(([propName]) => !(propName in referenceEntityMapping))
|
|
44
|
+
.map(([propName, propValue]) => {
|
|
45
|
+
const propObj = isJsonObject(propValue) ? propValue : undefined;
|
|
46
|
+
const formattedName = normalizePropertyName(formatPropertyName(propName));
|
|
47
|
+
return {
|
|
48
|
+
name: formattedName,
|
|
49
|
+
type: determineTypeScriptType(modelName, propObj, '', propName),
|
|
50
|
+
hasQuestionToken: !requiredFields.has(propName),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
sourceFile.addInterface({
|
|
54
|
+
name: `${convertToValidIdentifier(modelName)}Base`,
|
|
55
|
+
isExported: true,
|
|
56
|
+
properties: baseProperties,
|
|
57
|
+
});
|
|
58
|
+
if (hasReferenceEntities) {
|
|
59
|
+
// Emit ${modelName}Read extends ${modelName}Base — reference entity props typed as ${key}Value
|
|
60
|
+
const readProperties = Object.entries(propertiesNode)
|
|
61
|
+
.filter(([propName]) => propName in referenceEntityMapping)
|
|
62
|
+
.map(([propName]) => {
|
|
63
|
+
const formattedName = normalizePropertyName(formatPropertyName(propName));
|
|
64
|
+
const isRequired = requiredFields.has(propName);
|
|
65
|
+
return {
|
|
66
|
+
name: formattedName,
|
|
67
|
+
type: referenceEntityMapping[propName],
|
|
68
|
+
hasQuestionToken: !isRequired,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
sourceFile.addInterface({
|
|
72
|
+
name: `${convertToValidIdentifier(modelName)}Read`,
|
|
73
|
+
isExported: true,
|
|
74
|
+
extends: [`${convertToValidIdentifier(modelName)}Base`],
|
|
75
|
+
properties: readProperties,
|
|
76
|
+
});
|
|
77
|
+
// Emit ${modelName}Write extends ${modelName}Base
|
|
78
|
+
// Choice columns → string/string[], others → ${key}Value (same as Read)
|
|
79
|
+
const writeProperties = Object.entries(propertiesNode)
|
|
80
|
+
.filter(([propName]) => propName in referenceEntityMapping)
|
|
81
|
+
.map(([propName, propValue]) => {
|
|
82
|
+
const propObj = isJsonObject(propValue) ? propValue : undefined;
|
|
83
|
+
const formattedName = normalizePropertyName(formatPropertyName(propName));
|
|
84
|
+
const isRequired = requiredFields.has(propName);
|
|
85
|
+
let type;
|
|
86
|
+
if (isSharepointChoiceColumn(propValue)) {
|
|
87
|
+
type = propObj?.type === 'array' ? 'string[]' : 'string';
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
type = referenceEntityMapping[propName];
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
name: formattedName,
|
|
94
|
+
type,
|
|
95
|
+
hasQuestionToken: !isRequired,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
sourceFile.addInterface({
|
|
99
|
+
name: `${convertToValidIdentifier(modelName)}Write`,
|
|
100
|
+
isExported: true,
|
|
101
|
+
extends: [`${convertToValidIdentifier(modelName)}Base`],
|
|
102
|
+
properties: writeProperties,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return { primaryKey, hasReferenceEntities };
|
|
106
|
+
}
|
|
107
|
+
// Emits a ${key}Value interface whose properties come from the referenced property's nested schema.
|
|
108
|
+
// Replicates V1's addInnerPropertyDeclaration logic.
|
|
109
|
+
function addReferenceEntityValueInterface(sourceFile, interfaceName, propValue) {
|
|
110
|
+
let subPropertiesNode;
|
|
111
|
+
if (isJsonObject(propValue.properties)) {
|
|
112
|
+
subPropertiesNode = propValue.properties;
|
|
113
|
+
}
|
|
114
|
+
else if (isJsonObject(propValue.items) &&
|
|
115
|
+
isJsonObject(propValue.items.properties)) {
|
|
116
|
+
subPropertiesNode = propValue.items.properties;
|
|
117
|
+
}
|
|
118
|
+
const properties = subPropertiesNode !== undefined
|
|
119
|
+
? Object.entries(subPropertiesNode).map(([subPropName, subPropValue]) => {
|
|
120
|
+
const formattedName = formatPropertyName(subPropName);
|
|
121
|
+
const type = isJsonObject(subPropValue)
|
|
122
|
+
? mapJsonTypeToTypeScript(subPropValue.type)
|
|
123
|
+
: 'unknown';
|
|
124
|
+
return { name: formattedName, type, hasQuestionToken: false };
|
|
125
|
+
})
|
|
126
|
+
: [];
|
|
127
|
+
sourceFile.addInterface({ name: interfaceName, isExported: true, properties });
|
|
128
|
+
}
|
|
129
|
+
export default generateSharepointTabularModel;
|
|
130
|
+
//# sourceMappingURL=generateSharepointTabularModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateSharepointTabularModel.js","sourceRoot":"","sources":["../../src/SharePointTabular/generateSharepointTabularModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAS9D,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,EACnD,aAAa,EACb,MAAM,EACN,aAAa,GACyB;IAItC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC;IAE7C,MAAM,KAAK,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAEhD,IAAI,cAAc,GAAe,EAAE,CAAC;IACpC,IAAI,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,cAAc,GAAG,KAAK,CAAC,UAAwB,CAAC;IAClD,CAAC;IAED,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEhD,gEAAgE;IAChE,MAAM,sBAAsB,GAA2B,EAAE,CAAC;IAC1D,IAAI,YAAY,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC5C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACzD,sBAAsB,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC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|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/SharePointTabular/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import type { ICodegenContext } from '../shared/types.js';
|
|
5
|
+
import type { JsonObject } from '../types.js';
|
|
6
|
+
interface GenerateSqlStoredProcModelContext {
|
|
7
|
+
parentContext: ICodegenContext;
|
|
8
|
+
schema: JsonObject;
|
|
9
|
+
modelFilePath: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function generateSqlStoredProcModel({ parentContext, schema, modelFilePath, }: GenerateSqlStoredProcModelContext): Promise<{
|
|
12
|
+
requestModelName: string | null;
|
|
13
|
+
responseModelName: string;
|
|
14
|
+
}>;
|
|
15
|
+
export default generateSqlStoredProcModel;
|
|
16
|
+
//# sourceMappingURL=generateSqlStoredProcModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateSqlStoredProcModel.d.ts","sourceRoot":"","sources":["../../src/SqlStoredProc/generateSqlStoredProcModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,UAAU,iCAAiC;IACzC,aAAa,EAAE,eAAe,CAAC;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,0BAA0B,CAAC,EAC/C,aAAa,EACb,MAAM,EACN,aAAa,GACd,EAAE,iCAAiC,GAAG,OAAO,CAAC;IAC7C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CAwCD;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { convertToValidIdentifier } from '../shared/nameUtils.js';
|
|
5
|
+
import { getPropertiesNode, getRequiredFields, isJsonObject } from '../shared/schemaUtils.js';
|
|
6
|
+
import { buildInterfaceProperties } from '../shared/typeUtils.js';
|
|
7
|
+
export async function generateSqlStoredProcModel({ parentContext, schema, modelFilePath, }) {
|
|
8
|
+
const { modelName, project } = parentContext;
|
|
9
|
+
if (!isJsonObject(schema.schema) || !isJsonObject(schema.schema.procedureresultschema)) {
|
|
10
|
+
throw new Error(`Invalid SQL stored procedure schema for '${modelName}': expected schema.procedureresultschema to be an object`);
|
|
11
|
+
}
|
|
12
|
+
const schemaNode = schema.schema;
|
|
13
|
+
const sourceFile = await project.createFile('model', modelFilePath, '');
|
|
14
|
+
let requestModelName = null;
|
|
15
|
+
if (isJsonObject(schemaNode.inputparameters)) {
|
|
16
|
+
const propertiesNode = getPropertiesNode(schemaNode.inputparameters);
|
|
17
|
+
const requiredFields = getRequiredFields(schemaNode.inputparameters);
|
|
18
|
+
const requestName = `${convertToValidIdentifier(modelName)}Request`;
|
|
19
|
+
sourceFile.addInterface({
|
|
20
|
+
name: requestName,
|
|
21
|
+
isExported: true,
|
|
22
|
+
properties: buildInterfaceProperties(propertiesNode, requiredFields, modelName),
|
|
23
|
+
});
|
|
24
|
+
requestModelName = requestName;
|
|
25
|
+
}
|
|
26
|
+
const procedureResultSchema = schemaNode.procedureresultschema;
|
|
27
|
+
const propertiesNode = getPropertiesNode(procedureResultSchema);
|
|
28
|
+
const requiredFields = getRequiredFields(procedureResultSchema);
|
|
29
|
+
const responseModelName = `${convertToValidIdentifier(modelName)}Response`;
|
|
30
|
+
sourceFile.addInterface({
|
|
31
|
+
name: responseModelName,
|
|
32
|
+
isExported: true,
|
|
33
|
+
properties: buildInterfaceProperties(propertiesNode, requiredFields, modelName),
|
|
34
|
+
});
|
|
35
|
+
return { requestModelName, responseModelName };
|
|
36
|
+
}
|
|
37
|
+
export default generateSqlStoredProcModel;
|
|
38
|
+
//# sourceMappingURL=generateSqlStoredProcModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateSqlStoredProcModel.js","sourceRoot":"","sources":["../../src/SqlStoredProc/generateSqlStoredProcModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAS/D,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,EAC/C,aAAa,EACb,MAAM,EACN,aAAa,GACqB;IAIlC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC;IAE7C,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACvF,MAAM,IAAI,KAAK,CACb,4CAA4C,SAAS,0DAA0D,CAChH,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IAEjC,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;IAExE,IAAI,gBAAgB,GAAkB,IAAI,CAAC;IAE3C,IAAI,YAAY,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QAC7C,MAAM,cAAc,GAAG,iBAAiB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QACrE,MAAM,cAAc,GAAG,iBAAiB,C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