sharepoint

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package sharepoint integrates Microsoft SharePoint as a server-registered Atlas connector: a BPMN SharePoint connector task creates a list item in a model-authored site and list through a configured provider via the job path (ADR-0141), mirroring how the mail package delegates a send to a registry-managed provider (ADR-0079). The integration inherits the job protocol's durability and non-blocking properties (ADR-0007):

  • A connector task creates a job carrying the reserved compiler.SharePointJobType. The processor never performs the outbound call itself, so it stays allocation-free (invariant I1) and free of any HTTP dependency.
  • The in-process Handler — a job worker — pulls those jobs, creates the item off the processor goroutine and after fsync (invariant I2, never inside applyToState / I4), and completes the job (writing the created item's JSON into the task's result variable), which drives the token onward.
  • The Graph base and OAuth credential live in a server-side Registry keyed by connector name, so a model refers to a provider by name only and never carries an endpoint or a secret (ADR-0036/0041). Only the target (site, list, item fields) is authored in the model, like a REST task's endpoint (ADR-0067).

The transport is Microsoft Graph (GraphClient), authenticated with an OAuth2 bearer token acquired app-only (client-credentials) or via a pre-obtained refresh token (ADR-0141), reusing the same grant shapes as the native mail providers (ADR-0093).

Delivery is at-least-once: a crash between "Graph created the item" and "job completed" replays the create, which — unlike an idempotent mail Message-ID — can produce a duplicate list item. De-duplication of created items is a follow-up (ADR-0141).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(store state.Reader, lookup ProcessLookup, reg *Registry) job.OutputHandler

Handler builds a job handler that performs a SharePoint connector task. Register it with a job.Runner under the reserved compiler.SharePointJobTypeIndex via HandleWithOutput; the runner then pulls activatable SharePoint jobs, and for each the handler resolves the task's connector/site/list/fields from the compiled process — evaluating any FEEL value over the variables the task sees, up its scope chain (the fx toggle, ADR-0067) — resolves the named connector's Graph client from reg, creates the list item, and (when the task names a result variable) returns the created item's JSON as that variable to be written back on completion. Returning an error leaves the job pending (retry, then an incident, ADR-0061); the runner completes it only on success.

Types

type Client

type Client interface {
	CreateItem(ctx context.Context, req ItemRequest) (any, error)
}

Client creates a list item through one configured SharePoint provider. It is an interface so the worker is testable without a live server and so a connector name binds to exactly one provider. CreateItem returns the created item as decoded JSON (the shape Graph returns), which the worker writes into the task's result variable.

func NewProviderClient

func NewProviderClient(cfg ProviderConfig) (Client, error)

NewProviderClient builds the SharePoint client for a managed connector: it parses the credential bundle, applies the Graph token-endpoint and scope defaults, builds an OAuth token source, and returns a Graph client. A misconfigured connector returns an error so the caller can skip it (its tasks park) rather than acting wrongly. This is the single place a provider variant would be added.

type GraphClient

type GraphClient struct {
	// contains filtered or unexported fields
}

GraphClient creates SharePoint list items through the Microsoft Graph API (ADR-0141). It POSTs {fields:{…}} to /sites/{site}/lists/{list}/items with a bearer token from its TokenSource, and returns the created item as decoded JSON.

func NewGraphClient

func NewGraphClient(tokens TokenSource, baseURL string) *GraphClient

NewGraphClient builds a SharePoint Graph client. baseURL defaults to the Graph v1.0 API when empty.

func (*GraphClient) CreateItem

func (c *GraphClient) CreateItem(ctx context.Context, req ItemRequest) (any, error)

CreateItem creates a list item in the connector's site/list and returns the created item decoded from Graph's JSON response. A missing site or list, or a non-2xx response, is an error so the job stays pending and is retried (at-least-once).

type ItemRequest

type ItemRequest struct {
	Site      string
	List      string
	Fields    map[string]string
	RequestID string
}

ItemRequest is one list-item creation a SharePoint connector task performs. Site and List address the target list (a Graph site id and a list name or id); Fields are the item's column values, already resolved from the model's literal-or-FEEL values by the worker. RequestID is the job key, carried for tracing and any future idempotency support.

type ProcessLookup

type ProcessLookup func(defKey uint64) *compiler.CompiledProcess

ProcessLookup resolves a process-definition key to its compiled process. The worker uses it to find the connector name, site, list, and item fields a SharePoint job belongs to, so one handler serves every deployed process.

type ProviderConfig

type ProviderConfig struct {
	Endpoint string
	Secret   string
}

ProviderConfig is the per-connector data the server resolves before building a client: an optional Graph base override (Endpoint) and the resolved Secret — the OAuth credential JSON bundle held in the vault under the connector's credentialsRef (ADR-0141). The secret lives only here at build time, never in a model or an event (I6).

type Registry

type Registry = clientreg.Registry[Client]

Registry resolves a connector name to the Client for this kind. Connectors are registered at the server from managed configuration (endpoint plus credentials), so a model refers to a connector by name only (ADR-0036/0041).

It is the shared clientreg.Registry, which also carries *why* a configured connector is missing from it — the difference between "never configured" and "configured and broken", which is what a parked token has to be able to say (ADR-0158).

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty connector registry.

type TokenSource

type TokenSource = oauth2.TokenSource

TokenSource yields a valid OAuth2 bearer access token for the Graph API. The mechanism — caching, refresh timing, the token exchange — is the shared oauth2 package's; what stays here is this connector's policy: which grants it accepts and what its credential bundle looks like.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL