sharepoint

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 16 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-0105), 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-0105), 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-0105).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(store *state.Store, 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 instance's variables (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-0105). 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-0105). The secret lives only here at build time, never in a model or an event (I6).

type Registry

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

Registry resolves a connector name to the Client for its SharePoint provider. Connectors are registered at the server from managed configuration (Graph base plus credentials), so a model refers to a connector by name only (ADR-0036/0041). A Registry is read-only once populated and safe for concurrent use by workers.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty connector registry.

func (*Registry) Client

func (r *Registry) Client(name string) (Client, bool)

Client returns the client bound to name, or nil and false if none is registered.

func (*Registry) Register

func (r *Registry) Register(name string, c Client)

Register binds a connector name to its client. Registering the same name again replaces the earlier binding (last write wins), so reconfiguration is simple.

func (*Registry) Replace

func (r *Registry) Replace(clients map[string]Client)

Replace swaps the whole set of registered connectors at once, so a server can rebuild the registry from managed configuration after a change (ADR-0041). The caller must serialize Replace with the workers that read the registry — the Atlas server does both on its run-loop goroutine — so no lock is needed. A nil map clears the registry.

type TokenSource

type TokenSource interface {
	Token(ctx context.Context) (string, error)
}

TokenSource yields a valid OAuth2 bearer access token for the Graph API, acquiring and refreshing it as it nears expiry. Implementations are safe for concurrent use by the SharePoint worker.

Jump to

Keyboard shortcuts

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