Lightning.Projects.Provisioner (Lightning v2.19.0)

View Source

Provides functions for importing projects. This module is used by the provisioning HTTP API.

When providing a project to import, all records must have an id field. It's up to the caller to ensure that the id is unique and generated ahead of time in the case of new records.

Summary

Functions

Import a project document into the database.

Preload all dependencies for a project.

Extracts the workflow ids carried by an import/merge document that a live collaborative document should reconcile against, excluding workflows the document marks for deletion. Only workflows present in the document are returned, so sibling workflows on the target are never touched.

Validate that there are no extraneous parameters in the changeset.

Functions

import_document(project, user_or_repo_connection, data, opts \\ [])

Import a project document into the database.

Upserts the project and the associations carried in the document (workflows, project credentials, collections) inside a single transaction, then fires audit, version-bump, and snapshot side effects.

Generic pipeline shared by YAML provisioning, CLI deploys, GitHub syncs, and sandbox merges. It only acts on what the document contains — sandbox-specific behaviours (credential cloning, dataclip copying, collection name sync) are composed around this call in Lightning.Projects.Sandboxes.

Options

  • :allow_stale - If true, allows stale operations during import (useful for merge operations where concurrent modifications are expected). Defaults to false.

  • :reconcile_collaboration - If true, broadcasts a collaboration reconcile request for each affected workflow AFTER the import transaction commits, so any live collaborative document re-syncs from the database.

    Defaults to FALSE, which is what a deploy did before this work: an editor that was open stayed as it was. Rebuilding someone's document under them mid-edit is a visible change, and it would reach every collaborator in the room whether or not they asked for any of this. Callers that need it ask for it, and none of them is a plain import.

parse_document(project, data, user_or_repo_connection \\ nil)

preload_dependencies(project, snapshots \\ nil)

@spec preload_dependencies(Lightning.Projects.Project.t(), nil | [Ecto.UUID.t(), ...]) ::
  Lightning.Projects.Project.t()

Preload all dependencies for a project.

Exclude deleted workflows.

reconcilable_workflow_ids(data)

@spec reconcilable_workflow_ids(map()) :: [Ecto.UUID.t()]

Extracts the workflow ids carried by an import/merge document that a live collaborative document should reconcile against, excluding workflows the document marks for deletion. Only workflows present in the document are returned, so sibling workflows on the target are never touched.

validate_extraneous_params(changeset, opts \\ [])

Validate that there are no extraneous parameters in the changeset.

For all params in the changeset, ensure that the param is in the list of known fields in the schema.