Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure-tools/rlc-common

Package Overview
Dependencies
Maintainers
1
Versions
385
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure-tools/rlc-common - npm Package Compare versions

Comparing version 1.0.0-alpha.2.20221107.1 to 1.0.0-alpha.2.20221108.1

4

.rush/temp/package-deps_build.json

@@ -14,5 +14,5 @@ {

"packages/rlc-common/src/buildMethodShortcuts.ts": "5a4f96895b17402b9570c2600b227421035db052",
"packages/rlc-common/src/buildObjectTypes.ts": "1fa988b1adc981eab3d3642e6f38c674989a2f3f",
"packages/rlc-common/src/buildObjectTypes.ts": "d29bd69a8cc55b835c56839ab581e0b1ba5183ce",
"packages/rlc-common/src/buildPaginateHelper.ts": "bfa91271cfd4c5411331db01d667cd82f0096e2b",
"packages/rlc-common/src/buildParameterTypes.ts": "dfdca1b5322aa2acdb03d9d5e7021af143fa0a34",
"packages/rlc-common/src/buildParameterTypes.ts": "16fc6f0c0837889436af0e64429e26e5ab32b2dc",
"packages/rlc-common/src/buildPollingHelper.ts": "1aeeef5b9cc4f9098632b7fb79ba01aa5e686d43",

@@ -19,0 +19,0 @@ "packages/rlc-common/src/buildResponseTypes.ts": "e6cfeb8281e55b7280ac2ff004965faa583b5096",

@@ -221,3 +221,7 @@ // Copyright (c) Microsoft Corporation.

function getPropertySignatures(properties, schemaUsage, importedModels) {
return Object.keys(properties).map((p) => getPropertySignature({ ...properties[p], name: p }, schemaUsage, importedModels));
let validProperties = Object.keys(properties);
if (schemaUsage.includes(SchemaContext.Input)) {
validProperties = validProperties.filter((p) => { return !properties[p].readOnly; });
}
return validProperties.map((p) => getPropertySignature({ ...properties[p], name: p }, schemaUsage, importedModels));
}

@@ -233,7 +237,3 @@ /**

const description = property.description;
const type = ((schemaUsage.includes(SchemaContext.Output) &&
property.usage?.includes(SchemaContext.Output)) ||
(schemaUsage.includes(SchemaContext.Exception) &&
property.usage?.includes(SchemaContext.Exception))) &&
property.outputTypeName
const type = generateForOutput(schemaUsage, property.usage) && property.outputTypeName
? property.outputTypeName

@@ -247,2 +247,3 @@ : property.typeName

hasQuestionToken: !property.required,
isReadonly: generateForOutput(schemaUsage, property.usage) && property.readOnly,
type,

@@ -252,2 +253,8 @@ kind: StructureKind.PropertySignature

}
function generateForOutput(schemaUsage, propertyUsage) {
return ((schemaUsage.includes(SchemaContext.Output) &&
propertyUsage?.includes(SchemaContext.Output)) ||
(schemaUsage.includes(SchemaContext.Exception) &&
propertyUsage?.includes(SchemaContext.Exception)));
}
//# sourceMappingURL=buildObjectTypes.js.map

@@ -39,2 +39,6 @@ // Copyright (c) Microsoft Corporation.

const bodyParameterDefinition = buildBodyParametersDefinition(parameter, baseParameterName, internalReferences, i);
const bodyTypeAlias = buildBodyTypeAlias(parameter);
if (bodyTypeAlias) {
parametersFile.addTypeAlias(bodyTypeAlias);
}
// Add interfaces for body and query parameters

@@ -292,2 +296,42 @@ parametersFile.addInterfaces([

}
export function buildBodyTypeAlias(parameters) {
const bodyParameters = parameters.body;
if (!bodyParameters ||
!bodyParameters?.body ||
!bodyParameters?.body.length) {
return undefined;
}
const schema = bodyParameters.body[0];
const headerParameters = (parameters.parameters || []).filter((p) => p.type === "header" && p.name === "contentType");
if (!headerParameters.length || headerParameters.length > 1) {
return undefined;
}
const contentType = headerParameters[0].param.type;
const readOnlyProperties = [];
if (schema.properties) {
for (const propertyName of Object.keys(schema.properties)) {
const prop = schema.properties[propertyName];
if (prop?.readOnly) {
if (propertyName.startsWith('"') && propertyName.endsWith('"')) {
readOnlyProperties.push(`${propertyName}`);
}
else {
readOnlyProperties.push(`"${propertyName}"`);
}
}
}
}
const description = `${schema.description}`;
const typeName = `${schema.typeName}ResourceMergeAndPatch`;
if (contentType.includes("application/merge-patch+json")) {
const type = `Partial<${schema.typeName}>`;
return {
// kind: StructureKind.TypeAlias,
...(description && { docs: [{ description }] }),
name: `${typeName}`,
type,
isExported: true
};
}
}
//# sourceMappingURL=buildParameterTypes.js.map

@@ -226,3 +226,7 @@ "use strict";

function getPropertySignatures(properties, schemaUsage, importedModels) {
return Object.keys(properties).map((p) => getPropertySignature(Object.assign(Object.assign({}, properties[p]), { name: p }), schemaUsage, importedModels));
let validProperties = Object.keys(properties);
if (schemaUsage.includes(interfaces_js_1.SchemaContext.Input)) {
validProperties = validProperties.filter((p) => { return !properties[p].readOnly; });
}
return validProperties.map((p) => getPropertySignature(Object.assign(Object.assign({}, properties[p]), { name: p }), schemaUsage, importedModels));
}

@@ -236,10 +240,5 @@ /**

function getPropertySignature(property, schemaUsage, importedModels = new Set()) {
var _a, _b;
const propertyName = property.name;
const description = property.description;
const type = ((schemaUsage.includes(interfaces_js_1.SchemaContext.Output) &&
((_a = property.usage) === null || _a === void 0 ? void 0 : _a.includes(interfaces_js_1.SchemaContext.Output))) ||
(schemaUsage.includes(interfaces_js_1.SchemaContext.Exception) &&
((_b = property.usage) === null || _b === void 0 ? void 0 : _b.includes(interfaces_js_1.SchemaContext.Exception)))) &&
property.outputTypeName
const type = generateForOutput(schemaUsage, property.usage) && property.outputTypeName
? property.outputTypeName

@@ -249,5 +248,11 @@ : property.typeName

: property.type;
return Object.assign(Object.assign({ name: propertyName }, (description && { docs: [{ description }] })), { hasQuestionToken: !property.required, type, kind: ts_morph_1.StructureKind.PropertySignature });
return Object.assign(Object.assign({ name: propertyName }, (description && { docs: [{ description }] })), { hasQuestionToken: !property.required, isReadonly: generateForOutput(schemaUsage, property.usage) && property.readOnly, type, kind: ts_morph_1.StructureKind.PropertySignature });
}
exports.getPropertySignature = getPropertySignature;
function generateForOutput(schemaUsage, propertyUsage) {
return ((schemaUsage.includes(interfaces_js_1.SchemaContext.Output) &&
(propertyUsage === null || propertyUsage === void 0 ? void 0 : propertyUsage.includes(interfaces_js_1.SchemaContext.Output))) ||
(schemaUsage.includes(interfaces_js_1.SchemaContext.Exception) &&
(propertyUsage === null || propertyUsage === void 0 ? void 0 : propertyUsage.includes(interfaces_js_1.SchemaContext.Exception))));
}
//# sourceMappingURL=buildObjectTypes.js.map

@@ -5,3 +5,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildParameterTypes = void 0;
exports.buildBodyTypeAlias = exports.buildParameterTypes = void 0;
const ts_morph_1 = require("ts-morph");

@@ -44,2 +44,6 @@ const path = require("path");

const bodyParameterDefinition = buildBodyParametersDefinition(parameter, baseParameterName, internalReferences, i);
const bodyTypeAlias = buildBodyTypeAlias(parameter);
if (bodyTypeAlias) {
parametersFile.addTypeAlias(bodyTypeAlias);
}
// Add interfaces for body and query parameters

@@ -292,2 +296,37 @@ parametersFile.addInterfaces([

}
function buildBodyTypeAlias(parameters) {
const bodyParameters = parameters.body;
if (!bodyParameters ||
!(bodyParameters === null || bodyParameters === void 0 ? void 0 : bodyParameters.body) ||
!(bodyParameters === null || bodyParameters === void 0 ? void 0 : bodyParameters.body.length)) {
return undefined;
}
const schema = bodyParameters.body[0];
const headerParameters = (parameters.parameters || []).filter((p) => p.type === "header" && p.name === "contentType");
if (!headerParameters.length || headerParameters.length > 1) {
return undefined;
}
const contentType = headerParameters[0].param.type;
const readOnlyProperties = [];
if (schema.properties) {
for (const propertyName of Object.keys(schema.properties)) {
const prop = schema.properties[propertyName];
if (prop === null || prop === void 0 ? void 0 : prop.readOnly) {
if (propertyName.startsWith('"') && propertyName.endsWith('"')) {
readOnlyProperties.push(`${propertyName}`);
}
else {
readOnlyProperties.push(`"${propertyName}"`);
}
}
}
}
const description = `${schema.description}`;
const typeName = `${schema.typeName}ResourceMergeAndPatch`;
if (contentType.includes("application/merge-patch+json")) {
const type = `Partial<${schema.typeName}>`;
return Object.assign(Object.assign({}, (description && { docs: [{ description }] })), { name: `${typeName}`, type, isExported: true });
}
}
exports.buildBodyTypeAlias = buildBodyTypeAlias;
//# sourceMappingURL=buildParameterTypes.js.map
{
"name": "@azure-tools/rlc-common",
"version": "1.0.0-alpha.2.20221107.1",
"version": "1.0.0-alpha.2.20221108.1",
"description": "",

@@ -5,0 +5,0 @@ "type": "module",

@@ -126,3 +126,3 @@ // Copyright (c) Microsoft Corporation.

const description = objectSchema.description;
return {

@@ -354,3 +354,7 @@ kind: StructureKind.TypeAlias,

) {
return Object.keys(properties).map((p) =>
let validProperties = Object.keys(properties)
if (schemaUsage.includes(SchemaContext.Input)) {
validProperties = validProperties.filter((p) => { return !properties[p].readOnly})
}
return validProperties.map((p) =>
getPropertySignature(

@@ -379,7 +383,3 @@ { ...properties[p], name: p },

const type =
((schemaUsage.includes(SchemaContext.Output) &&
property.usage?.includes(SchemaContext.Output)) ||
(schemaUsage.includes(SchemaContext.Exception) &&
property.usage?.includes(SchemaContext.Exception))) &&
property.outputTypeName
generateForOutput(schemaUsage, property.usage) && property.outputTypeName
? property.outputTypeName

@@ -393,2 +393,3 @@ : property.typeName

hasQuestionToken: !property.required,
isReadonly: generateForOutput(schemaUsage, property.usage) && property.readOnly,
type,

@@ -398,1 +399,13 @@ kind: StructureKind.PropertySignature

}
function generateForOutput(
schemaUsage: SchemaContext[],
propertyUsage?: SchemaContext[]
) {
return (
(schemaUsage.includes(SchemaContext.Output) &&
propertyUsage?.includes(SchemaContext.Output)) ||
(schemaUsage.includes(SchemaContext.Exception) &&
propertyUsage?.includes(SchemaContext.Exception))
);
}

@@ -14,2 +14,3 @@ // Copyright (c) Microsoft Corporation.

ImportKind,
ObjectSchema,
ParameterMetadata,

@@ -96,2 +97,7 @@ ParameterMetadatas,

const bodyTypeAlias = buildBodyTypeAlias(parameter);
if (bodyTypeAlias) {
parametersFile.addTypeAlias(bodyTypeAlias);
}
// Add interfaces for body and query parameters

@@ -443,1 +449,48 @@ parametersFile.addInterfaces([

}
export function buildBodyTypeAlias(parameters: ParameterMetadatas) {
const bodyParameters = parameters.body;
if (
!bodyParameters ||
!bodyParameters?.body ||
!bodyParameters?.body.length
) {
return undefined;
}
const schema = bodyParameters.body[0] as ObjectSchema;
const headerParameters = (parameters.parameters || []).filter(
(p) => p.type === "header" && p.name === "contentType"
);
if (!headerParameters.length || headerParameters.length > 1) {
return undefined;
}
const contentType = headerParameters[0].param.type;
const readOnlyProperties = [];
if (schema.properties) {
for(const propertyName of Object.keys(schema.properties)) {
const prop = schema.properties[propertyName];
if (prop?.readOnly) {
if (propertyName.startsWith('"') && propertyName.endsWith('"')) {
readOnlyProperties.push(`${propertyName}`)
} else {
readOnlyProperties.push(`"${propertyName}"`);
}
}
}
}
const description = `${schema.description}`;
const typeName = `${schema.typeName}ResourceMergeAndPatch`
if (contentType.includes("application/merge-patch+json")) {
const type = `Partial<${schema.typeName}>`;
return {
// kind: StructureKind.TypeAlias,
...(description && { docs: [{ description }] }),
name: `${typeName}`,
type,
isExported: true
};
}
}

@@ -1,2 +0,2 @@

import { RLCModel } from "./interfaces.js";
import { ParameterMetadatas, RLCModel } from "./interfaces.js";
export declare function buildParameterTypes(model: RLCModel): {

@@ -6,1 +6,9 @@ path: string;

} | undefined;
export declare function buildBodyTypeAlias(parameters: ParameterMetadatas): {
name: string;
type: string;
isExported: boolean;
docs?: {
description: string;
}[] | undefined;
} | undefined;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc