@odata2ts/odata2ts 0.26.1 → 0.28.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.
@@ -1 +1 @@
1
- {"version":3,"file":"DataModelDigestionV4.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV4.ts"],"names":[],"mappings":";;;;AAAA,mEAAoF;AACpF,qDAAmE;AAGnE,6DAA2D;AAC3D,mDAA6F;AAKtF,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,IAAA,kCAAc,EAAC,0BAAa,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AALW,QAAA,MAAM,UAKjB;AAEF,MAAM,UAAW,SAAQ,6BAA+C;IACtE,YACE,OAAwB,EACxB,OAAyB,EACzB,YAA0B,EAC1B,UAAkC;QAElC,KAAK,CAAC,4BAAY,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAES,kBAAkB,CAAC,UAAsC;QACjE,OAAQ,UAA2B,CAAC,kBAAkB,IAAI,EAAE,CAAC;IAC/D,CAAC;IAES,gBAAgB,CAAC,MAAgB;QACzC,sBAAsB;QACtB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,2CAA0B,CAAC;QACjF,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,uCAAwB,CAAC;IAC/E,CAAC;IAES,qBAAqB,CAAC,MAAgB;;QAC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CAAC,CAAC,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;gBAC5D,IAAI;gBACJ,KAAK;gBACL,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC;gBACtF,IAAI,EAAE,IAAI;gBACV,UAAU,EAAE,MAAM;gBAClB,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,oBAAoB,CAAC,IAAY;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,GAAG,CAAC,CAAC;SACrE;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { MappedConverterChains, loadConverters } from \"@odata2ts/converter-runtime\";\r\nimport { ODataTypesV4, ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { Digester, TypeModel } from \"./DataModelDigestion\";\r\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase\";\r\nimport { ComplexTypeV4, EntityTypeV4, Operation, SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\n\r\nexport const digest: DigesterFunction<SchemaV4> = async (schemas, options, namingHelper) => {\r\n const converters = await loadConverters(ODataVersions.V2, options.converters);\r\n\r\n const digester = new DigesterV4(schemas, options, namingHelper, converters);\r\n return digester.digest();\r\n};\r\n\r\nclass DigesterV4 extends Digester<SchemaV4, EntityTypeV4, ComplexTypeV4> {\r\n constructor(\r\n schemas: Array<SchemaV4>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n super(ODataVersion.V4, schemas, options, namingHelper, converters);\r\n }\r\n\r\n protected getNavigationProps(entityType: ComplexType | EntityTypeV4): Array<Property> {\r\n return (entityType as EntityTypeV4).NavigationProperty || [];\r\n }\r\n\r\n protected digestOperations(schema: SchemaV4) {\r\n // functions & actions\r\n this.addOperations(schema.$.Namespace, schema.Function, OperationTypes.Function);\r\n this.addOperations(schema.$.Namespace, schema.Action, OperationTypes.Action);\r\n }\r\n\r\n protected digestEntityContainer(schema: SchemaV4) {\r\n if (schema.EntityContainer && schema.EntityContainer.length) {\r\n const container = schema.EntityContainer[0];\r\n\r\n container.ActionImport?.forEach((actionImport) => {\r\n const name = this.namingHelper.getActionName(actionImport.$.Name);\r\n const operationName = this.namingHelper.getActionName(actionImport.$.Action);\r\n\r\n this.dataModel.addAction(name, {\r\n name: name,\r\n odataName: actionImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n });\r\n });\r\n\r\n container.FunctionImport?.forEach((funcImport) => {\r\n const name = this.namingHelper.getFunctionName(funcImport.$.Name);\r\n const operationName = this.namingHelper.getFunctionName(funcImport.$.Function);\r\n\r\n this.dataModel.addFunction(name, {\r\n name,\r\n odataName: funcImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n entitySet: funcImport.$.EntitySet,\r\n });\r\n });\r\n\r\n container.Singleton?.forEach((singleton) => {\r\n const name = singleton.$.Name;\r\n const navPropBindings = singleton.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addSingleton(name, {\r\n name,\r\n odataName: singleton.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(singleton.$.Type)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n\r\n container.EntitySet?.forEach((entitySet) => {\r\n const name = entitySet.$.Name;\r\n const navPropBindings = entitySet.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addEntitySet(name, {\r\n name,\r\n odataName: entitySet.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(entitySet.$.EntityType)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n }\r\n }\r\n\r\n protected mapODataType(type: string): TypeModel {\r\n switch (type) {\r\n case ODataTypesV4.Boolean:\r\n return {\r\n outputType: \"boolean\",\r\n qPath: \"QBooleanPath\",\r\n qCollection: \"QBooleanCollection\",\r\n qParam: \"QBooleanParam\",\r\n };\r\n case ODataTypesV4.Byte:\r\n case ODataTypesV4.SByte:\r\n case ODataTypesV4.Int16:\r\n case ODataTypesV4.Int32:\r\n case ODataTypesV4.Int64:\r\n case ODataTypesV4.Single:\r\n case ODataTypesV4.Double:\r\n case ODataTypesV4.Decimal:\r\n return {\r\n outputType: \"number\",\r\n qPath: \"QNumberPath\",\r\n qCollection: \"QNumberCollection\",\r\n qParam: \"QNumberParam\",\r\n };\r\n case ODataTypesV4.String:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: \"QStringParam\",\r\n };\r\n case ODataTypesV4.Date:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDatePath\",\r\n qCollection: \"QDateCollection\",\r\n qParam: \"QDateParam\",\r\n };\r\n case ODataTypesV4.TimeOfDay:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QTimeOfDayPath\",\r\n qCollection: \"QTimeOfDayCollection\",\r\n qParam: \"QTimeOfDayParam\",\r\n };\r\n case ODataTypesV4.DateTimeOffset:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeOffsetPath\",\r\n qCollection: \"QDateTimeOffsetCollection\",\r\n qParam: \"QDateTimeOffsetParam\",\r\n };\r\n case ODataTypesV4.Binary:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBinaryPath\",\r\n qCollection: \"QBinaryCollection\",\r\n qParam: undefined,\r\n };\r\n case ODataTypesV4.Guid:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QGuidPath\",\r\n qCollection: \"QGuidCollection\",\r\n qParam: \"QGuidParam\",\r\n };\r\n default:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: undefined,\r\n };\r\n }\r\n }\r\n\r\n private addOperations(namespace: string, operations: Array<Operation> | undefined, type: OperationTypes) {\r\n if (!operations || !operations.length) {\r\n return;\r\n }\r\n\r\n operations.forEach((op) => {\r\n const params: Array<PropertyModel> = op.Parameter?.map((p) => this.mapProp(p)) ?? [];\r\n const returnType: PropertyModel | undefined = op.ReturnType?.map((rt) => {\r\n return this.mapProp({ ...rt, $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", ...rt.$ } });\r\n })[0];\r\n const isBound = op.$.IsBound === \"true\";\r\n\r\n if (isBound && !params.length) {\r\n throw new Error(`IllegalState: Operation '${op.$.Name}' is bound, but has no parameters!`);\r\n }\r\n\r\n const bindingProp = isBound ? params.shift() : undefined;\r\n const binding = bindingProp\r\n ? bindingProp.isCollection\r\n ? `Collection(${bindingProp.type})`\r\n : bindingProp.type\r\n : DigesterV4.ROOT_OPERATION;\r\n\r\n const name =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getFunctionName(op.$.Name)\r\n : this.namingHelper.getActionName(op.$.Name);\r\n const qName =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getQFunctionName(op.$.Name, bindingProp)\r\n : this.namingHelper.getQActionName(op.$.Name, bindingProp);\r\n this.dataModel.addOperationType(binding, {\r\n odataName: isBound ? `${namespace}.${op.$.Name}` : op.$.Name,\r\n name,\r\n qName,\r\n paramsModelName: this.namingHelper.getOperationParamsModelName(op.$.Name, bindingProp),\r\n type: type,\r\n parameters: params,\r\n returnType: returnType,\r\n });\r\n });\r\n }\r\n\r\n private getRootOperationType(name: string): OperationType {\r\n const rootOps = this.dataModel.getOperationTypeByBinding(DigesterV4.ROOT_OPERATION);\r\n const rootOp = rootOps.find((op) => op.name === name);\r\n if (!rootOp) {\r\n throw new Error(`Couldn't find root operation with name [${name}]`);\r\n }\r\n return rootOp;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DataModelDigestionV4.js","sourceRoot":"","sources":["../../src/data-model/DataModelDigestionV4.ts"],"names":[],"mappings":";;;;AAAA,mEAAoF;AACpF,qDAAmE;AAGnE,6DAA2D;AAC3D,mDAA6F;AAKtF,MAAM,MAAM,GAA+B,CAAO,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,MAAM,IAAA,kCAAc,EAAC,0BAAa,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC3B,CAAC,CAAA,CAAC;AALW,QAAA,MAAM,UAKjB;AAEF,MAAM,UAAW,SAAQ,6BAA+C;IACtE,YACE,OAAwB,EACxB,OAAyB,EACzB,YAA0B,EAC1B,UAAkC;QAElC,KAAK,CAAC,4BAAY,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAES,kBAAkB,CAAC,UAAsC;QACjE,OAAQ,UAA2B,CAAC,kBAAkB,IAAI,EAAE,CAAC;IAC/D,CAAC;IAES,gBAAgB,CAAC,MAAgB;QACzC,sBAAs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ata2ts/converter-runtime\";\r\nimport { ODataTypesV4, ODataVersions } from \"@odata2ts/odata-core\";\r\n\r\nimport { DigesterFunction, DigestionOptions } from \"../FactoryFunctionModel\";\r\nimport { Digester, TypeModel } from \"./DataModelDigestion\";\r\nimport { ODataVersion, OperationType, OperationTypes, PropertyModel } from \"./DataTypeModel\";\r\nimport { ComplexType, Property } from \"./edmx/ODataEdmxModelBase\";\r\nimport { ComplexTypeV4, EntityTypeV4, Operation, SchemaV4 } from \"./edmx/ODataEdmxModelV4\";\r\nimport { NamingHelper } from \"./NamingHelper\";\r\n\r\nexport const digest: DigesterFunction<SchemaV4> = async (schemas, options, namingHelper) => {\r\n const converters = await loadConverters(ODataVersions.V2, options.converters);\r\n\r\n const digester = new DigesterV4(schemas, options, namingHelper, converters);\r\n return digester.digest();\r\n};\r\n\r\nclass DigesterV4 extends Digester<SchemaV4, EntityTypeV4, ComplexTypeV4> {\r\n constructor(\r\n schemas: Array<SchemaV4>,\r\n options: DigestionOptions,\r\n namingHelper: NamingHelper,\r\n converters?: MappedConverterChains\r\n ) {\r\n super(ODataVersion.V4, schemas, options, namingHelper, converters);\r\n }\r\n\r\n protected getNavigationProps(entityType: ComplexType | EntityTypeV4): Array<Property> {\r\n return (entityType as EntityTypeV4).NavigationProperty || [];\r\n }\r\n\r\n protected digestOperations(schema: SchemaV4) {\r\n // functions & actions\r\n this.addOperations(schema.$.Namespace, schema.Function, OperationTypes.Function);\r\n this.addOperations(schema.$.Namespace, schema.Action, OperationTypes.Action);\r\n }\r\n\r\n protected digestEntityContainer(schema: SchemaV4) {\r\n if (schema.EntityContainer && schema.EntityContainer.length) {\r\n const container = schema.EntityContainer[0];\r\n\r\n container.ActionImport?.forEach((actionImport) => {\r\n const name = this.namingHelper.getActionName(actionImport.$.Name);\r\n const operationName = this.namingHelper.getActionName(actionImport.$.Action);\r\n\r\n this.dataModel.addAction(name, {\r\n name: name,\r\n odataName: actionImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n });\r\n });\r\n\r\n container.FunctionImport?.forEach((funcImport) => {\r\n const name = this.namingHelper.getFunctionName(funcImport.$.Name);\r\n const operationName = this.namingHelper.getFunctionName(funcImport.$.Function);\r\n\r\n this.dataModel.addFunction(name, {\r\n name,\r\n odataName: funcImport.$.Name,\r\n operation: this.getRootOperationType(operationName),\r\n entitySet: funcImport.$.EntitySet,\r\n });\r\n });\r\n\r\n container.Singleton?.forEach((singleton) => {\r\n const name = singleton.$.Name;\r\n const navPropBindings = singleton.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addSingleton(name, {\r\n name,\r\n odataName: singleton.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(singleton.$.Type)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n\r\n container.EntitySet?.forEach((entitySet) => {\r\n const name = entitySet.$.Name;\r\n const navPropBindings = entitySet.NavigationPropertyBinding || [];\r\n\r\n this.dataModel.addEntitySet(name, {\r\n name,\r\n odataName: entitySet.$.Name,\r\n entityType: this.dataModel.getModel(this.namingHelper.getModelName(entitySet.$.EntityType)),\r\n navPropBinding: navPropBindings.map((binding) => ({\r\n path: this.namingHelper.stripServicePrefix(binding.$.Path),\r\n target: binding.$.Target,\r\n })),\r\n });\r\n });\r\n }\r\n }\r\n\r\n protected mapODataType(type: string): TypeModel {\r\n switch (type) {\r\n case ODataTypesV4.Boolean:\r\n return {\r\n outputType: \"boolean\",\r\n qPath: \"QBooleanPath\",\r\n qCollection: \"QBooleanCollection\",\r\n qParam: \"QBooleanParam\",\r\n };\r\n case ODataTypesV4.Int64:\r\n case ODataTypesV4.Decimal:\r\n if (this.options.v4BigNumberAsString) {\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBigNumberPath\",\r\n qCollection: \"QBigNumberCollection\",\r\n qParam: \"QBigNumberParam\",\r\n };\r\n }\r\n // yes, intentional fall through!\r\n case ODataTypesV4.Byte:\r\n case ODataTypesV4.SByte:\r\n case ODataTypesV4.Int16:\r\n case ODataTypesV4.Int32:\r\n case ODataTypesV4.Single:\r\n case ODataTypesV4.Double:\r\n return {\r\n outputType: \"number\",\r\n qPath: \"QNumberPath\",\r\n qCollection: \"QNumberCollection\",\r\n qParam: \"QNumberParam\",\r\n };\r\n case ODataTypesV4.String:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: \"QStringParam\",\r\n };\r\n case ODataTypesV4.Date:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDatePath\",\r\n qCollection: \"QDateCollection\",\r\n qParam: \"QDateParam\",\r\n };\r\n case ODataTypesV4.TimeOfDay:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QTimeOfDayPath\",\r\n qCollection: \"QTimeOfDayCollection\",\r\n qParam: \"QTimeOfDayParam\",\r\n };\r\n case ODataTypesV4.DateTimeOffset:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QDateTimeOffsetPath\",\r\n qCollection: \"QDateTimeOffsetCollection\",\r\n qParam: \"QDateTimeOffsetParam\",\r\n };\r\n case ODataTypesV4.Binary:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QBinaryPath\",\r\n qCollection: \"QBinaryCollection\",\r\n qParam: undefined,\r\n };\r\n case ODataTypesV4.Guid:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QGuidPath\",\r\n qCollection: \"QGuidCollection\",\r\n qParam: \"QGuidParam\",\r\n };\r\n default:\r\n return {\r\n outputType: \"string\",\r\n qPath: \"QStringPath\",\r\n qCollection: \"QStringCollection\",\r\n qParam: undefined,\r\n };\r\n }\r\n }\r\n\r\n private addOperations(namespace: string, operations: Array<Operation> | undefined, type: OperationTypes) {\r\n if (!operations || !operations.length) {\r\n return;\r\n }\r\n\r\n operations.forEach((op) => {\r\n const params: Array<PropertyModel> = op.Parameter?.map((p) => this.mapProp(p)) ?? [];\r\n const returnType: PropertyModel | undefined = op.ReturnType?.map((rt) => {\r\n return this.mapProp({ ...rt, $: { Name: \"NO_NAME_BECAUSE_RETURN_TYPE\", ...rt.$ } });\r\n })[0];\r\n const isBound = op.$.IsBound === \"true\";\r\n\r\n if (isBound && !params.length) {\r\n throw new Error(`IllegalState: Operation '${op.$.Name}' is bound, but has no parameters!`);\r\n }\r\n\r\n const bindingProp = isBound ? params.shift() : undefined;\r\n const binding = bindingProp\r\n ? bindingProp.isCollection\r\n ? `Collection(${bindingProp.type})`\r\n : bindingProp.type\r\n : DigesterV4.ROOT_OPERATION;\r\n\r\n const name =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getFunctionName(op.$.Name)\r\n : this.namingHelper.getActionName(op.$.Name);\r\n const qName =\r\n type === OperationTypes.Function\r\n ? this.namingHelper.getQFunctionName(op.$.Name, bindingProp)\r\n : this.namingHelper.getQActionName(op.$.Name, bindingProp);\r\n this.dataModel.addOperationType(binding, {\r\n odataName: isBound ? `${namespace}.${op.$.Name}` : op.$.Name,\r\n name,\r\n qName,\r\n paramsModelName: this.namingHelper.getOperationParamsModelName(op.$.Name, bindingProp),\r\n type: type,\r\n parameters: params,\r\n returnType: returnType,\r\n });\r\n });\r\n }\r\n\r\n private getRootOperationType(name: string): OperationType {\r\n const rootOps = this.dataModel.getOperationTypeByBinding(DigesterV4.ROOT_OPERATION);\r\n const rootOp = rootOps.find((op) => op.name === name);\r\n if (!rootOp) {\r\n throw new Error(`Couldn't find root operation with name [${name}]`);\r\n }\r\n return rootOp;\r\n }\r\n}\r\n"]}
@@ -1,9 +1,10 @@
1
1
  import { RunOptions } from "./OptionModel";
