Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# AI Coding Agent Instructions for Standard-Types

## Project Overview

This repository provides Java stub declarations for Salesforce platform types to support static analysis in apex-ls. All classes are compilation-compatible but throw `UnsupportedOperationException` at runtime since they're analysis stubs, not implementations.

## Architecture & Package Structure

### Core Namespace Pattern

- **Root package**: `com.nawforce.runforce`
- **Namespace mapping**: Each Salesforce namespace becomes a Java package (e.g., `System` → `com.nawforce.runforce.System`)
- **Cross-references**: Types reference each other using proper `com.nawforce.runforce.*` imports, never native Java types (except `Object`)

### Key Package Categories

- **`System/`** - Core Apex types (String, Integer, List, Map, Database operations)
- **`Schema/`** - Metadata and reflection types (SObjectType, DescribeSObjectResult)
- **`ConnectApi/`** - REST API representations and service classes
- **`Database/`** - DML operation results and batch processing interfaces
- **`SObjectStubs/`** - Standard object stubs (User, AuthProvider, etc.)
- **`aiplatform/`** - AI platform service types (newer additions)

## Development Patterns

### Stub Implementation Pattern

Every method follows this exact pattern:

```java
// [link to class documentation page]
@SuppressWarnings("unused")
public class ExampleClass {
public ReturnType methodName(ParamType param) {throw new java.lang.UnsupportedOperationException();}
}
```

### Type Import Rules ⚠️

- **ALWAYS use** `com.nawforce.runforce.System.String` (not `java.lang.String`)
- **ALWAYS use** `com.nawforce.runforce.System.Integer` (not `java.lang.Integer`)
- **ALWAYS use** `com.nawforce.runforce.System.List` (not `java.util.List`)
- **ONLY exception**: `Object` can reference native Java type

### Method Name Collision Rules ⚠️

- **Methods that clash with `java.lang.Object`** must be suffixed with `$`:
- `equals(Object obj)` → `equals$(Object obj)`
- `hashCode()` → `hashCode$()`
- `toString()` → `toString$()`
- This prevents compilation conflicts with inherited Object methods
- Apply this rule when Salesforce documentation shows these method names

### Class Structure Patterns

#### Static Method Classes

Classes with only static methods (no instance state):

```java
@SuppressWarnings("unused")
public class StaticMethodClass {
public static ReturnType methodName(ParamType param) {throw new java.lang.UnsupportedOperationException();}
}
```

#### Instance Classes

Classes with non-static methods/properties require public constructors:

```java
@SuppressWarnings("unused")
public class InstanceClass {
public String field; // Public fields as documented

public InstanceClass() {throw new java.lang.UnsupportedOperationException();} // Default constructor
public InstanceClass(String param) {throw new java.lang.UnsupportedOperationException();} // Documented constructors

public String getField() {throw new java.lang.UnsupportedOperationException();} // Only documented methods
}
```

### Documentation Adherence Rules

- **Method/property order**: Maintain alphabetical order as documented in Salesforce API docs
- **⚠️ CRITICAL: Getters/setters**: NEVER auto-generate getter/setter methods. ONLY create methods that are explicitly documented in the Salesforce API documentation. Properties are public fields unless documentation shows otherwise.
- **⚠️ CRITICAL: Methods only**: Create ONLY the methods that appear in the official Salesforce documentation. Do not add any convenience methods, utility methods, or standard Java patterns not documented.
- **Constructor patterns**: Static method classes have no constructors; instance classes have public default constructor plus any documented constructors
- **Copyright year**: Use current year (2025) for newly created files

## Build & Development

### Maven Build

```bash
mvn install -Dgpg.skip=true # Skip GPG signing for local builds
```

### Version Strategy

