{"library":"ms-rest","title":"Azure ms-rest Client Runtime","description":"ms-rest is a foundational client runtime for Node.js client libraries generated using AutoRest, specifically designed for interacting with Azure services. It provides core infrastructure for serialization, deserialization, error handling, tracing, and configuring HTTP client pipelines. The current stable version is 2.5.6, with its last publish in May 2022. While it was a cornerstone of the older Azure SDK for Node.js, this package and its containing repository (`azure-sdk-for-node`) are now officially deprecated. Newer Azure SDKs (`@azure/*`) leverage more modular core packages like `@azure/core-http` and `@azure/core-rest-pipeline` for improved performance and maintainability. ms-rest ships with built-in TypeScript type definitions and adheres to Microsoft REST API Guidelines for consistent API design and error handling, differentiating it by its specific use within the Azure ecosystem for AutoRest-generated clients.","language":"javascript","status":"deprecated","last_verified":"Tue Apr 21","install":{"commands":["npm install ms-rest"],"cli":null},"imports":["import { serialize } from 'ms-rest';","import { deserialize } from 'ms-rest';","import { ServiceClient } from 'ms-rest';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { serialize, deserialize } from 'ms-rest';\n\ninterface Product {\n  id: number;\n  name: string;\n  price?: number;\n}\n\nconst productMapper = {\n  type: {\n    name: 'Composite',\n    className: 'Product',\n    modelProperties: {\n      id: {\n        required: true,\n        serializedName: 'id',\n        type: { name: 'Number' }\n      },\n      name: {\n        required: true,\n        serializedName: 'productName',\n        type: { name: 'String' }\n      },\n      price: {\n        required: false,\n        serializedName: 'productPrice',\n        type: { name: 'Number' }\n      }\n    }\n  }\n};\n\nconst originalProduct: Product = { id: 1, name: 'Example Widget', price: 99.99 };\n\n// Serialize an object based on the defined mapper\nconst serializedProduct = serialize(productMapper, originalProduct, 'productObject');\n\nconsole.log('Original Product:', originalProduct);\nconsole.log('Serialized Product:', JSON.stringify(serializedProduct, null, 2));\n\n// Assuming the serialized form might have different property names on the wire\nconst receivedSerializedProduct = { id: 1, productName: 'Example Widget', productPrice: 99.99 };\n\n// Deserialize the received object back into the Product interface\nconst deserializedProduct = deserialize(productMapper, receivedSerializedProduct, 'productObject') as Product;\n\nconsole.log('Deserialized Product:', deserializedProduct);\n\n// Example with missing required property (will throw an error during serialization/deserialization)\ntry {\n  const invalidProduct = { name: 'Missing ID' };\n  serialize(productMapper, invalidProduct, 'invalidProduct');\n} catch (error: any) {\n  console.error('\\nError during serialization (expected):', error.message);\n}\n","lang":"typescript","description":"Demonstrates basic object serialization and deserialization using `ms-rest` mappers, including handling required properties during validation.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}