2
+ export type DefaultConfiguration = Omit<RunOptions, "sourceUrl" | "source" | "output" | "serviceName">;
2
3
  /**
3
4
  * Creates a defensive copy of the default config.
4
5
  */
5
- export declare function getDefaultConfig(): Omit<RunOptions, "source" | "output">;
6
+ export declare function getDefaultConfig(): DefaultConfiguration;
6
7
  /**
7
8
  * Creates a defensive copy of the minimal config: minimal in respect to naming.
8
9
  */
9
- export declare function getMinimalConfig(): Omit<RunOptions, "source" | "output">;
10
+ export declare function getMinimalConfig(): DefaultConfiguration;
@@ -9,6 +9,8 @@ const OptionModel_1 = require("./OptionModel");
9
9
  * The default configuration.
10
10
  */
11
11
  const defaultConfig = {
12
+ sourceUrlConfig: {},
13
+ refreshFile: false,
12
14
  mode: OptionModel_1.Modes.all,
13
15
  emitMode: OptionModel_1.EmitModes.js_dts,
14
16
  debug: false,
@@ -22,6 +24,7 @@ const defaultConfig = {
22
24
  disableAutoManagedKey: false,
23
25
  allowRenaming: false,
24
26
  v2ModelsWithExtraResultsWrapping: false,
27
+ v4BigNumberAsString: false,
25
28
  naming: {
26
29
  models: {
27
30
  namingStrategy: NamingModel_1.NamingStrategies.PASCAL_CASE,
@@ -1 +1 @@
1
- {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAE7D;;GAEG;AACH,MAAM,aAAa,GAA0C;IAC3D,IAAI,EAAE,mBAAK,CAAC,GAAG;IACf,QAAQ,EAAE,uBAAS,CAAC,MAAM;IAC1B,KAAK,EAAE,KAAK;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,eAAe;IACzB,UAAU,EAAE,EAAE;IACd,kBAAkB,EAAE,KAAK;IACzB,YAAY,EAAE,KAAK;IACnB,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,KAAK;IACnB,qBAAqB,EAAE,KAAK;IAC5B,aAAa,EAAE,KAAK;IACpB,gCAAgC,EAAE,KAAK;IACvC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,cAAc,EAAE,8BAAgB,CAAC,WAAW;YAC5C,kBAAkB,EAAE,8BAAgB,CAAC,UAAU;YAC/C,cAAc,EAAE;gBACd,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,EAAE;gBACV,gBAAgB,EAAE,IA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;QACD,UAAU,EAAE;YACV,kBAAkB,EAAE,IAAI;YACxB,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;YAClC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;SACnC;QACD,YAAY,EAAE;YACZ,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;YACpC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,MAAM;SACrC;QACD,oBAAoB,EAAE;YACpB,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;YAC5C,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,MAAM;SAC7C;KACF;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,mBAAS,EAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAFD,4CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,EAAE,MAAM,KAAqB,aAAa,EAA7B,WAAW,kBAAK,aAAa,EAA1C,UAA0B,CAAgB,CAAC;IACjD,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC;AAHD,4CAGC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: Omit<RunOptions, \"source\" | \"output\"> = {\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n skipComments: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n entitiesByName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): Omit<RunOptions, \"source\" | \"output\"> {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): Omit<RunOptions, \"source\" | \"output\"> {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
1
+ {"version":3,"file":"defaultConfig.js","sourceRoot":"","sources":["../src/defaultConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,+CAA+D;AAC/D,+CAA6D;AAG7D;;GAEG;AACH,MAAM,aAAa,GAAyB;IAC1C,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,KAAK;IAClB,IAAI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C;IACjD,OAAO,IAAA,mBAAS,EAAC,WAAW,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;AACjE,CAAC;AAHD,4CAGC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { NameSettings, NamingStrategies } from \"./NamingModel\";\r\nimport { EmitModes, Modes, RunOptions } from \"./OptionModel\";\r\n\r\nexport type DefaultConfiguration = Omit<RunOptions, \"sourceUrl\" | \"source\" | \"output\" | \"serviceName\">;\r\n/**\r\n * The default configuration.\r\n */\r\nconst defaultConfig: DefaultConfiguration = {\r\n sourceUrlConfig: {},\r\n refreshFile: false,\r\n mode: Modes.all,\r\n emitMode: EmitModes.js_dts,\r\n debug: false,\r\n prettier: false,\r\n tsconfig: \"tsconfig.json\",\r\n converters: [],\r\n skipEditableModels: false,\r\n skipIdModels: false,\r\n skipOperations: false,\r\n skipComments: false,\r\n disableAutoManagedKey: false,\r\n allowRenaming: false,\r\n v2ModelsWithExtraResultsWrapping: false,\r\n v4BigNumberAsString: false,\r\n naming: {\r\n models: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n editableModels: {\r\n prefix: \"Editable\",\r\n suffix: \"\",\r\n applyModelNaming: true,\r\n },\r\n idModels: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n applyModelNaming: true,\r\n },\r\n operationParamModels: {\r\n prefix: \"\",\r\n suffix: \"Params\",\r\n applyModelNaming: true,\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"\",\r\n suffix: \"Model\",\r\n },\r\n },\r\n queryObjects: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n propNamingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n idFunctions: {\r\n prefix: \"\",\r\n suffix: \"Id\",\r\n },\r\n fileName: {\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n prefix: \"Q\",\r\n suffix: \"\",\r\n },\r\n },\r\n services: {\r\n prefix: \"\",\r\n suffix: \"Service\",\r\n namingStrategy: NamingStrategies.PASCAL_CASE,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n prefix: \"\",\r\n suffix: \"Collection\",\r\n applyServiceNaming: true,\r\n },\r\n operations: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n },\r\n relatedServiceGetter: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"\",\r\n suffix: \"\",\r\n },\r\n privateProps: {\r\n namingStrategy: NamingStrategies.CAMEL_CASE,\r\n prefix: \"_\",\r\n suffix: \"\",\r\n },\r\n },\r\n },\r\n propertiesByName: [],\r\n entitiesByName: [],\r\n};\r\n\r\nconst { models, queryObjects, services } = defaultConfig.naming;\r\nconst minimalNamingConfig: NameSettings = {\r\n models: {\r\n fileName: {\r\n prefix: models.fileName.prefix,\r\n suffix: models.fileName.suffix,\r\n },\r\n idModels: {\r\n applyModelNaming: true,\r\n prefix: models.idModels.prefix,\r\n suffix: models.idModels.suffix,\r\n },\r\n editableModels: {\r\n applyModelNaming: true,\r\n prefix: models.editableModels.prefix,\r\n suffix: models.editableModels.suffix,\r\n },\r\n operationParamModels: {\r\n applyModelNaming: true,\r\n prefix: models.operationParamModels.prefix,\r\n suffix: models.operationParamModels.suffix,\r\n },\r\n },\r\n queryObjects: {\r\n prefix: queryObjects.prefix,\r\n suffix: queryObjects.suffix,\r\n fileName: {\r\n prefix: queryObjects.fileName.prefix,\r\n suffix: queryObjects.fileName.suffix,\r\n },\r\n idFunctions: {\r\n prefix: queryObjects.idFunctions.prefix,\r\n suffix: queryObjects.idFunctions.suffix,\r\n },\r\n },\r\n services: {\r\n prefix: services.prefix,\r\n suffix: services.suffix,\r\n main: {\r\n applyServiceNaming: true,\r\n },\r\n collection: {\r\n applyServiceNaming: true,\r\n prefix: services.collection.prefix,\r\n suffix: services.collection.suffix,\r\n },\r\n privateProps: {\r\n prefix: services.privateProps.prefix,\r\n suffix: services.privateProps.suffix,\r\n },\r\n relatedServiceGetter: {\r\n prefix: services.relatedServiceGetter.prefix,\r\n suffix: services.relatedServiceGetter.suffix,\r\n },\r\n },\r\n};\r\n\r\n/**\r\n * Creates a defensive copy of the default config.\r\n */\r\nexport function getDefaultConfig(): DefaultConfiguration {\r\n return deepmerge(defaultConfig, {});\r\n}\r\n\r\n/**\r\n * Creates a defensive copy of the minimal config: minimal in respect to naming.\r\n */\r\nexport function getMinimalConfig(): DefaultConfiguration {\r\n const { naming, ...passThrough } = defaultConfig;\r\n return deepmerge(passThrough, { naming: minimalNamingConfig });\r\n}\r\n"]}
@@ -0,0 +1,12 @@
1
+ import { UrlSourceConfiguration } from "../OptionModel";
2
+ /**
3
+ * Retrieves the metadata from the given URL using the given configuration.
4
+ *
5
+ * Failure handling must be implemented by consumer.
6
+ * Exception is thrown for failed requests (400, 401, ...).
7
+ *
8
+ * @param sourceUrl
9
+ * @param sourceConfig
10
+ * @param debug
11
+ */
12
+ export declare function downloadMetadata(sourceUrl: string, sourceConfig?: UrlSourceConfiguration, debug?: boolean): Promise<string>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.downloadMetadata = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const METADATA_PATH = "$metadata";
7
+ const PWD_BLIND_TEXT = { password: "xxx hidden xxx" };
8
+ function evaluateRequestConfig(url, config) {
9
+ const defaultReqConfig = { url: url, method: "GET" };
10
+ const reqConfig = config.custom
11
+ ? config.custom
12
+ : typeof config.username === "string" && typeof (config === null || config === void 0 ? void 0 : config.password) === "string"
13
+ ? { auth: { username: config.username, password: config.password } }
14
+ : {};
15
+ return Object.assign(Object.assign({}, defaultReqConfig), reqConfig);
16
+ }
17
+ /**
18
+ * Retrieves the metadata from the given URL using the given configuration.
19
+ *
20
+ * Failure handling must be implemented by consumer.
21
+ * Exception is thrown for failed requests (400, 401, ...).
22
+ *
23
+ * @param sourceUrl
24
+ * @param sourceConfig
25
+ * @param debug
26
+ */
27
+ function downloadMetadata(sourceUrl, sourceConfig = {}, debug = false) {
28
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ // add the $metadata suffix
30
+ const url = sourceUrl.endsWith(METADATA_PATH)
31
+ ? sourceUrl
32
+ : sourceUrl + (sourceUrl.endsWith("/") ? "" : "/") + METADATA_PATH;
33
+ console.log(`Reading metadata from URL:`, url);
34
+ // evaluate configured request config options
35
+ const config = evaluateRequestConfig(url, sourceConfig);
36
+ // log request configuration without password
37
+ if (debug) {
38
+ const { auth } = config, loggable = tslib_1.__rest(config, ["auth"]);
39
+ const safeConfig = auth ? Object.assign(Object.assign({}, loggable), { auth: Object.assign(Object.assign({}, auth), (auth.password ? PWD_BLIND_TEXT : {})) }) : loggable;
40
+ console.log(`Request configuration:`, safeConfig);
41
+ }
42
+ // execute the request & return response data
43
+ const response = yield axios_1.default.request(config);
44
+ return response.data;
45
+ });
46
+ }
47
+ exports.downloadMetadata = downloadMetadata;
48
+ //# sourceMappingURL=downloadMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downloadMetadata.js","sourceRoot":"","sources":["../../src/download/downloadMetadata.ts"],"names":[],"mappings":";;;;AAAA,0DAAkD;AAIlD,MAAM,aAAa,GAAG,WAAW,CAAC;AAClC,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAEtD,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAA8B;IACxE,MAAM,gBAAgB,GAAuB,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACzE,MAAM,SAAS,GAAuB,MAAM,CAAC,MAAM;QACjD,CAAC,CAAC,MAAM,CAAC,MAAM;QACf,CAAC,CAAC,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO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C,MAAM,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA;AAxBD,4CAwBC","sourcesContent":["import axios, { AxiosRequestConfig } from \"axios\";\r\n\r\nimport { UrlSourceConfiguration } from \"../OptionModel\";\r\n\r\nconst METADATA_PATH = \"$metadata\";\r\nconst PWD_BLIND_TEXT = { password: \"xxx hidden xxx\" };\r\n\r\nfunction evaluateRequestConfig(url: string, config: UrlSourceConfiguration): AxiosRequestConfig {\r\n const defaultReqConfig: AxiosRequestConfig = { url: url, method: \"GET\" };\r\n const reqConfig: AxiosRequestConfig = config.custom\r\n ? config.custom\r\n : typeof config.username === \"string\" && typeof config?.password === \"string\"\r\n ? { auth: { username: config.username, password: config.password } }\r\n : {};\r\n return { ...defaultReqConfig, ...reqConfig };\r\n}\r\n\r\n/**\r\n * Retrieves the metadata from the given URL using the given configuration.\r\n *\r\n * Failure handling must be implemented by consumer.\r\n * Exception is thrown for failed requests (400, 401, ...).\r\n *\r\n * @param sourceUrl\r\n * @param sourceConfig\r\n * @param debug\r\n */\r\nexport async function downloadMetadata(\r\n sourceUrl: string,\r\n sourceConfig: UrlSourceConfiguration = {},\r\n debug: boolean = false\r\n): Promise<string> {\r\n // add the $metadata suffix\r\n const url = sourceUrl.endsWith(METADATA_PATH)\r\n ? sourceUrl\r\n : sourceUrl + (sourceUrl.endsWith(\"/\") ? \"\" : \"/\") + METADATA_PATH;\r\n console.log(`Reading metadata from URL:`, url);\r\n\r\n // evaluate configured request config options\r\n const config = evaluateRequestConfig(url, sourceConfig);\r\n\r\n // log request configuration without password\r\n if (debug) {\r\n const { auth, ...loggable } = config;\r\n const safeConfig = auth ? { ...loggable, auth: { ...auth, ...(auth.password ? PWD_BLIND_TEXT : {}) } } : loggable;\r\n console.log(`Request configuration:`, safeConfig);\r\n }\r\n\r\n // execute the request & return response data\r\n const response = await axios.request(config);\r\n return response.data;\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ export { downloadMetadata } from "./downloadMetadata";
2
+ export { storeMetadata } from "./storeMetadata";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storeMetadata = exports.downloadMetadata = void 0;
4
+ var downloadMetadata_1 = require("./downloadMetadata");
5
+ Object.defineProperty(exports, "downloadMetadata", { enumerable: true, get: function () { return downloadMetadata_1.downloadMetadata; } });
6
+ var storeMetadata_1 = require("./storeMetadata");
7
+ Object.defineProperty(exports, "storeMetadata", { enumerable: true, get: function () { return storeMetadata_1.storeMetadata; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/download/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA","sourcesContent":["export { downloadMetadata } from \"./downloadMetadata\";\r\nexport { storeMetadata } from \"./storeMetadata\";\r\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Write (prettified) data to disk.
3
+ *
4
+ * @param filePath
5
+ * @param metadataXml
6
+ * @param prettify
7
+ */
8
+ export declare function storeMetadata(filePath: string, metadataXml: string, prettify: boolean): Promise<string>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storeMetadata = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const fs_extra_1 = require("fs-extra");
7
+ const prettier_1 = tslib_1.__importDefault(require("prettier"));
8
+ /**
9
+ * Write (prettified) data to disk.
10
+ *
11
+ * @param filePath
12
+ * @param metadataXml
13
+ * @param prettify
14
+ */
15
+ function storeMetadata(filePath, metadataXml, prettify) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const outDir = path_1.default.dirname(filePath);
18
+ const prettierConfig = yield prettier_1.default.resolveConfig(outDir);
19
+ const prettified = prettify
20
+ ? prettier_1.default.format(metadataXml, Object.assign(Object.assign({ xmlWhitespaceSensitivity: "ignore" }, prettierConfig), { parser: "xml", plugins: ["@prettier/plugin-xml"] }))
21
+ : metadataXml;
22
+ yield (0, fs_extra_1.ensureDir)(outDir);
23
+ yield (0, fs_extra_1.writeFile)(filePath, prettified);
24
+ return prettified;
25
+ });
26
+ }
27
+ exports.storeMetadata = storeMetadata;
28
+ //# sourceMappingURL=storeMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storeMetadata.js","sourceRoot":"","sources":["../../src/download/storeMetadata.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB,uCAAgD;AAChD,gEAAgC;AAEhC;;;;;;GAMG;AACH,SAAsB,aAAa,CAAC,QAAgB,EAAE,WAAmB,EAAE,QAAiB;;QAC1F,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEtC,MAAM,cAAc,GAAG,MAAM,kBAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,QAAQ;YACzB,CAAC,CAAC,kBAAQ,CAAC,MAAM,CACb,WAAW,gCAET,wBAAwB,EAAE,QAAQ,IAAK,cAAc,KAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,sBAAsB,CAAC,IAC1G;YACH,CAAC,CAAC,WAAW,CAAC;QAEhB,MAAM,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC;QACxB,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAEtC,OAAO,UAAU,CAAC;IACpB,CAAC;CAAA;AAhBD,sCAgBC","sourcesContent":["import path from \"path\";\r\n\r\nimport { ensureDir, writeFile } from \"fs-extra\";\r\nimport prettier from \"prettier\";\r\n\r\n/**\r\n * Write (prettified) data to disk.\r\n *\r\n * @param filePath\r\n * @param metadataXml\r\n * @param prettify\r\n */\r\nexport async function storeMetadata(filePath: string, metadataXml: string, prettify: boolean) {\r\n const outDir = path.dirname(filePath);\r\n\r\n const prettierConfig = await prettier.resolveConfig(outDir);\r\n const prettified = prettify\r\n ? prettier.format(\r\n metadataXml,\r\n // @ts-ignore: xmlWhitespaceSensitivity is an option of the plugin\r\n { xmlWhitespaceSensitivity: \"ignore\", ...prettierConfig, parser: \"xml\", plugins: [\"@prettier/plugin-xml\"] }\r\n )\r\n : metadataXml;\r\n\r\n await ensureDir(outDir);\r\n await writeFile(filePath, prettified);\r\n\r\n return prettified;\r\n}\r\n"]}
@@ -57,7 +57,7 @@ function evaluateConfigOptions(cliOpts, configOpts) {
57
57
  if (!service) {
58
58
  throw new Error(`Specified service "${s}" doesn't exist in configuration!`);
59
59
  }
60
- const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts === null || configOpts === void 0 ? void 0 : configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : defaultConfig;
60
+ const serviceDefault = ((_a = service.naming) === null || _a === void 0 ? void 0 : _a.minimalDefaults) && !((_b = configOpts.naming) === null || _b === void 0 ? void 0 : _b.minimalDefaults) ? (0, defaultConfig_1.getMinimalConfig)() : defaultConfig;
61
61
  const merged = deepmerge_1.default.all([serviceDefault, confBaseOpts, service, cliBaseOpts]);
62
62
  return safeGuardOptions(merged);
63
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"evaluateConfig.js","sourceRoot":"","sources":["../src/evaluateConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,mDAAqE;AACrE,+CAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,qBAAqB,CACnC,OAAmB,EACnB,UAAyC;;IAEzC,MAAM,aAAa,GAAG,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,eAAe,EAAC,CAAC,CAAC,IAAA,gCAAgB,GAAE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AK,CAAC,sBAAsB,CAAC,mCAAmC,CAAC,CAAC;SAC7E;QACD,MAAM,cAAc,GAClB,CAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,eAAe,KAAI,CAAC,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,eAAe,CAAA,CAAC,CAAC,CAAC,IAAA,gCAAgB,GAAE,CAAC,CAAC,CAAC,aAAa,CAAC;QAC/G,MAAM,MAAM,GAAG,mBAAS,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC,CAAe,CAAC;QACjG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC;AAxCD,sDAwCC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,OAAmB;IAC3C,oDAAoD;IACpD,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,GAAG,EAAE;QAChE,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC7B,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC;KAChC;IACD,0DAA0D;IAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,MAAM,EAAE;QACjC,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC;KAClD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { getDefaultConfig, getMinimalConfig } from \"./defaultConfig\";\r\nimport { CliOptions, ConfigFileOptions, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * Provides default values and evaluates the various config file and CLI options.\r\n * This function always returns a list of RunOptions,\r\n * whereby each item represents one generation run / one service.\r\n *\r\n * Configurations are merged in the following order (last one wins):\r\n * - default values\r\n * - config file: base settings\r\n * - config file: service specific settings\r\n * - CLI options\r\n *\r\n * If the CLI options specify source and output, then the service config is completely ignored and only the\r\n * base settings are applied from the config file.\r\n *\r\n * If the CLI options do not specify source and output, but do specify services, then these services must\r\n * exist in the config file and each service must supply values for source and output as a minimum.\r\n *\r\n * If the CLI options neither entail source nor services, then at least one service must be configured in the\r\n * config file. All configured services are returned.\r\n *\r\n * @param cliOpts CLI passed options\r\n * @param configOpts config file options\r\n */\r\nexport function evaluateConfigOptions(\r\n cliOpts: CliOptions,\r\n configOpts: ConfigFileOptions | undefined\r\n): Array<RunOptions> {\r\n const defaultConfig = configOpts?.naming?.minimalDefaults ? getMinimalConfig() : getDefaultConfig();\r\n // No config file\r\n if (!configOpts) {\r\n if (!cliOpts.source || !cliOpts.output) {\r\n throw new Error(\"Without any configuration file options --source and --output must be specified!\");\r\n }\r\n return [deepmerge(defaultConfig, cliOpts)];\r\n }\r\n\r\n const { services: cliServices, source, output, ...cliBaseOpts } = cliOpts;\r\n const { services: confServices, ...confBaseOpts } = configOpts;\r\n\r\n // No configurations of services in config file\r\n // or CLI opts specify source and output => ignore service config\r\n if ((source && output) || !confServices) {\r\n if (!source || !output) {\r\n throw new Error(\r\n \"No services were configured in config file, so options --source and --output must be specified!\"\r\n );\r\n }\r\n const merged = deepmerge.all([defaultConfig, confBaseOpts, cliOpts]) as RunOptions;\r\n return [safeGuardOptions(merged)];\r\n }\r\n\r\n // Either services are specified or we use all configured services\r\n const servicesToUse = cliServices?.length ? cliServices : Object.keys(confServices);\r\n return servicesToUse.map((s) => {\r\n const service = confServices[s];\r\n if (!service) {\r\n throw new Error(`Specified service \"${s}\" doesn't exist in configuration!`);\r\n }\r\n const serviceDefault =\r\n service.naming?.minimalDefaults && !configOpts?.naming?.minimalDefaults ? getMinimalConfig() : defaultConfig;\r\n const merged = deepmerge.all([serviceDefault, confBaseOpts, service, cliBaseOpts]) as RunOptions;\r\n return safeGuardOptions(merged);\r\n });\r\n}\r\n\r\n/**\r\n * Make sure that some options are only active if in correct mode.\r\n * @param options\r\n */\r\nfunction safeGuardOptions(options: RunOptions): RunOptions {\r\n // skip options are not valid for service generation\r\n if (options.mode === Modes.service || options.mode === Modes.all) {\r\n options.skipEditableModels = false;\r\n options.skipIdModels = false;\r\n options.skipOperations = false;\r\n }\r\n // special option which is only valid for model generation\r\n if (options.mode !== Modes.models) {\r\n options.v2ModelsWithExtraResultsWrapping = false;\r\n }\r\n\r\n return options;\r\n}\r\n"]}
1
+ {"version":3,"file":"evaluateConfig.js","sourceRoot":"","sources":["../src/evaluateConfig.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,mDAAqE;AACrE,+CAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,qBAAqB,CACnC,OAAmB,EACnB,UAAyC;;IAEzC,MAAM,aAAa,GAAG,CAAA,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,0CAAE,eAAe,EAAC,CAAC,CAAC,IAAA,gCAAgB,GAAE,CAAC,CAAC,CAAC,IAAA,gCAAgB,GAAE,CAAC;IACpG,iBAAiB;IACjB,IAAI,CAAC,UAAU,EAAE;QACf,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;SACpG;QACD,OAAO,CAAC,IAAA,mBAAS,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;KAC5C;IAED,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,KAAqB,OAAO,EAAvB,WAAW,kBAAK,OAAO,EAAnE,gCAAyD,CAAU,CAAC;IAC1E,MAAM,EAAE,QAAQ,EAAE,YAAY,KAAsB,UAAU,EAA3B,YAAY,kBAAK,UAAU,EAAxD,YAA2C,CAAa,CAAC;IAE/D,+CAA+C;IAC/C,iEAAiE;IACjE,IAAI,CAAC,MAAM,IAAI,MAAM,CAA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KAAK,mBAAK,CAAC,GAAG,EAAE;QAChE,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC7B,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC;KAChC;IACD,0DAA0D;IAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAK,CAAC,MAAM,EAAE;QACjC,OAAO,CAAC,gCAAgC,GAAG,KAAK,CAAC;KAClD;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import deepmerge from \"deepmerge\";\r\n\r\nimport { getDefaultConfig, getMinimalConfig } from \"./defaultConfig\";\r\nimport { CliOptions, ConfigFileOptions, Modes, RunOptions } from \"./OptionModel\";\r\n\r\n/**\r\n * Provides default values and evaluates the various config file and CLI options.\r\n * This function always returns a list of RunOptions,\r\n * whereby each item represents one generation run / one service.\r\n *\r\n * Configurations are merged in the following order (last one wins):\r\n * - default values\r\n * - config file: base settings\r\n * - config file: service specific settings\r\n * - CLI options\r\n *\r\n * If the CLI options specify source and output, then the service config is completely ignored and only the\r\n * base settings are applied from the config file.\r\n *\r\n * If the CLI options do not specify source and output, but do specify services, then these services must\r\n * exist in the config file and each service must supply values for source and output as a minimum.\r\n *\r\n * If the CLI options neither entail source nor services, then at least one service must be configured in the\r\n * config file. All configured services are returned.\r\n *\r\n * @param cliOpts CLI passed options\r\n * @param configOpts config file options\r\n */\r\nexport function evaluateConfigOptions(\r\n cliOpts: CliOptions,\r\n configOpts: ConfigFileOptions | undefined\r\n): Array<RunOptions> {\r\n const defaultConfig = configOpts?.naming?.minimalDefaults ? getMinimalConfig() : getDefaultConfig();\r\n // No config file\r\n if (!configOpts) {\r\n if (!cliOpts.source || !cliOpts.output) {\r\n throw new Error(\"Without any configuration file options --source and --output must be specified!\");\r\n }\r\n return [deepmerge(defaultConfig, cliOpts)];\r\n }\r\n\r\n const { services: cliServices, source, output, ...cliBaseOpts } = cliOpts;\r\n const { services: confServices, ...confBaseOpts } = configOpts;\r\n\r\n // No configurations of services in config file\r\n // or CLI opts specify source and output => ignore service config\r\n if ((source && output) || !confServices) {\r\n if (!source || !output) {\r\n throw new Error(\r\n \"No services were configured in config file, so options --source and --output must be specified!\"\r\n );\r\n }\r\n const merged = deepmerge.all([defaultConfig, confBaseOpts, cliOpts]) as RunOptions;\r\n return [safeGuardOptions(merged)];\r\n }\r\n\r\n // Either services are specified or we use all configured services\r\n const servicesToUse = cliServices?.length ? cliServices : Object.keys(confServices);\r\n return servicesToUse.map((s) => {\r\n const service = confServices[s];\r\n if (!service) {\r\n throw new Error(`Specified service \"${s}\" doesn't exist in configuration!`);\r\n }\r\n const serviceDefault =\r\n service.naming?.minimalDefaults && !configOpts.naming?.minimalDefaults ? getMinimalConfig() : defaultConfig;\r\n const merged = deepmerge.all([serviceDefault, confBaseOpts, service, cliBaseOpts]) as RunOptions;\r\n return safeGuardOptions(merged);\r\n });\r\n}\r\n\r\n/**\r\n * Make sure that some options are only active if in correct mode.\r\n * @param options\r\n */\r\nfunction safeGuardOptions(options: RunOptions): RunOptions {\r\n // skip options are not valid for service generation\r\n if (options.mode === Modes.service || options.mode === Modes.all) {\r\n options.skipEditableModels = false;\r\n options.skipIdModels = false;\r\n options.skipOperations = false;\r\n }\r\n // special option which is only valid for model generation\r\n if (options.mode !== Modes.models) {\r\n options.v2ModelsWithExtraResultsWrapping = false;\r\n }\r\n\r\n return options;\r\n}\r\n"]}
@@ -5,4 +5,4 @@ import { NamingHelper } from "../data-model/NamingHelper";
5
5
  import { ProjectManager } from "../project/ProjectManager";
6
6
  export interface PropsAndOps extends Required<Pick<ClassDeclarationStructure, "properties" | "methods">> {
7
7
  }
8
- export declare function generateServices(dataModel: DataModel, project: ProjectManager, version: ODataVersions, namingHelper: NamingHelper): Promise<void>;
8
+ export declare function generateServices(dataModel: DataModel, project: ProjectManager, version: ODataVersions, namingHelper: NamingHelper, v4BigNumberAsString?: boolean): Promise<void>;
@@ -14,19 +14,20 @@ const RESPONSE_TYPES = {
14
14
  model: "ODataModelResponse",
15
15
  value: "ODataValueResponse",
16
16
  };
17
- function generateServices(dataModel, project, version, namingHelper) {
17
+ function generateServices(dataModel, project, version, namingHelper, v4BigNumberAsString = false) {
18
18
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
- const generator = new ServiceGenerator(dataModel, project, version, namingHelper);
19
+ const generator = new ServiceGenerator(dataModel, project, version, namingHelper, v4BigNumberAsString);
20
20
  return generator.generate();
21
21
  });
22
22
  }
23
23
  exports.generateServices = generateServices;
24
24
  class ServiceGenerator {
25
- constructor(dataModel, project, version, namingHelper) {
25
+ constructor(dataModel, project, version, namingHelper, v4BigNumberAsString) {
26
26
  this.dataModel = dataModel;
27
27
  this.project = project;
28
28
  this.version = version;
29
29
  this.namingHelper = namingHelper;
30
+ this.v4BigNumberAsString = v4BigNumberAsString;
30
31
  this.generateQOperationProp = (operation) => {
31
32
  return {
32
33
  scope: ts_morph_1.Scope.Private,
@@ -36,6 +37,9 @@ class ServiceGenerator {
36
37
  };
37
38
  };
38
39
  }
40
+ isV4BigNumber() {
41
+ return this.v4BigNumberAsString && this.version === odata_core_1.ODataVersions.V4;
42
+ }
39
43
  generate() {
40
44
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
45
  const sourceFile = yield this.project.createMainServiceFile();
@@ -52,14 +56,18 @@ class ServiceGenerator {
52
56
  name: serviceName,
53
57
  typeParameters: ["ClientType extends ODataHttpClient"],
54
58
  extends: `${ROOT_SERVICE}<ClientType>`,
55
- properties /*: [
56
- {
57
- scope: Scope.Private,
58
- name: this.namingHelper.getPrivatePropName("name"),
59
- type: "string",
60
- initializer: `"${this.namingHelper.getODataServiceName()}"`,
61
- },
62
- ]*/,
59
+ ctors: this.isV4BigNumber()
60
+ ? [
61
+ {
62
+ parameters: [
63
+ { name: "client", type: "ClientType" },
64
+ { name: "basePath", type: "string" },
65
+ ],
66
+ statements: [`super(client, basePath, true);`],
67
+ },
68
+ ]
69
+ : [],
70
+ properties,
63
71
  methods,
64
72
  });
65
73
  sourceFile.addImportDeclarations(importContainer.getImportDeclarations(false));
@@ -184,7 +192,7 @@ class ServiceGenerator {
184
192
  { name: "basePath", type: "string" },
185
193
  { name: "name", type: "string" },
186
194
  ],
187
- statements: [`super(client, basePath, name, ${qObjectName});`],
195
+ statements: [`super(client, basePath, name, ${qObjectName}${this.isV4BigNumber() ? ", true" : ""});`],
188
196
  },
189
197
  ],
190
198
  properties,
@@ -251,7 +259,7 @@ class ServiceGenerator {
251
259
  generatePrimitiveCollectionProp(prop, collectionServiceType, importContainer) {
252
260
  const isEnum = prop.dataType === "EnumType" /* DataTypes.EnumType */;
253
261
  const type = isEnum ? `EnumCollection<${prop.type}>` : `${(0, upper_case_first_1.upperCaseFirst)(prop.type)}Collection`;
254
- const qType = isEnum ? "QEnumCollection" : `Q${type}`;
262
+ const qType = isEnum ? "QEnumCollection" : prop.qObject;
255
263
  const collectionType = `${collectionServiceType}<ClientType, ${type}, ${qType}>`;
256
264
  if (!prop.qObject) {
257
265
  throw new Error("Illegal State: [qObject] must be provided for Collection types!");
@@ -305,7 +313,7 @@ class ServiceGenerator {
305
313
  statements: [
306
314
  `if(!${propName}) {`,
307
315
  // prettier-ignore
308
- ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), "${prop.odataName}", ${(0, processors_1.firstCharLowerCase)(prop.qObject)})`,
316
+ ` ${propName} = new ${collectionServiceType}(this.client, this.getPath(), "${prop.odataName}", ${(0, processors_1.firstCharLowerCase)(prop.qObject)}${this.isV4BigNumber() ? ", true" : ""})`,
309
317
  "}",
310
318
  `return ${propName}`,
311
319
  ],
@@ -334,7 +342,9 @@ class ServiceGenerator {
334
342
  { name: "basePath", type: "string" },
335
343
  { name: "name", type: "string" },
336
344
  ],
337
- statements: [`super(client, basePath, name, ${qObjectName}, new ${model.qIdFunctionName}(name));`],
345
+ statements: [
346
+ `super(client, basePath, name, ${qObjectName}, new ${model.qIdFunctionName}(name)${this.isV4BigNumber() ? ", true" : ""});`,
347
+ ],
338
348
  },
339
349
  ],
340
350
  properties,