- Versions track Salesforce API releases (e.g., v64.X.X = Summer '25 API)
- Built for Java 1.8 compatibility for wider tooling support

### File Organization

- No tests (stubs are compilation-only)
- `options/field-service.txt` - Lists Field Service related types

## Common Tasks

### Accessing Salesforce Documentation

When working with Apex reference pages, use **Playwright MCP** to access the content since the Salesforce documentation pages cannot be fetched directly. Use the browser tools to navigate to and extract information from:

- `https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/` - Main Apex Reference documentation
- Specific class documentation pages for method signatures, constructors, and property definitions

### Implementing Namespaces

Use **Playwright MCP** to access the namespace documentation page (e.g., `apex_namespace_[namespace].htm`) since Salesforce docs cannot be fetched directly. Extract all type names and their documentation links. Types can then be added systematically using the links and checked off.

Create `.github/[namespace-name]-todo.md` with a simple structure:

```markdown
# [Namespace] TODO List

## Classes

- [ ] **TypeName** - [Documentation](link)

## Interfaces

- [ ] **TypeName** - [Documentation](link)

## Enums

- [ ] **TypeName** - [Documentation](link)
```

### Adding New Salesforce Types

1. **Determine package location** based on Salesforce namespace mapping
2. **Set copyright year** to current year (2025) for new files
3. **Preserve documentation order** - maintain alphabetical method/property order from API docs
4. **Choose class pattern**:
- Static method classes: No constructors
- Instance classes: Public default constructor + documented constructors
5. **Import only `com.nawforce.runforce.*` types** (except `Object`)
6. **Add `@SuppressWarnings("unused")` annotation**
7. **⚠️ CRITICAL: Create only documented methods** - NEVER create getter/setter methods or any other methods not explicitly shown in the Salesforce documentation. Only public fields and documented methods.
8. **Add documentation link** - include comment above class: `// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/[class-doc-page].htm`
9. **Do not create types without documentation** - If you encounter a referenced type that doesn't exist, do not attempt to create it without access to its official Salesforce documentation page. Ask for the documentation link if necessary.
10. **Verify compilation** with `mvn compile`

### Updating Existing Classes

1. **Maintain existing method order** when adding new methods
2. **Follow alphabetical insertion** for new methods per API documentation
3. **Preserve existing constructor patterns** (static vs instance class style)
4. **Add documentation link** if not already present - include comment above class with Salesforce documentation URL
5. **⚠️ CRITICAL: Do not create types without documentation** - If you encounter a referenced type that doesn't exist, do not attempt to create it without access to its official Salesforce documentation page. Ask for the documentation link if necessary.
6. **Validate with compilation** after changes

### Cross-Package Dependencies

When types reference each other across packages, always use full package imports:

```java
// In ConnectApi package referencing System types
import com.nawforce.runforce.System.String;
import com.nawforce.runforce.System.List;
```

### Static Analysis Integration

These stubs are consumed by apex-ls via JVM reflection - the structure and method signatures must exactly match Salesforce platform APIs for static analysis accuracy.

## Sources

- [apex-ls repository](https://github.com/apex-dev-tools/apex-ls) - The Apex Language Server that consumes these stubs
- [API Updates Documentation](https://github.com/apex-dev-tools/apex-ls/blob/main/doc/API_Updates.md) - Detailed update process workflow
- [sobject-types repository](https://github.com/apex-dev-tools/sobject-types) - Companion repository for SObject type stubs
- [Salesforce Release Notes](https://help.salesforce.com/s/articleView?id=release-notes.salesforce_release_notes.htm) - Official API change documentation
- [Apex Reference Guide](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ref_guide.htm) - Method signatures and type definitions
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Stub declarations for Salesforce platform types encoded as compilable Java.

These stub declarations help support static analysis of Apex code in [apex-ls](https://github.com/apex-dev-tools/apex-ls) but you may also find them useful for other purposes. They have been encoded in Java to get the benefit of type checking by javac so it easier to spot when something is amiss. In apex-ls JVM reflection is used to 'read' the stubs as part of the static analysis.

The library is versioned to reflect Salesforce API numbers, so currently v64.X.X matches the Salesforce Summer '25 API.
The library is versioned to reflect Salesforce API numbers, so currently v65.X.X matches the Salesforce Winter '26 API.

## Installation

Expand All @@ -14,7 +14,7 @@ To use the jar in a maven project add the following to your pom.xml
<dependency>
<groupId>io.github.apex-dev-tools</groupId>
<artifactId>standard-types</artifactId>
<version>64.0.0</version>
<version>65.0.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.apex-dev-tools</groupId>
<artifactId>standard-types</artifactId>
<version>64.0.0</version>
<version>65.0.0</version>
<packaging>jar</packaging>

<name>standard-types</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

import com.nawforce.runforce.System.String;
import com.nawforce.runforce.System.Datetime;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AbstractResponse.htm
@SuppressWarnings("unused")
public abstract class AbstractResponse implements GatewayResponse {
public AbstractResponse() {throw new java.lang.UnsupportedOperationException();}

public void setGatewayAvsCode(String gatewayAvsCode) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayDate(Datetime gatewayDate) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayMessage(String gatewayMessage) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayResultCode(String gatewayResultCode) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayResultCodeDescription(String gatewayResultCodeDescription) {throw new java.lang.UnsupportedOperationException();}
public void setSalesforceResultCodeInfo(SalesforceResultCodeInfo salesforceResultCodeInfo) {throw new java.lang.UnsupportedOperationException();}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

import com.nawforce.runforce.System.String;
import com.nawforce.runforce.System.Double;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AbstractTransactionResponse.htm
@SuppressWarnings("unused")
public abstract class AbstractTransactionResponse extends AbstractResponse {
public AbstractTransactionResponse() {throw new java.lang.UnsupportedOperationException();}

public void setAmount(Double amount) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayReferenceDetails(String gatewayReferenceDetails) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayReferenceNumber(String gatewayReferenceNumber) {throw new java.lang.UnsupportedOperationException();}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_commercepayments_AccountHolderType.htm
@SuppressWarnings("unused")
public enum AccountHolderType {
Business,
Individual
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_commercepayments_AccountType.htm
@SuppressWarnings("unused")
public enum AccountType {
Checking,
Savings
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

import com.nawforce.runforce.System.String;
import com.nawforce.runforce.System.Boolean;
import com.nawforce.runforce.System.Integer;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AddressRequest.htm
@SuppressWarnings("unused")
public class AddressRequest {
public String city;
public String companyName;
public String country;
public String postalCode;
public String state;
public String street;

public AddressRequest() {throw new java.lang.UnsupportedOperationException();}
public AddressRequest(String street, String city, String state, String country, String postalCode) {throw new java.lang.UnsupportedOperationException();}

public Boolean equals$(Object obj) {throw new java.lang.UnsupportedOperationException();}
public Integer hashCode$() {throw new java.lang.UnsupportedOperationException();}
public String toString$() {throw new java.lang.UnsupportedOperationException();}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/
package com.nawforce.runforce.CommercePayments;

import com.nawforce.runforce.System.Boolean;
import com.nawforce.runforce.System.Integer;
import com.nawforce.runforce.System.String;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AlternativePaymentMethodRequest.htm
@SuppressWarnings("unused")
public class AlternativePaymentMethodRequest {
public String accountId;
public String email;
public String gatewayToken;
public String gatewayTokenDetails;
public String name;

public AlternativePaymentMethodRequest(String gatewayToken) {throw new java.lang.UnsupportedOperationException();}

public Boolean equals$(Object obj) {throw new java.lang.UnsupportedOperationException();}
public Integer hashCode$() {throw new java.lang.UnsupportedOperationException();}
public String toString$() {throw new java.lang.UnsupportedOperationException();}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/
package com.nawforce.runforce.CommercePayments;

import com.nawforce.runforce.System.Id;
import com.nawforce.runforce.System.String;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AlternativePaymentMethodResponse.htm
@SuppressWarnings("unused")
public class AlternativePaymentMethodResponse {

public AlternativePaymentMethodResponse() {throw new java.lang.UnsupportedOperationException();}

public void setAccountId(Id accountId) {throw new java.lang.UnsupportedOperationException();}
public void setComments(String comments) {throw new java.lang.UnsupportedOperationException();}
public void setEmail(String email) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayToken(String gatewayToken) {throw new java.lang.UnsupportedOperationException();}
public void setGatewayTokenDetails(String gatewayTokenDetails) {throw new java.lang.UnsupportedOperationException();}
public void setName(String name) {throw new java.lang.UnsupportedOperationException();}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2025 Certinia Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

import com.nawforce.runforce.System.String;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AuditParamsRequest.htm
@SuppressWarnings("unused")
public abstract class AuditParamsRequest {
public String email;
public String ipAddress;
public String macAddress;
public String phone;

public AuditParamsRequest(String email, String macAddress, String ipAddress, String phone) {throw new java.lang.UnsupportedOperationException();}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2025 Salesforce, Inc. All rights reserved.
*/

package com.nawforce.runforce.CommercePayments;

// https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_commercepayments_AuthApiPaymentMethodRequest.htm
@SuppressWarnings("unused")
public class AuthApiPaymentMethodRequest extends BaseApiPaymentMethodRequest {
public CardPaymentMethodRequest cardPaymentMethod;

public AuthApiPaymentMethodRequest() {throw new java.lang.UnsupportedOperationException();}
public AuthApiPaymentMethodRequest(CardPaymentMethodRequest cardPaymentMethodRequest) {throw new java.lang.UnsupportedOperationException();}
}
Loading