Skip to content

gi-nx


gi-nx / addContentPackToProject

ts
function addContentPackToProject(url: string, options?: ImportOptions): Promise<{
  contents: PackContents;
  mergeDecisions?: MergeDecisions;
}>;

Fetches a content pack from url and imports its contents into the current project.

Parameters ​

ParameterTypeDescription
urlstringThe URL of the pack bundle to fetch.
options?ImportOptionsWhich bundle contents to import. Defaults to all enabled.

Returns ​

Promise<{ contents: PackContents; mergeDecisions?: MergeDecisions; }>

The fetched pack contents and the merge decisions that were applied (e.g. 'replace', 'ignore', 'keep both' for each conflict).

Needs Permission ​

Examples ​

ts
const { contents, mergeDecisions } = await addContentPackToProject('https://example.com/pack.json');
console.log(contents.sections, contents.layers);
console.log(mergeDecisions?.projectApp); // decisions for each feature category conflict

// Import only sections and layers
const { contents: partial } = await addContentPackToProject('https://example.com/pack.json', {
  [SECTIONS_IN_BUNDLE]: true,
  [FLOW_IN_BUNDLE]: true,
  [LAYER_IN_BUNDLE]: true
});
ts
const result = await addContentPackToProject('https://example.com/bundle.json');
console.log(result);
// {
//   contents: {
//     layerTree: { items: { root: ..., "GIRDRW-1:default-fill": ... }, rootId: "root" },
//     layers: ["100002", "2476", "24624"],
//     sections: [{ type: "Feature", geometry: { ... }, properties: { id: "..." } }],
//     usages: { Community: { join: { color: "#ffe644" }, default: { levels: 1 } } },
//     flows: { "055897e4...": { id: "...", name: "Rounded Stack", ... } },
//     blocks: { "0a2109...": { id: "...", name: "Block 5", ... } },
//     analytics: { tabs: { ... }, units: { ... }, ... },
//     apps: { "213": { app: "213" } }
//   },
//   mergeDecisions: {
//     projectApp: [{ default: "keep both", dictKey: "usage", key: "Community", ... }],
//     flows: [{ default: "replace", value: { ... } }],
//     blocks: [],
//     scenarios: []
//   }
// }