sp-js-provisioning
Version:
SharePoint provisioning with pure JavaScript
177 lines (176 loc) • 5.63 kB
TypeScript
import { IWeb } from '@pnp/sp/presets/all';
import { JsomContext } from 'spfx-jsom';
import { IProvisioningConfig } from '../provisioningconfig';
import { ProvisioningContext } from '../provisioningcontext';
import { IListInstance } from '../schema';
import { TokenHelper } from '../util/tokenhelper';
import { HandlerBase } from './handlerbase';
export interface ISPField {
Id: string;
InternalName: string;
SchemaXml: string;
}
/**
* Describes the Lists Object Handler
*/
export declare class Lists extends HandlerBase {
tokenHelper: TokenHelper;
jsomContext: JsomContext;
context: ProvisioningContext;
/**
* Creates a new instance of the Lists class
*
* @param config - Provisioning config
*/
constructor(config: IProvisioningConfig);
/**
* Provisioning lists
*
* @param web - The web
* @param lists - The lists to provision
*/
ProvisionObjects(web: IWeb, lists: IListInstance[], context: ProvisioningContext): Promise<void>;
/**
* Processes a list
*
* @param web - The web
* @param lc - The list
*/
private processList;
/**
* Processes content type bindings for a list
*
* @param lc - The list configuration
* @param list - The pnp list
* @param contentTypeBindings - Content type bindings
* @param removeExisting - Remove existing content type bindings
*/
private processContentTypeBindings;
/**
* Processes a content type binding for a list
*
* @param lc - The list configuration
* @param list - The pnp list
* @param contentTypeID - The Content Type ID
*/
private processContentTypeBinding;
/**
* Processes fields for a list
*
* @param web - The web
* @param list - The pnp list
*/
private processListFields;
/**
* Processes a field for a lit
*
* @param web - The web
* @param lc - The list configuration
* @param fieldXml - Field XML
*/
private processField;
/**
* Processes field refs for a list
*
* @param web - The web
* @param lc - The list configuration
*/
private processListFieldRefs;
/**
*
* Processes a field ref for a list
*
* @param list - The list
* @param lc - The list configuration
* @param fieldRef - The list field ref
* @param listFields - The list fields
* @param webFields - The web fields
*/
private processFieldRef;
/**
* Processes views for a list
*
* @param web - The web
* @param lc - The list configuration
*/
private processListViews;
/**
* Removes existing views for a list
*
* @param web - The web
* @param lc - The list configuration
*/
private removeExistingViews;
/**
* Processes a view for a list
*
* @param web - The web
* @param lc - The list configuration
* @param lvc - The view configuration
*/
private processView;
/**
* Processes view fields for a view
*
* @param view - The pnp view
* @param lvc - The view configuration
*/
private processViewFields;
/**
* Provisions a folder hierarchy inside a list / document library. Runs after
* the list, its fields and views exist. Creation is idempotent: an existing
* folder is left in place and recursion continues into its children, so
* re-running the template is safe. A folder that fails to create is logged
* and skipped (along with its subtree) rather than aborting the whole list.
*
* @param web - The web
* @param lc - The list configuration
*/
private processListFolders;
/**
* Creates each folder in `folders` beneath `parentFolder` (idempotent) then
* recurses into its children. `parentServerRelativeUrl` is used only for
* logging the full path.
*
* @param parentFolder - The PnP parent folder
* @param parentServerRelativeUrl - Server-relative URL of the parent folder
* @param folders - Folder configs to create at this level
* @param listTitle - The list title (for logging)
*/
private _processFolderLevel;
/**
* Provisions seed data rows for a list. Runs last (after fields, content
* types and views exist). Upserts by KeyColumn so re-running is idempotent,
* and resolves Lookup/User/Taxonomy values. A failing row is logged and
* skipped rather than aborting the whole list.
*
* @param web - The web
* @param lc - The list configuration
*/
private processListDataRows;
/**
* Builds the REST item payload from a data row, mapping each field by type
* (Lookup/User → `<Field>Id`, Taxonomy → the hidden note field, URL, etc.).
*/
private _buildItemValues;
/**
* Resolves a lookup value to an item id: a number (or `{ lookupId }`) is used
* directly; a string (or `{ lookupValue }`) is looked up in the target list by
* its show field.
*/
private _resolveLookupId;
/**
* Resolves a user value (login/email string, `{ login }`/`{ email }`, or a
* numeric id) to a user id via `ensureUser`.
*/
private _resolveUserId;
/**
* Writes taxonomy value(s) by setting the field's hidden note field to the
* `-1;#Label|TermGuid` form (joined with `;#` for multi-value fields). Terms
* without a label are skipped (the label is required to write the note field).
*/
private _applyTaxonomy;
private static _normGuid;
private static _escapeOData;
private static _toArray;
}