{"id":15737,"library":"oci-workrequests","title":"Oracle Cloud Infrastructure Node.js/TypeScript Client for Work Requests","description":"The `oci-workrequests` package is an official Oracle Cloud Infrastructure (OCI) Node.js/TypeScript client specifically designed to interact with the OCI Work Requests service. Currently at version 2.130.0, this package is part of the broader OCI TypeScript SDK and receives very frequent updates, often on a daily or weekly basis, reflecting continuous feature development and alignment with new OCI service capabilities. It provides a type-safe and idiomatic interface for managing asynchronous operations within OCI, allowing developers to programmatically monitor the status and outcomes of long-running tasks across various OCI services. Key differentiators include its tight integration with the OCI ecosystem, comprehensive type definitions, and adherence to OCI's API standards, simplifying the development of robust cloud automation and management scripts.","status":"active","version":"2.130.0","language":"javascript","source_language":"en","source_url":"https://github.com/oracle/oci-typescript-sdk","tags":["javascript","typescript"],"install":[{"cmd":"npm install oci-workrequests","lang":"bash","label":"npm"},{"cmd":"yarn add oci-workrequests","lang":"bash","label":"yarn"},{"cmd":"pnpm add oci-workrequests","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The OCI SDK primarily targets modern TypeScript/ESM environments. While CommonJS might work with transpilation, direct require is less common and types will be lost.","wrong":"const WorkRequestsClient = require('oci-workrequests');","symbol":"WorkRequestsClient","correct":"import { WorkRequestsClient } from 'oci-workrequests';"},{"note":"The `oci-common` module exports many utilities, including authentication providers, as named exports. It's typically imported as a namespace.","wrong":"import common from 'oci-common';","symbol":"common","correct":"import * as common from 'oci-common';"},{"note":"Request and response types for service operations are typically nested under a 'requests' or 'responses' namespace within the service module.","symbol":"ListWorkRequestsRequest","correct":"import { requests } from 'oci-workrequests';\nconst request: requests.ListWorkRequestsRequest = { /* ... */ };"}],"quickstart":{"code":"import { WorkRequestsClient } from 'oci-workrequests';\nimport * as common from 'oci-common';\nimport { requests } from 'oci-workrequests';\n\nasync function listAllWorkRequests(): Promise<void> {\n  try {\n    // Configure authentication using default provider (e.g., OCI config file or instance principal)\n    const provider = new common.auth.DefaultAuthenticationDetailsProvider();\n    \n    // Initialize the WorkRequests client\n    const client = new WorkRequestsClient({\n      authenticationDetailsProvider: provider\n    });\n\n    // Define the request to list work requests\n    // Replace 'ocid1.compartment.oc1..aaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' with your compartment OCID\n    const listRequest: requests.ListWorkRequestsRequest = {\n      compartmentId: process.env.OCI_COMPARTMENT_ID ?? 'ocid1.compartment.oc1..aaaaaaaaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',\n      // You can add filters like status, resourceId, etc.\n      limit: 10 // Limit to 10 results for brevity\n    };\n\n    // Call the ListWorkRequests API\n    console.log('Listing OCI Work Requests...');\n    let response = await client.listWorkRequests(listRequest);\n    \n    if (response.items && response.items.length > 0) {\n      console.log(`Found ${response.items.length} work requests:`)\n      for (const wr of response.items) {\n        console.log(`  ID: ${wr.id}, Status: ${wr.status}, Resource: ${wr.resources ? wr.resources[0]?.identifier : 'N/A'}`);\n      }\n    } else {\n      console.log('No work requests found in the specified compartment.');\n    }\n\n  } catch (error) {\n    console.error('Error listing work requests:', error);\n  }\n}\n\nlistAllWorkRequests();\n","lang":"typescript","description":"This code initializes the WorkRequests client and lists the first 10 work requests in a specified compartment, demonstrating basic API interaction."},"warnings":[{"fix":"Ensure your `~/.oci/config` file is properly configured with `user`, `fingerprint`, `key_file`, and `tenancy` details, or ensure your compute instance has appropriate instance principal policies.","message":"OCI SDK authentication can be complex, requiring a correctly configured `~/.oci/config` file, instance principals for compute instances, or session tokens for Cloud Shell. Incorrect setup is a common source of errors.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always review the release notes for the main `oci-typescript-sdk` repository before upgrading major versions. Pin exact major versions in your `package.json` to avoid unexpected breaking changes.","message":"Major version updates to the overall OCI SDK (e.g., from v2 to v3) often involve significant changes to module structure, authentication patterns, or API interfaces, requiring code adjustments.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Regularly update your dependencies and test thoroughly. Consider using a dependency management tool that allows for minor version updates (`^2.130.0`) but prevents major shifts, or pin specific versions if stability is paramount.","message":"The `oci-workrequests` package (and other service-specific packages) receives very frequent updates. While this brings new features, it can also introduce subtle behavior changes or dependency conflicts if not managed carefully.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always ensure the required `compartmentId` is provided in request objects and that the provided OCID is correct and accessible by the authenticated user.","message":"OCI API calls, especially for listing operations, often require a `compartmentId`. Forgetting this or providing an incorrect OCID will result in unauthorized or not found errors.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Verify your OCI configuration file (`~/.oci/config`) exists and is correctly formatted, or ensure environment variables like `OCI_CLI_PROFILE` and `OCI_CLI_CONFIG_FILE` are set if using a non-default profile/location.","cause":"The authentication details provider could not find valid credentials (e.g., `~/.oci/config` file missing or malformed, environment variables not set).","error":"Error: NotAuthenticated: The required information to complete authentication was not supplied."},{"fix":"Check your OCI IAM policies to ensure the user or instance principal has permissions for the Work Requests service. Double-check the OCIDs used in your request for correctness.","cause":"The authenticated user lacks the necessary IAM policies to perform the requested operation, or the specified resource (e.g., compartmentId) does not exist or is incorrect.","error":"Error: ServiceError: Authorization failed or requested resource not found. (opc-request-id: <request-id>)"},{"fix":"Ensure `npm install oci-workrequests` has been run successfully and your import statement is `import { WorkRequestsClient } from 'oci-workrequests';`.","cause":"Incorrect import statement or `oci-workrequests` package not installed or incorrectly resolved by Node.js/TypeScript.","error":"TypeError: Cannot read properties of undefined (reading 'WorkRequestsClient')"}],"ecosystem":"npm"}