{"id":47738,"library":"gd-sprest-def","title":"gd-sprest-def","description":"TypeScript definition files generated from the $metadata REST endpoint for SharePoint, providing type-safe access to SharePoint REST APIs. Current stable version is 2.1.3, updated as needed to match SharePoint changes. It is designed to be used with the gd-sprest library, offering auto-generated interfaces for SharePoint entities (SP, MS, OBA, PS, SPO) directly from the OData metadata. Key differentiator: eliminates manual TypeScript definitions by reflecting the actual server metadata, ensuring accuracy and up-to-date types. This library is not standalone; it requires async loading at runtime for full functionality.","status":"active","version":"2.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/gunjandatta/sprest-def","tags":["javascript","API","Definition","Microsoft","Office","REST","SharePoint","TypeScript","typescript"],"install":[{"cmd":"npm install gd-sprest-def","lang":"bash","label":"npm"},{"cmd":"yarn add gd-sprest-def","lang":"bash","label":"yarn"},{"cmd":"pnpm add gd-sprest-def","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Primary library that consumes these definitions; this package provides types for it.","package":"gd-sprest","optional":false},{"reason":"Peer dependency for linting TypeScript, referenced in the lib's setup.","package":"tslint","optional":true}],"imports":[{"note":"Named export, not a namespace. Allows tree-shaking.","wrong":"import * as SP from 'gd-sprest-def';","symbol":"SP","correct":"import { SP } from 'gd-sprest-def';"},{"note":"For SharePoint-related Microsoft Graph entities.","wrong":"","symbol":"Microsoft","correct":"import { Microsoft } from 'gd-sprest-def';"},{"note":"ESM-only package; CommonJS require will work but is not recommended.","wrong":"const PS = require('gd-sprest-def').PS;","symbol":"PS","correct":"import { PS } from 'gd-sprest-def';"}],"quickstart":{"code":"import { SP, MS, OBA, PS, SPO } from 'gd-sprest-def';\n\n// Example: List all lists in a SharePoint site\nasync function getLists() {\n  const lists = await SP.Web.get('/sites/mysite').lists();\n  console.log(lists);\n  // Types are fully defined: lists is SP.ListCollection<SP.List>\n}\n\ngetLists().catch(err => console.error(err));","lang":"typescript","description":"Demonstrates importing multiple definition modules and using SP.Web to fetch lists, showing type-safe async API usage."},"warnings":[{"fix":"Update imports to use { SP } from 'gd-sprest-def' instead of 'require' or default import.","message":"Removed CommonJS exports and flat file structure; uses ESM named exports only in v2.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure gd-sprest's async loader is invoked before using these definitions, or use dynamic import if using in isolation (not recommended).","message":"Direct use of definition files without the async loader from gd-sprest may cause runtime errors.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Generate fresh definitions against your target environment using the gd-sprest-def build script if types mismatch.","message":"Definitions are auto-generated from a specific SharePoint tenant's metadata; they may not cover all customizations or on-premises differences.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2.1.3':29 'access':20 'accuraci':80 'actual':76 'api':24,102 'async':94 'auto':51 'auto-gener':50 'chang':36 'current':25 'date':85 'def':4 'definit':6,72,103 'design':39 'differenti':68 'direct':62 'elimin':69 'endpoint':13 'ensur':79 'entiti':56 'file':7 'full':99 'function':100 'gd':2,46 'gd-sprest':45 'gd-sprest-def':1 'generat':8,52 'interfac':53 'javascript':101 'key':67 'librari':48,88 'load':95 'manual':70 'match':34 'metadata':11,66,78 'microsoft':104 'ms':58 'need':32 'oba':59 'odata':65 'offer':49 'offic':105 'provid':16 'ps':60 'reflect':74 'requir':93 'rest':12,23,106 'runtim':97 'safe':19 'server':77 'sharepoint':15,22,35,55,107 'sp':57 'spo':61 'sprest':3,47 'stabl':26 'standalon':91 'type':18,86 'type-saf':17 'typescript':5,71,108,109 'up-to-d':82 'updat':30 'use':42 'version':27","created_at":"2026-06-07T16:53:03.540285+00:00","updated_at":"2026-06-07T16:53:03.540285+00:00","problems":[{"fix":"Install the package: npm install gd-sprest-def. Ensure tsconfig.json includes node_modules in typeRoots or uses 'types': ['gd-sprest-def'].","cause":"Missing installation or incorrect import style in a TypeScript project without @types.","error":"Cannot find module 'gd-sprest-def' or its corresponding type declarations."},{"fix":"Add resolve.fullySpecified: false to webpack config, or use proper import path: import { SP } from 'gd-sprest-def'.","cause":"Webpack or bundler cannot resolve the ESM package. Possibly missing file extension or wrong path.","error":"Module not found: Error: Can't resolve 'gd-sprest-def' in '/path/to/project'"},{"fix":"Use type import: import type { SP } from 'gd-sprest-def' and use it only as a type, not a value.","cause":"Conflicting local type with the same name imported from both gd-sprest-def and gd-sprest/lib.","error":"Type 'SP' is not assignable to type 'SP'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/gunjandatta/sprest-def#readme","github":"https://github.com/gunjandatta/sprest-def","docs":null,"changelog":null,"pypi":null,"npm":"gd-sprest-def","openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}