@uniformdev/canvas 12.0.1-alpha.94 → 12.2.1-alpha.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +5 -5
  3. package/dist/chunk-A4MBTKCQ.mjs +2 -0
  4. package/dist/cli/cli.d.ts +14 -0
  5. package/dist/cli/cli.js +4 -0
  6. package/dist/cli/cli.mjs +3 -0
  7. package/dist/createEventBus-ca90547e.d.ts +255 -0
  8. package/dist/index.d.ts +365 -0
  9. package/dist/index.esm.js +4 -0
  10. package/dist/index.js +5 -0
  11. package/dist/index.mjs +4 -0
  12. package/package.json +34 -34
  13. package/dist/cjs/CanvasClient.d.ts +0 -50
  14. package/dist/cjs/CanvasClient.js +0 -1
  15. package/dist/cjs/cli/arraySyncEngineDataSource.d.ts +0 -10
  16. package/dist/cjs/cli/arraySyncEngineDataSource.js +0 -1
  17. package/dist/cjs/cli/cli.d.ts +0 -3
  18. package/dist/cjs/cli/cli.js +0 -1
  19. package/dist/cjs/cli/commands/component/_util.d.ts +0 -3
  20. package/dist/cjs/cli/commands/component/_util.js +0 -1
  21. package/dist/cjs/cli/commands/component/get.d.ts +0 -7
  22. package/dist/cjs/cli/commands/component/get.js +0 -1
  23. package/dist/cjs/cli/commands/component/list.d.ts +0 -6
  24. package/dist/cjs/cli/commands/component/list.js +0 -1
  25. package/dist/cjs/cli/commands/component/pull.d.ts +0 -10
  26. package/dist/cjs/cli/commands/component/pull.js +0 -1
  27. package/dist/cjs/cli/commands/component/push.d.ts +0 -9
  28. package/dist/cjs/cli/commands/component/push.js +0 -1
  29. package/dist/cjs/cli/commands/component/remove.d.ts +0 -7
  30. package/dist/cjs/cli/commands/component/remove.js +0 -1
  31. package/dist/cjs/cli/commands/component/update.d.ts +0 -7
  32. package/dist/cjs/cli/commands/component/update.js +0 -1
  33. package/dist/cjs/cli/commands/component.d.ts +0 -2
  34. package/dist/cjs/cli/commands/component.js +0 -1
  35. package/dist/cjs/cli/commands/composition/_util.d.ts +0 -3
  36. package/dist/cjs/cli/commands/composition/_util.js +0 -1
  37. package/dist/cjs/cli/commands/composition/get.d.ts +0 -8
  38. package/dist/cjs/cli/commands/composition/get.js +0 -1
  39. package/dist/cjs/cli/commands/composition/list.d.ts +0 -8
  40. package/dist/cjs/cli/commands/composition/list.js +0 -1
  41. package/dist/cjs/cli/commands/composition/pull.d.ts +0 -10
  42. package/dist/cjs/cli/commands/composition/pull.js +0 -1
  43. package/dist/cjs/cli/commands/composition/push.d.ts +0 -9
  44. package/dist/cjs/cli/commands/composition/push.js +0 -1
  45. package/dist/cjs/cli/commands/composition/remove.d.ts +0 -7
  46. package/dist/cjs/cli/commands/composition/remove.js +0 -1
  47. package/dist/cjs/cli/commands/composition/update.d.ts +0 -7
  48. package/dist/cjs/cli/commands/composition/update.js +0 -1
  49. package/dist/cjs/cli/commands/composition.d.ts +0 -2
  50. package/dist/cjs/cli/commands/composition.js +0 -1
  51. package/dist/cjs/cli/componentDefinitionEngineDataSource.d.ts +0 -7
  52. package/dist/cjs/cli/componentDefinitionEngineDataSource.js +0 -1
  53. package/dist/cjs/cli/componentInstanceEngineDataSource.d.ts +0 -9
  54. package/dist/cjs/cli/componentInstanceEngineDataSource.js +0 -1
  55. package/dist/cjs/cli/fileSyncEngineDataSource.d.ts +0 -9
  56. package/dist/cjs/cli/fileSyncEngineDataSource.js +0 -1
  57. package/dist/cjs/cli/package.d.ts +0 -7
  58. package/dist/cjs/cli/package.js +0 -1
  59. package/dist/cjs/cli/syncEngine.d.ts +0 -49
  60. package/dist/cjs/cli/syncEngine.js +0 -1
  61. package/dist/cjs/cli/syncEngineConsoleLogger.d.ts +0 -5
  62. package/dist/cjs/cli/syncEngineConsoleLogger.js +0 -1
  63. package/dist/cjs/cli/util.d.ts +0 -43
  64. package/dist/cjs/cli/util.js +0 -1
  65. package/dist/cjs/enhancement/EnhancerBuilder.d.ts +0 -66
  66. package/dist/cjs/enhancement/EnhancerBuilder.js +0 -1
  67. package/dist/cjs/enhancement/UniqueBatchEntries.d.ts +0 -17
  68. package/dist/cjs/enhancement/UniqueBatchEntries.js +0 -1
  69. package/dist/cjs/enhancement/batchEnhancer.d.ts +0 -39
  70. package/dist/cjs/enhancement/batchEnhancer.js +0 -1
  71. package/dist/cjs/enhancement/compose.d.ts +0 -6
  72. package/dist/cjs/enhancement/compose.js +0 -1
  73. package/dist/cjs/enhancement/createLimitPolicy.d.ts +0 -8
  74. package/dist/cjs/enhancement/createLimitPolicy.js +0 -1
  75. package/dist/cjs/enhancement/enhance.d.ts +0 -18
  76. package/dist/cjs/enhancement/enhance.js +0 -1
  77. package/dist/cjs/enhancement/localize.d.ts +0 -11
  78. package/dist/cjs/enhancement/localize.js +0 -1
  79. package/dist/cjs/enhancement/walkComponentTree.d.ts +0 -14
  80. package/dist/cjs/enhancement/walkComponentTree.js +0 -1
  81. package/dist/cjs/index.d.ts +0 -17
  82. package/dist/cjs/index.js +0 -1
  83. package/dist/cjs/preview/EventNames.d.ts +0 -1
  84. package/dist/cjs/preview/EventNames.js +0 -1
  85. package/dist/cjs/preview/createEventBus.d.ts +0 -6
  86. package/dist/cjs/preview/createEventBus.js +0 -1
  87. package/dist/cjs/preview/getChannelName.d.ts +0 -1
  88. package/dist/cjs/preview/getChannelName.js +0 -1
  89. package/dist/cjs/preview/subscribeToComposition.d.ts +0 -13
  90. package/dist/cjs/preview/subscribeToComposition.js +0 -1
  91. package/dist/cjs/types/componentDefinitions.d.ts +0 -90
  92. package/dist/cjs/types/componentDefinitions.js +0 -1
  93. package/dist/cjs/types/componentInstances.d.ts +0 -104
  94. package/dist/cjs/types/componentInstances.js +0 -1
  95. package/dist/cjs/types/enhancement.d.ts +0 -79
  96. package/dist/cjs/types/enhancement.js +0 -1
  97. package/dist/cjs/types/index.d.ts +0 -3
  98. package/dist/cjs/types/index.js +0 -1
  99. package/dist/cjs/utils/constants.d.ts +0 -20
  100. package/dist/cjs/utils/constants.js +0 -1
  101. package/dist/cjs/utils/isSystemComponentDefinition.d.ts +0 -2
  102. package/dist/cjs/utils/isSystemComponentDefinition.js +0 -1
  103. package/dist/cjs/utils/mapSlotToPersonalizedVariations.d.ts +0 -7
  104. package/dist/cjs/utils/mapSlotToPersonalizedVariations.js +0 -1
  105. package/dist/esm/CanvasClient.d.ts +0 -50
  106. package/dist/esm/CanvasClient.js +0 -1
  107. package/dist/esm/cli/arraySyncEngineDataSource.d.ts +0 -10
  108. package/dist/esm/cli/arraySyncEngineDataSource.js +0 -1
  109. package/dist/esm/cli/cli.d.ts +0 -3
  110. package/dist/esm/cli/cli.js +0 -1
  111. package/dist/esm/cli/commands/component/_util.d.ts +0 -3
  112. package/dist/esm/cli/commands/component/_util.js +0 -1
  113. package/dist/esm/cli/commands/component/get.d.ts +0 -7
  114. package/dist/esm/cli/commands/component/get.js +0 -1
  115. package/dist/esm/cli/commands/component/list.d.ts +0 -6
  116. package/dist/esm/cli/commands/component/list.js +0 -1
  117. package/dist/esm/cli/commands/component/pull.d.ts +0 -10
  118. package/dist/esm/cli/commands/component/pull.js +0 -1
  119. package/dist/esm/cli/commands/component/push.d.ts +0 -9
  120. package/dist/esm/cli/commands/component/push.js +0 -1
  121. package/dist/esm/cli/commands/component/remove.d.ts +0 -7
  122. package/dist/esm/cli/commands/component/remove.js +0 -1
  123. package/dist/esm/cli/commands/component/update.d.ts +0 -7
  124. package/dist/esm/cli/commands/component/update.js +0 -1
  125. package/dist/esm/cli/commands/component.d.ts +0 -2
  126. package/dist/esm/cli/commands/component.js +0 -1
  127. package/dist/esm/cli/commands/composition/_util.d.ts +0 -3
  128. package/dist/esm/cli/commands/composition/_util.js +0 -1
  129. package/dist/esm/cli/commands/composition/get.d.ts +0 -8
  130. package/dist/esm/cli/commands/composition/get.js +0 -1
  131. package/dist/esm/cli/commands/composition/list.d.ts +0 -8
  132. package/dist/esm/cli/commands/composition/list.js +0 -1
  133. package/dist/esm/cli/commands/composition/pull.d.ts +0 -10
  134. package/dist/esm/cli/commands/composition/pull.js +0 -1
  135. package/dist/esm/cli/commands/composition/push.d.ts +0 -9
  136. package/dist/esm/cli/commands/composition/push.js +0 -1
  137. package/dist/esm/cli/commands/composition/remove.d.ts +0 -7
  138. package/dist/esm/cli/commands/composition/remove.js +0 -1
  139. package/dist/esm/cli/commands/composition/update.d.ts +0 -7
  140. package/dist/esm/cli/commands/composition/update.js +0 -1
  141. package/dist/esm/cli/commands/composition.d.ts +0 -2
  142. package/dist/esm/cli/commands/composition.js +0 -1
  143. package/dist/esm/cli/componentDefinitionEngineDataSource.d.ts +0 -7
  144. package/dist/esm/cli/componentDefinitionEngineDataSource.js +0 -1
  145. package/dist/esm/cli/componentInstanceEngineDataSource.d.ts +0 -9
  146. package/dist/esm/cli/componentInstanceEngineDataSource.js +0 -1
  147. package/dist/esm/cli/fileSyncEngineDataSource.d.ts +0 -9
  148. package/dist/esm/cli/fileSyncEngineDataSource.js +0 -1
  149. package/dist/esm/cli/package.d.ts +0 -7
  150. package/dist/esm/cli/package.js +0 -1
  151. package/dist/esm/cli/syncEngine.d.ts +0 -49
  152. package/dist/esm/cli/syncEngine.js +0 -1
  153. package/dist/esm/cli/syncEngineConsoleLogger.d.ts +0 -5
  154. package/dist/esm/cli/syncEngineConsoleLogger.js +0 -1
  155. package/dist/esm/cli/util.d.ts +0 -43
  156. package/dist/esm/cli/util.js +0 -1
  157. package/dist/esm/enhancement/EnhancerBuilder.d.ts +0 -66
  158. package/dist/esm/enhancement/EnhancerBuilder.js +0 -1
  159. package/dist/esm/enhancement/UniqueBatchEntries.d.ts +0 -17
  160. package/dist/esm/enhancement/UniqueBatchEntries.js +0 -1
  161. package/dist/esm/enhancement/batchEnhancer.d.ts +0 -39
  162. package/dist/esm/enhancement/batchEnhancer.js +0 -1
  163. package/dist/esm/enhancement/compose.d.ts +0 -6
  164. package/dist/esm/enhancement/compose.js +0 -1
  165. package/dist/esm/enhancement/createLimitPolicy.d.ts +0 -8
  166. package/dist/esm/enhancement/createLimitPolicy.js +0 -1
  167. package/dist/esm/enhancement/enhance.d.ts +0 -18
  168. package/dist/esm/enhancement/enhance.js +0 -1
  169. package/dist/esm/enhancement/localize.d.ts +0 -11
  170. package/dist/esm/enhancement/localize.js +0 -1
  171. package/dist/esm/enhancement/walkComponentTree.d.ts +0 -14
  172. package/dist/esm/enhancement/walkComponentTree.js +0 -1
  173. package/dist/esm/index.d.ts +0 -17
  174. package/dist/esm/index.js +0 -1
  175. package/dist/esm/preview/EventNames.d.ts +0 -1
  176. package/dist/esm/preview/EventNames.js +0 -0
  177. package/dist/esm/preview/createEventBus.d.ts +0 -6
  178. package/dist/esm/preview/createEventBus.js +0 -1
  179. package/dist/esm/preview/getChannelName.d.ts +0 -1
  180. package/dist/esm/preview/getChannelName.js +0 -1
  181. package/dist/esm/preview/subscribeToComposition.d.ts +0 -13
  182. package/dist/esm/preview/subscribeToComposition.js +0 -1
  183. package/dist/esm/types/componentDefinitions.d.ts +0 -90
  184. package/dist/esm/types/componentDefinitions.js +0 -0
  185. package/dist/esm/types/componentInstances.d.ts +0 -104
  186. package/dist/esm/types/componentInstances.js +0 -0
  187. package/dist/esm/types/enhancement.d.ts +0 -79
  188. package/dist/esm/types/enhancement.js +0 -0
  189. package/dist/esm/types/index.d.ts +0 -3
  190. package/dist/esm/types/index.js +0 -1
  191. package/dist/esm/utils/constants.d.ts +0 -20
  192. package/dist/esm/utils/constants.js +0 -1
  193. package/dist/esm/utils/isSystemComponentDefinition.d.ts +0 -2
  194. package/dist/esm/utils/isSystemComponentDefinition.js +0 -1
  195. package/dist/esm/utils/mapSlotToPersonalizedVariations.d.ts +0 -7
  196. package/dist/esm/utils/mapSlotToPersonalizedVariations.js +0 -1
package/LICENSE.txt CHANGED
@@ -1,2 +1,2 @@
1
- © 2021 Uniform Systems, Inc. All Rights Reserved.
1
+ © 2021 Uniform Systems, Inc. All Rights Reserved.
2
2
  See details of Uniform Systems, Inc. Master Subscription Agreement here: https://uniform.dev/eula
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- Uniform Canvas JavaScript SDK
2
-
3
- Contains the Canvas API client, Canvas CLI, and core typings.
4
-
5
- part of the [Uniform Platform](https://uniform.app). See our [documentation](https://docs.uniform.app) for more details.
1
+ Uniform Canvas JavaScript SDK
2
+
3
+ Contains the Canvas API client, Canvas CLI, and core typings.
4
+
5
+ part of the [Uniform Platform](https://uniform.app). See our [documentation](https://docs.uniform.app) for more details.
@@ -0,0 +1,2 @@
1
+ import h from"p-throttle";import A from"p-retry";function u({throttle:p={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=p?h(p):null;return function(s){let i=async()=>await s();if(t&&(i=t(i)),e){let n=i;i=()=>A(n,e)}return i()}}var y=async p=>await p();var c=class extends Error{constructor(e,t,o,s,i){super(`${e}
2
+ ${s}${i?" "+i:""} (${t} ${o})`);this.errorMessage=e;this.fetchMethod=t;this.fetchUri=o;this.statusCode=s;this.statusText=i;Object.setPrototypeOf(this,c.prototype)}},f=class{constructor(e){var o,s,i,n,r;if(!e.apiKey&&!e.bearerToken)throw new Error("You must provide an API key or a bearer token");let t=e.fetch;if(!t)if(typeof window!="undefined")t=window.fetch.bind(window);else if(typeof fetch!="undefined")t=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...e,fetch:t,apiHost:(o=e.apiHost)!=null?o:"https://uniform.app",apiKey:(s=e.apiKey)!=null?s:null,projectId:(i=e.projectId)!=null?i:null,bearerToken:(n=e.bearerToken)!=null?n:null,limitPolicy:(r=e.limitPolicy)!=null?r:u({})}}async getCompositionList(e){let{projectId:t}=this.options,o=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(o)}async getCompositionBySlug(e){let{projectId:t}=this.options,o=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(o)}async getCompositionById(e){let{projectId:t}=this.options,o=this.createUrl("/api/v1/canvas",{...e,projectId:t});return await this.apiClient(o)}async updateComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(e){let t=this.createUrl("/api/v1/canvas");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async getComponentDefinitions(e){let{projectId:t}=this.options,o=this.createUrl("/api/v1/canvas-definitions",{...e,projectId:t});return await this.apiClient(o)}async updateComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(e){let t=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(e,t){return this.options.limitPolicy(async()=>{var i;let o=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},s=await this.options.fetch(e.toString(),{...t,headers:{...t==null?void 0:t.headers,...o}});if(!s.ok){let n="";try{let r=await s.text();try{let a=JSON.parse(r);a.errorMessage?n=Array.isArray(a.errorMessage)?a.errorMessage.join(", "):a.errorMessage:n=r}catch(a){n=r}}catch(r){n="General error"}throw new c(n,(i=t==null?void 0:t.method)!=null?i:"GET",e.toString(),s.status)}return(t==null?void 0:t.expectNoContent)?null:await s.json()})}createUrl(e,t){let o=new URL(`${this.options.apiHost}${e}`);return Object.entries(t!=null?t:{}).forEach(([s,i])=>{var n;typeof i!==void 0&&i!==null&&o.searchParams.append(s,(n=i==null?void 0:i.toString())!=null?n:"")}),o}};var S="$personalization",L="$test",g="$localization",E="intentTag",w="locale",x="pz",_="test",j="localized",b=0,U=64,v="$pzCrit",D="$enr";export{u as a,y as b,c,f as d,S as e,L as f,g,E as h,w as i,x as j,_ as k,j as l,b as m,U as n,v as o,D as p};
@@ -0,0 +1,14 @@
1
+ import { UniformCLIPlugin } from '@uniformdev/cli';
2
+ import { o as ComponentDefinition, d as CompositionAPIResponse } from '../createEventBus-ca90547e';
3
+ import 'pusher-js';
4
+
5
+ declare type CanvasPackage = {
6
+ components?: Array<ComponentDefinition>;
7
+ compositions?: Array<CompositionAPIResponse>;
8
+ };
9
+ declare function readCanvasPackage(filename: string, assertExists: boolean): CanvasPackage;
10
+ declare function writeCanvasPackage(filename: string, packageContents: CanvasPackage): void;
11
+
12
+ declare const uniformCLI: UniformCLIPlugin;
13
+
14
+ export { CanvasPackage, readCanvasPackage, uniformCLI, writeCanvasPackage };
@@ -0,0 +1,4 @@
1
+ var Ge=Object.create;var J=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var oe=e=>J(e,"__esModule",{value:!0});var Ye=(e,t)=>{for(var o in t)J(e,o,{get:t[o],enumerable:!0})},ie=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Je(t))!ze.call(e,n)&&(o||n!=="default")&&J(e,n,{get:()=>t[n],enumerable:!(i=He(t,n))||i.enumerable});return e},y=(e,t)=>ie(oe(J(e!=null?Ge(Ke(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),qe=(e=>(t,o)=>e&&e.get(t)||(o=ie(oe({}),t,1),e&&e.set(t,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var Ze={};Ye(Ze,{readCanvasPackage:()=>j,uniformCLI:()=>Be,writeCanvasPackage:()=>G});var We=y(require("yargs"));var Ie=y(require("yargs"));var ne=y(require("p-throttle")),re=y(require("p-retry"));function se({throttle:e={interval:1e3,limit:10},retry:t={retries:1,factor:1.66}}){let o=e?(0,ne.default)(e):null;return function(n){let r=async()=>await n();if(o&&(r=o(r)),t){let a=r;r=()=>(0,re.default)(a,t)}return r()}}var K=class extends Error{constructor(t,o,i,n,r){super(`${t}
2
+ ${n}${r?" "+r:""} (${o} ${i})`);this.errorMessage=t;this.fetchMethod=o;this.fetchUri=i;this.statusCode=n;this.statusText=r;Object.setPrototypeOf(this,K.prototype)}},d=class{constructor(t){var i,n,r,a,s;if(!t.apiKey&&!t.bearerToken)throw new Error("You must provide an API key or a bearer token");let o=t.fetch;if(!o)if(typeof window!="undefined")o=window.fetch.bind(window);else if(typeof fetch!="undefined")o=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...t,fetch:o,apiHost:(i=t.apiHost)!=null?i:"https://uniform.app",apiKey:(n=t.apiKey)!=null?n:null,projectId:(r=t.projectId)!=null?r:null,bearerToken:(a=t.bearerToken)!=null?a:null,limitPolicy:(s=t.limitPolicy)!=null?s:se({})}}async getCompositionList(t){let{projectId:o}=this.options,i=this.createUrl("/api/v1/canvas",{...t,projectId:o});return await this.apiClient(i)}async getCompositionBySlug(t){let{projectId:o}=this.options,i=this.createUrl("/api/v1/canvas",{...t,projectId:o});return await this.apiClient(i)}async getCompositionById(t){let{projectId:o}=this.options,i=this.createUrl("/api/v1/canvas",{...t,projectId:o});return await this.apiClient(i)}async updateComposition(t){let o=this.createUrl("/api/v1/canvas");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(t){let o=this.createUrl("/api/v1/canvas");await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async getComponentDefinitions(t){let{projectId:o}=this.options,i=this.createUrl("/api/v1/canvas-definitions",{...t,projectId:o});return await this.apiClient(i)}async updateComponentDefinition(t){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(t){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async apiClient(t,o){return this.options.limitPolicy(async()=>{var r;let i=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},n=await this.options.fetch(t.toString(),{...o,headers:{...o==null?void 0:o.headers,...i}});if(!n.ok){let a="";try{let s=await n.text();try{let p=JSON.parse(s);p.errorMessage?a=Array.isArray(p.errorMessage)?p.errorMessage.join(", "):p.errorMessage:a=s}catch(p){a=s}}catch(s){a="General error"}throw new K(a,(r=o==null?void 0:o.method)!=null?r:"GET",t.toString(),n.status)}return(o==null?void 0:o.expectNoContent)?null:await n.json()})}createUrl(t,o){let i=new URL(`${this.options.apiHost}${t}`);return Object.entries(o!=null?o:{}).forEach(([n,r])=>{var a;typeof r!==void 0&&r!==null&&i.searchParams.append(n,(a=r==null?void 0:r.toString())!=null?a:"")}),i}};var z=require("js-yaml"),pe=require("fs"),te=require("path"),ce=require("fs");var ae=0,ee=64;var me=y(require("p-limit"));function l(e){var t,o;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(o=(t=process.env.CANVAS_CLI_API_KEY)!=null?t:process.env.UPM_CLI_API_KEY)!=null?o:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"})}function f(e){var t,o;return e.option("project",{describe:"Uniform project ID. Defaults to CANVAS_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(o=(t=process.env.CANVAS_CLI_PROJECT_ID)!=null?t:process.env.UPM_CLI_PROJECT_ID)!=null?o:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function S(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function I(e){return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes",default:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function D(e){let t=(0,te.extname)(e);return t===".yaml"||t===".yml"||t===".json"}function P(e,t,o){let i;if(o&&!t){let n=(0,te.extname)(o);n===".yaml"||n===".yml"?t="yaml":n===".json"&&(t="json")}else if(!t)throw new Error("Format must be specified when no filename is passed");switch(t){case"json":i=JSON.stringify(e,null,2);break;case"yaml":i=(0,z.dump)(e);break;default:throw new Error(`Unsupported format: ${t}`)}o?(0,pe.writeFileSync)(o,i,"utf8"):console.log(i)}function v(e){let t=(0,ce.readFileSync)(e,"utf8");return(0,z.load)(t,{filename:e,json:!0})}function Y(e){let t={...e};return delete t.projectId,delete t.state,t}function w(e){return e.option("state",{type:"string",describe:"Composition state to fetch.",choices:["preview","published"],default:"preview"})}async function*q(e,t){let o=t.pageSize||100,i=0,n=[];do{n=await e(i,o);for(let r of n)yield r;i+=o}while(n.length===o)}function E(e){let t=Number(e);if(!isNaN(t))return t;if(!e)return ee;if(typeof e!="string")throw new Error('state must be "published", "preview", or a number');return e==="preview"?ae:ee}var T=(0,me.default)(8);var de=y(require("isomorphic-unfetch")),le={command:"get <id>",describe:"Fetch a component definition",builder:e=>S(l(f(e.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"})))),handler:async({apiHost:e,apiKey:t,id:o,format:i,project:n,filename:r})=>{let s=await new d({apiKey:t,apiHost:e,fetch:de.default,projectId:n}).getComponentDefinitions({componentId:o,limit:1});s.componentDefinitions.length===0?(console.error("Component did not exist"),process.exit(1)):P(s.componentDefinitions[0],i,r)}};var fe=y(require("isomorphic-unfetch")),ue={command:"list",describe:"List component definitions",aliases:["ls"],builder:e=>S(l(f(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20}})))),handler:async({apiHost:e,apiKey:t,limit:o,offset:i,format:n,filename:r,project:a})=>{let p=await new d({apiKey:t,apiHost:e,fetch:fe.default,projectId:a}).getComponentDefinitions({limit:o,offset:i});P(p.componentDefinitions,n,r)}};var Ae=y(require("isomorphic-unfetch"));var V=require("diff"),ge=y(require("lodash.isequalwith"));async function x({source:e,target:t,compareContents:o=(s,p)=>(0,ge.default)(s.object,p.object,(c,g,C)=>C==="created"||C==="updated"?!0:void 0),mode:i,allowEmptySource:n=!1,whatIf:r=!1,log:a=()=>{}}){var g,C;let s=new Map;for await(let u of t.objects)s.set(u.id,u);let p=[],c=!1;for await(let u of e.objects){c=!0;let A=u.id,O=s.get(A);if(O){if(!o(u,O)&&(i==="createOrUpdate"||i==="mirror")){let b=async(h,H)=>{var $;r||await t.writeObject(h),a({action:"update",id:A,providerId:h.providerId,displayName:($=h.displayName)!=null?$:h.providerId,whatIf:r,diff:(0,V.diffJson)(H.object,h.object)})};p.push(b(u,O))}s.delete(A)}else{let b=async(h,H)=>{var $;r||await t.writeObject(h),a({action:"create",id:H,providerId:H,displayName:($=h.displayName)!=null?$:h.providerId,whatIf:r,diff:(0,V.diffLines)("",JSON.stringify(h.object,null,2))})};p.push(b(u,A))}}if(await Promise.all(p),i==="mirror"){if(!c&&!n)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let u=[];s.forEach(async A=>{let O=async b=>{var h;r||await t.deleteObject(b.providerId),a({action:"delete",id:b.id,providerId:b.providerId,displayName:(h=b.displayName)!=null?h:b.providerId,whatIf:r,diff:(0,V.diffLines)(JSON.stringify(b.object,null,2),"")})};u.push(O(A))}),await Promise.all(u)}await Promise.all([(g=e.onSyncComplete)==null?void 0:g.call(e,!1),(C=t.onSyncComplete)==null?void 0:C.call(t,!0)])}var Ce=y(require("chalk")),B=require("fs"),Z=require("fs/promises"),W=require("path");async function M({directory:e,format:t="yaml",selectIdentifier:o,selectDisplayName:i=o}){(0,B.existsSync)(e)||(0,B.mkdirSync)(e,{recursive:!0});let r=await(0,Z.readdir)(e,"utf-8"),a=new Set(r.filter(c=>{let g=(0,W.extname)(c);return g===".json"||g===".yaml"||g===".yml"})),s=c=>(0,W.join)(e,`${c}.${t}`);async function*p(){for(let c of a){let g=(0,W.join)(e,c);try{let C=await v(g);yield{id:o(C),displayName:i(C),providerId:g,object:C}}catch(C){throw console.error(Ce.default.red(`Failed to read ${g}, data is likely invalid.
3
+ ${C==null?void 0:C.message}`)),C}}}return{objects:p(),deleteObject:async c=>{await(0,Z.unlink)(c)},writeObject:async c=>{P(c.object,t,s(c.id))}}}var R=e=>e.id,L=e=>`${e.name} (pid: ${e.id})`;function Q({client:e}){async function*t(){let o=q(async(i,n)=>(await e.getComponentDefinitions({limit:n,offset:i})).componentDefinitions,{pageSize:100});for await(let i of o)yield{id:R(i),displayName:L(i),providerId:i.id,object:i}}return{objects:t(),deleteObject:async o=>{await e.removeComponentDefinition({componentId:o})},writeObject:async o=>{await e.updateComponentDefinition({componentDefinition:o.object})}}}var F=y(require("chalk"));function N({diffMode:e}){return function({action:o,displayName:i,whatIf:n,diff:r}){let a="";switch(o){case"create":a=F.default.green("[A]");break;case"update":a=F.default.white("[U]");break;case"delete":a=F.default.yellow("[D]");break}let s="";(e==="on"||e==="update"&&o==="update")&&(s=`
4
+ `+r.map(p=>p.added?F.default.green(p.value):p.removed?F.default.red(p.value):p.value).join("")),console.log(`${n?F.default.gray("[WHATIF]"):""}${a} ${i}${s}`)}}var ye=y(require("fs"));function j(e,t){if(!t&&!ye.default.existsSync(e))return{};let o=v(e);if(typeof o!="object")throw new Error(`Package ${e} does not appear valid.`);return o}function G(e,t){P(t,void 0,e)}async function k({objects:e,selectIdentifier:t,selectDisplayName:o=t,onSyncComplete:i}){let n=e.reduce((s,p)=>{let c=t(p);if(s[c])throw new Error(`Identifier ${c} was not unique.`);return s[c]={id:c,object:p,providerId:c,displayName:o(p)},s},{});async function*r(){for(let s of Object.values(n))yield s}function a(){return Object.entries(n).sort((s,p)=>s[0].localeCompare(p[0])).map(s=>s[1].object)}return{objects:r(),deleteObject:async s=>{delete n[s]},writeObject:async s=>{let p=t(s.object);n[p]=s},extractCurrent:a,onSyncComplete:i?s=>i(s,a()):void 0}}var he={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:e=>l(f(I(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:t,directory:o,format:i,mode:n,whatIf:r,project:a,diff:s})=>{var u;let p=new d({apiKey:t,apiHost:e,fetch:Ae.default,projectId:a,limitPolicy:T}),c=Q({client:p}),g;if(D(o)){let A=j(o,!1);g=await k({objects:(u=A.components)!=null?u:[],selectIdentifier:R,selectDisplayName:L,onSyncComplete:async(O,b)=>{A.components=b,G(o,A)}})}else g=await M({directory:o,selectIdentifier:R,selectDisplayName:L,format:i});await x({source:c,target:g,mode:n,whatIf:r,log:N({diffMode:s})})}};var be=y(require("isomorphic-unfetch"));var Oe={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Optimize",builder:e=>l(f(I(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:t,directory:o,mode:i,whatIf:n,project:r,diff:a})=>{var C;let s=new d({apiKey:t,apiHost:e,fetch:be.default,projectId:r,limitPolicy:T}),p;if(D(o)){let u=j(o,!0);p=await k({objects:(C=u.components)!=null?C:[],selectIdentifier:R,selectDisplayName:L})}else p=await M({directory:o,selectIdentifier:R,selectDisplayName:L});let g=Q({client:s});await x({source:p,target:g,mode:i,whatIf:n,log:N({diffMode:a})})}};var Pe=y(require("isomorphic-unfetch")),we={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:e=>l(f(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"}))),handler:async({apiHost:e,apiKey:t,id:o,project:i})=>{await new d({apiKey:t,apiHost:e,fetch:Pe.default,projectId:i}).removeComponentDefinition({componentId:o})}};var je=y(require("isomorphic-unfetch")),Se={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:e=>l(f(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"}))),handler:async({apiHost:e,apiKey:t,filename:o,project:i})=>{let n=new d({apiKey:t,apiHost:e,fetch:je.default,projectId:i}),r=v(o);await n.updateComponentDefinition({componentDefinition:r})}};var De={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:e=>e.command(he).command(Oe).command(le).command(we).command(ue).command(Se).demandCommand(),handler:()=>Ie.default.help()};var $e=y(require("yargs"));var ve=y(require("isomorphic-unfetch")),Ee={command:"get <id>",describe:"Fetch a composition",builder:e=>S(l(f(w(e.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:t,id:o,format:i,filename:n,state:r,project:a,resolvePatterns:s})=>{let p=new d({apiKey:t,apiHost:e,fetch:ve.default,projectId:a}),c=Y(await p.getCompositionById({compositionId:o,state:E(r),skipPatternResolution:!s}));P(c,i,n)}};var Te=y(require("isomorphic-unfetch")),xe={command:"list",describe:"List compositions",aliases:["ls"],builder:e=>S(l(f(w(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20},resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:t,limit:o,offset:i,format:n,filename:r,project:a,state:s,resolvePatterns:p})=>{let g=await new d({apiKey:t,apiHost:e,fetch:Te.default,projectId:a}).getCompositionList({limit:o,offset:i,state:E(s),skipPatternResolution:!p});P(g.compositions,n,r)}};var Me=y(require("isomorphic-unfetch"));var _=e=>e.composition._id,U=e=>{var t,o;return`${(o=(t=e.composition._name)!=null?t:e.composition._slug)!=null?o:e.composition._id} (pid: ${e.composition._id})`};function X({client:e,state:t}){let o=E(t);async function*i(){let n=q(async(r,a)=>(await e.getCompositionList({limit:a,offset:r,state:o,skipPatternResolution:!0})).compositions,{pageSize:100});for await(let r of n)yield{id:_(r),displayName:U(r),providerId:r.composition._id,object:Y(r)}}return{objects:i(),deleteObject:async n=>{await e.removeComposition({compositionId:n})},writeObject:async n=>{await e.updateComposition({...n.object,state:o})}}}var Re={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:e=>l(f(w(I(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:t,directory:o,format:i,mode:n,whatIf:r,state:a,project:s,diff:p})=>{var A;let c=new d({apiKey:t,apiHost:e,fetch:Me.default,projectId:s,limitPolicy:T}),g=X({client:c,state:a}),C=D(o),u;if(C){let O=j(o,!1);u=await k({objects:(A=O==null?void 0:O.compositions)!=null?A:[],selectIdentifier:_,selectDisplayName:U,onSyncComplete:async(b,h)=>{O.compositions=h,G(o,O)}})}else u=await M({directory:o,selectIdentifier:_,selectDisplayName:U,format:i});await x({source:g,target:u,mode:n,whatIf:r,log:N({diffMode:p})})}};var Le=y(require("isomorphic-unfetch"));var Ne={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Optimize",builder:e=>l(f(w(I(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:t,directory:o,mode:i,whatIf:n,state:r,project:a,diff:s})=>{var u;let p=new d({apiKey:t,apiHost:e,fetch:Le.default,projectId:a,limitPolicy:T}),c;if(D(o)){let A=j(o,!0);c=await k({objects:(u=A.compositions)!=null?u:[],selectIdentifier:_,selectDisplayName:U})}else c=await M({directory:o,selectIdentifier:_,selectDisplayName:U});let C=X({client:p,state:r});await x({source:c,target:C,mode:i,whatIf:n,log:N({diffMode:s})})}};var ke=y(require("isomorphic-unfetch")),_e={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:e=>l(f(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"}))),handler:async({apiHost:e,apiKey:t,id:o,project:i})=>{await new d({apiKey:t,apiHost:e,fetch:ke.default,projectId:i}).removeComposition({compositionId:o})}};var Ue=y(require("isomorphic-unfetch")),Fe={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:e=>l(f(w(e.positional("filename",{demandOption:!0,describe:"Composition file to put"})))),handler:async({apiHost:e,apiKey:t,filename:o,project:i,state:n})=>{let r=new d({apiKey:t,apiHost:e,fetch:Ue.default,projectId:i}),a=v(o);await r.updateComposition({...a,state:E(n)})}};var Ve={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:e=>e.command(Re).command(Ne).command(Ee).command(_e).command(xe).command(Fe).demandCommand(),handler:()=>{$e.default.help()}};var Be={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:e=>e.command(Ve).command(De).demandCommand(),handler:()=>{We.default.showHelp()}}]};module.exports=qe(Ze);0&&(module.exports={readCanvasPackage,uniformCLI,writeCanvasPackage});
@@ -0,0 +1,3 @@
1
+ import{d as c,m as Y,n as V}from"../chunk-A4MBTKCQ.mjs";import We from"yargs";import xe from"yargs";import{dump as le,load as fe}from"js-yaml";import{writeFileSync as ge}from"fs";import{extname as B}from"path";import{readFileSync as ue}from"fs";import Ce from"p-limit";function f(e){var o,t;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(t=(o=process.env.CANVAS_CLI_API_KEY)!=null?o:process.env.UPM_CLI_API_KEY)!=null?t:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"})}function g(e){var o,t;return e.option("project",{describe:"Uniform project ID. Defaults to CANVAS_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(t=(o=process.env.CANVAS_CLI_PROJECT_ID)!=null?o:process.env.UPM_CLI_PROJECT_ID)!=null?t:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function S(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function P(e){return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes",default:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function D(e){let o=B(e);return o===".yaml"||o===".yml"||o===".json"}function w(e,o,t){let i;if(t&&!o){let n=B(t);n===".yaml"||n===".yml"?o="yaml":n===".json"&&(o="json")}else if(!o)throw new Error("Format must be specified when no filename is passed");switch(o){case"json":i=JSON.stringify(e,null,2);break;case"yaml":i=le(e);break;default:throw new Error(`Unsupported format: ${o}`)}t?ge(t,i,"utf8"):console.log(i)}function v(e){let o=ue(e,"utf8");return fe(o,{filename:e,json:!0})}function G(e){let o={...e};return delete o.projectId,delete o.state,o}function O(e){return e.option("state",{type:"string",describe:"Composition state to fetch.",choices:["preview","published"],default:"preview"})}async function*J(e,o){let t=o.pageSize||100,i=0,n=[];do{n=await e(i,t);for(let s of n)yield s;i+=t}while(n.length===t)}function I(e){let o=Number(e);if(!isNaN(o))return o;if(!e)return V;if(typeof e!="string")throw new Error('state must be "published", "preview", or a number');return e==="preview"?Y:V}var E=Ce(8);import ye from"isomorphic-unfetch";var q={command:"get <id>",describe:"Fetch a component definition",builder:e=>S(f(g(e.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"})))),handler:async({apiHost:e,apiKey:o,id:t,format:i,project:n,filename:s})=>{let r=await new c({apiKey:o,apiHost:e,fetch:ye,projectId:n}).getComponentDefinitions({componentId:t,limit:1});r.componentDefinitions.length===0?(console.error("Component did not exist"),process.exit(1)):w(r.componentDefinitions[0],i,s)}};import be from"isomorphic-unfetch";var Q={command:"list",describe:"List component definitions",aliases:["ls"],builder:e=>S(f(g(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20}})))),handler:async({apiHost:e,apiKey:o,limit:t,offset:i,format:n,filename:s,project:m})=>{let a=await new c({apiKey:o,apiHost:e,fetch:be,projectId:m}).getComponentDefinitions({limit:t,offset:i});w(a.componentDefinitions,n,s)}};import Ie from"isomorphic-unfetch";import{diffJson as Ae,diffLines as X}from"diff";import he from"lodash.isequalwith";async function M({source:e,target:o,compareContents:t=(r,a)=>he(r.object,a.object,(p,C,y)=>y==="created"||y==="updated"?!0:void 0),mode:i,allowEmptySource:n=!1,whatIf:s=!1,log:m=()=>{}}){var C,y;let r=new Map;for await(let u of o.objects)r.set(u.id,u);let a=[],p=!1;for await(let u of e.objects){p=!0;let b=u.id,j=r.get(b);if(j){if(!t(u,j)&&(i==="createOrUpdate"||i==="mirror")){let h=async(A,$)=>{var W;s||await o.writeObject(A),m({action:"update",id:b,providerId:A.providerId,displayName:(W=A.displayName)!=null?W:A.providerId,whatIf:s,diff:Ae($.object,A.object)})};a.push(h(u,j))}r.delete(b)}else{let h=async(A,$)=>{var W;s||await o.writeObject(A),m({action:"create",id:$,providerId:$,displayName:(W=A.displayName)!=null?W:A.providerId,whatIf:s,diff:X("",JSON.stringify(A.object,null,2))})};a.push(h(u,b))}}if(await Promise.all(a),i==="mirror"){if(!p&&!n)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let u=[];r.forEach(async b=>{let j=async h=>{var A;s||await o.deleteObject(h.providerId),m({action:"delete",id:h.id,providerId:h.providerId,displayName:(A=h.displayName)!=null?A:h.providerId,whatIf:s,diff:X(JSON.stringify(h.object,null,2),"")})};u.push(j(b))}),await Promise.all(u)}await Promise.all([(C=e.onSyncComplete)==null?void 0:C.call(e,!1),(y=o.onSyncComplete)==null?void 0:y.call(o,!0)])}import je from"chalk";import{existsSync as we,mkdirSync as Oe}from"fs";import{readdir as Se,unlink as Pe}from"fs/promises";import{extname as De,join as Z}from"path";async function T({directory:e,format:o="yaml",selectIdentifier:t,selectDisplayName:i=t}){we(e)||Oe(e,{recursive:!0});let s=await Se(e,"utf-8"),m=new Set(s.filter(p=>{let C=De(p);return C===".json"||C===".yaml"||C===".yml"})),r=p=>Z(e,`${p}.${o}`);async function*a(){for(let p of m){let C=Z(e,p);try{let y=await v(C);yield{id:t(y),displayName:i(y),providerId:C,object:y}}catch(y){throw console.error(je.red(`Failed to read ${C}, data is likely invalid.
2
+ ${y==null?void 0:y.message}`)),y}}}return{objects:a(),deleteObject:async p=>{await Pe(p)},writeObject:async p=>{w(p.object,o,r(p.id))}}}var x=e=>e.id,F=e=>`${e.name} (pid: ${e.id})`;function K({client:e}){async function*o(){let t=J(async(i,n)=>(await e.getComponentDefinitions({limit:n,offset:i})).componentDefinitions,{pageSize:100});for await(let i of t)yield{id:x(i),displayName:F(i),providerId:i.id,object:i}}return{objects:o(),deleteObject:async t=>{await e.removeComponentDefinition({componentId:t})},writeObject:async t=>{await e.updateComponentDefinition({componentDefinition:t.object})}}}import R from"chalk";function k({diffMode:e}){return function({action:t,displayName:i,whatIf:n,diff:s}){let m="";switch(t){case"create":m=R.green("[A]");break;case"update":m=R.white("[U]");break;case"delete":m=R.yellow("[D]");break}let r="";(e==="on"||e==="update"&&t==="update")&&(r=`
3
+ `+s.map(a=>a.added?R.green(a.value):a.removed?R.red(a.value):a.value).join("")),console.log(`${n?R.gray("[WHATIF]"):""}${m} ${i}${r}`)}}import ve from"fs";function L(e,o){if(!o&&!ve.existsSync(e))return{};let t=v(e);if(typeof t!="object")throw new Error(`Package ${e} does not appear valid.`);return t}function z(e,o){w(o,void 0,e)}async function _({objects:e,selectIdentifier:o,selectDisplayName:t=o,onSyncComplete:i}){let n=e.reduce((r,a)=>{let p=o(a);if(r[p])throw new Error(`Identifier ${p} was not unique.`);return r[p]={id:p,object:a,providerId:p,displayName:t(a)},r},{});async function*s(){for(let r of Object.values(n))yield r}function m(){return Object.entries(n).sort((r,a)=>r[0].localeCompare(a[0])).map(r=>r[1].object)}return{objects:s(),deleteObject:async r=>{delete n[r]},writeObject:async r=>{let a=o(r.object);n[a]=r},extractCurrent:m,onSyncComplete:i?r=>i(r,m()):void 0}}var ee={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:e=>f(g(P(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:o,directory:t,format:i,mode:n,whatIf:s,project:m,diff:r})=>{var u;let a=new c({apiKey:o,apiHost:e,fetch:Ie,projectId:m,limitPolicy:E}),p=K({client:a}),C;if(D(t)){let b=L(t,!1);C=await _({objects:(u=b.components)!=null?u:[],selectIdentifier:x,selectDisplayName:F,onSyncComplete:async(j,h)=>{b.components=h,z(t,b)}})}else C=await T({directory:t,selectIdentifier:x,selectDisplayName:F,format:i});await M({source:p,target:C,mode:n,whatIf:s,log:k({diffMode:r})})}};import Ee from"isomorphic-unfetch";var oe={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Optimize",builder:e=>f(g(P(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:o,directory:t,mode:i,whatIf:n,project:s,diff:m})=>{var y;let r=new c({apiKey:o,apiHost:e,fetch:Ee,projectId:s,limitPolicy:E}),a;if(D(t)){let u=L(t,!0);a=await _({objects:(y=u.components)!=null?y:[],selectIdentifier:x,selectDisplayName:F})}else a=await T({directory:t,selectIdentifier:x,selectDisplayName:F});let C=K({client:r});await M({source:a,target:C,mode:i,whatIf:n,log:k({diffMode:m})})}};import Me from"isomorphic-unfetch";var te={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:e=>f(g(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"}))),handler:async({apiHost:e,apiKey:o,id:t,project:i})=>{await new c({apiKey:o,apiHost:e,fetch:Me,projectId:i}).removeComponentDefinition({componentId:t})}};import Te from"isomorphic-unfetch";var ie={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:e=>f(g(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"}))),handler:async({apiHost:e,apiKey:o,filename:t,project:i})=>{let n=new c({apiKey:o,apiHost:e,fetch:Te,projectId:i}),s=v(t);await n.updateComponentDefinition({componentDefinition:s})}};var ne={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:e=>e.command(ee).command(oe).command(q).command(te).command(Q).command(ie).demandCommand(),handler:()=>xe.help()};import Re from"yargs";import Fe from"isomorphic-unfetch";var re={command:"get <id>",describe:"Fetch a composition",builder:e=>S(f(g(O(e.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:o,id:t,format:i,filename:n,state:s,project:m,resolvePatterns:r})=>{let a=new c({apiKey:o,apiHost:e,fetch:Fe,projectId:m}),p=G(await a.getCompositionById({compositionId:t,state:I(s),skipPatternResolution:!r}));w(p,i,n)}};import ke from"isomorphic-unfetch";var se={command:"list",describe:"List compositions",aliases:["ls"],builder:e=>S(f(g(O(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20},resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}}))))),handler:async({apiHost:e,apiKey:o,limit:t,offset:i,format:n,filename:s,project:m,state:r,resolvePatterns:a})=>{let C=await new c({apiKey:o,apiHost:e,fetch:ke,projectId:m}).getCompositionList({limit:t,offset:i,state:I(r),skipPatternResolution:!a});w(C.compositions,n,s)}};import Le from"isomorphic-unfetch";var U=e=>e.composition._id,N=e=>{var o,t;return`${(t=(o=e.composition._name)!=null?o:e.composition._slug)!=null?t:e.composition._id} (pid: ${e.composition._id})`};function H({client:e,state:o}){let t=I(o);async function*i(){let n=J(async(s,m)=>(await e.getCompositionList({limit:m,offset:s,state:t,skipPatternResolution:!0})).compositions,{pageSize:100});for await(let s of n)yield{id:U(s),displayName:N(s),providerId:s.composition._id,object:G(s)}}return{objects:i(),deleteObject:async n=>{await e.removeComposition({compositionId:n})},writeObject:async n=>{await e.updateComposition({...n.object,state:t})}}}var ae={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:e=>f(g(O(P(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:o,directory:t,format:i,mode:n,whatIf:s,state:m,project:r,diff:a})=>{var b;let p=new c({apiKey:o,apiHost:e,fetch:Le,projectId:r,limitPolicy:E}),C=H({client:p,state:m}),y=D(t),u;if(y){let j=L(t,!1);u=await _({objects:(b=j==null?void 0:j.compositions)!=null?b:[],selectIdentifier:U,selectDisplayName:N,onSyncComplete:async(h,A)=>{j.compositions=A,z(t,j)}})}else u=await T({directory:t,selectIdentifier:U,selectDisplayName:N,format:i});await M({source:C,target:u,mode:n,whatIf:s,log:k({diffMode:a})})}};import _e from"isomorphic-unfetch";var me={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Optimize",builder:e=>f(g(O(P(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:o,directory:t,mode:i,whatIf:n,state:s,project:m,diff:r})=>{var u;let a=new c({apiKey:o,apiHost:e,fetch:_e,projectId:m,limitPolicy:E}),p;if(D(t)){let b=L(t,!0);p=await _({objects:(u=b.compositions)!=null?u:[],selectIdentifier:U,selectDisplayName:N})}else p=await T({directory:t,selectIdentifier:U,selectDisplayName:N});let y=H({client:a,state:s});await M({source:p,target:y,mode:i,whatIf:n,log:k({diffMode:r})})}};import Ue from"isomorphic-unfetch";var pe={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:e=>f(g(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"}))),handler:async({apiHost:e,apiKey:o,id:t,project:i})=>{await new c({apiKey:o,apiHost:e,fetch:Ue,projectId:i}).removeComposition({compositionId:t})}};import Ne from"isomorphic-unfetch";var ce={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:e=>f(g(O(e.positional("filename",{demandOption:!0,describe:"Composition file to put"})))),handler:async({apiHost:e,apiKey:o,filename:t,project:i,state:n})=>{let s=new c({apiKey:o,apiHost:e,fetch:Ne,projectId:i}),m=v(t);await s.updateComposition({...m,state:I(n)})}};var de={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:e=>e.command(ae).command(me).command(re).command(pe).command(se).command(ce).demandCommand(),handler:()=>{Re.help()}};var qi={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:e=>e.command(de).command(ne).demandCommand(),handler:()=>{We.showHelp()}}]};export{L as readCanvasPackage,qi as uniformCLI,z as writeCanvasPackage};
@@ -0,0 +1,255 @@
1
+ import Pusher from 'pusher-js';
2
+
3
+ /** @deprecated use CANVAS_DRAFT_STATE and CANVAS_PUBLISHED_STATE instead */
4
+ declare type CompositionFetchState = 'preview' | 'published' | number;
5
+ /** The GET response from /api/v1/canvas when `component` or `slug` params are specified */
6
+ declare type CompositionAPIResponse = {
7
+ /** The state of the layout. See CANVAS_DRAFT_STATE and CANVAS_PUBLISHED_STATE. */
8
+ state: number;
9
+ /** The project ID that this layout data is part of */
10
+ projectId: string;
11
+ /** Layout data being read or written */
12
+ composition: RootComponentInstance;
13
+ /** Whether this composition is a pattern (can be referenced by other compositions) */
14
+ pattern: boolean;
15
+ /** Created date string for this definition */
16
+ created?: string;
17
+ /** Modified date string for this definition */
18
+ modified?: string;
19
+ };
20
+ /** Shape of the PUT request body for /api/v1/canvas */
21
+ declare type CompositionAPIPutRequest = Omit<CompositionAPIResponse, 'projectId'> & {
22
+ projectId: string;
23
+ };
24
+ /** Shape of the DELETE request body for /api/v1/canvas */
25
+ declare type CompositionAPIDeleteRequest = {
26
+ /** Public ID of the composition to delete */
27
+ compositionId: string;
28
+ /** Project ID that the composition lives on. */
29
+ projectId: string;
30
+ /** The state to delete. If unspecified, all states will be deleted. See CANVAS_DRAFT_STATE and CANVAS_PUBLISHED_STATE. */
31
+ state?: number;
32
+ };
33
+ /** The GET response from /api/v1/canvas when `component` or `slug` are not specified */
34
+ declare type CompositionListAPIResponse = {
35
+ compositions: Array<CompositionAPIResponse>;
36
+ };
37
+ /** Query parameter options for GET /api/v1/canvas */
38
+ declare type CompositionAPIOptions = {
39
+ /** Specify a single composition ID to fetch. Changes response from list to single. */
40
+ compositionId?: string;
41
+ /** Specify a single composition to fetch by slug. Changes response from list to single. */
42
+ slug?: string;
43
+ /** The project the composition(s) are on. */
44
+ projectId: string;
45
+ /** The component type to filter by */
46
+ type?: string;
47
+ /** Number of records to skip */
48
+ offset?: number;
49
+ /** Max number of records to return (defaults to 100) */
50
+ limit?: number;
51
+ /** State of compositions to fetch. Default = 'published' */
52
+ state?: number;
53
+ /**
54
+ * Signals a Canvas enhancer proxy to skip processing enhancements to the data and return raw data only.
55
+ * This improves performance if you do not require enhanced component data.
56
+ * If calling the Canvas API directly with no enhancer proxy, this has no effect.
57
+ */
58
+ skipEnhance?: boolean;
59
+ /**
60
+ * If true, any pattern references in the composition will be left unresolved.
61
+ * This is appropriate if you intend to serialize the composition data without pattern
62
+ * data embedded into it, and serialize the pattern data separately.
63
+ */
64
+ skipPatternResolution?: boolean;
65
+ };
66
+ declare type ComponentParameter<TValue = unknown> = {
67
+ /** The type of the parameter. Determines how it is displayed when editing, and tells the consumer how to process it. */
68
+ type: string;
69
+ /**
70
+ * The value of the parameter.
71
+ * Any JSON-serializable value is acceptable.
72
+ */
73
+ value: TValue;
74
+ };
75
+ /**
76
+ * Defines the shape of a component instance served by the composition API.
77
+ */
78
+ declare type ComponentInstance = {
79
+ /** Type of the component instance (public_id of its definition) */
80
+ type: string;
81
+ /** Component parameter values for the component instance */
82
+ parameters?: Record<string, ComponentParameter>;
83
+ /** Public ID of alternate visual appearance for this component, if any selected */
84
+ variant?: string;
85
+ /** Slots containing any sub-components */
86
+ slots?: Record<string, ComponentInstance[]>;
87
+ /** Data for the component instance, provided by a component enhancer. Never set in unenhanced data. */
88
+ data?: Record<string, unknown>;
89
+ /** Indicates this component instance should be sourced from a pattern library pattern */
90
+ _pattern?: string;
91
+ /**
92
+ * If an error occurs resolving a pattern reference, it is left unresolved and this property is set to indicate why.
93
+ * CYCLIC: A cyclic pattern graph was detected, which could not be resolved because it would cause an infinite loop.
94
+ * NOTFOUND: The pattern ID referenced could not be found. It may have been deleted, or not be published yet.
95
+ */
96
+ _patternError?: 'CYCLIC' | 'NOTFOUND';
97
+ };
98
+ /** Defines the shape of the root component in a composition */
99
+ declare type RootComponentInstance = ComponentInstance & {
100
+ /** The public UUID of the composition. */
101
+ _id?: string;
102
+ /** Slug pattern of this component. */
103
+ _slug?: string | null;
104
+ /** Friendly name of this component. */
105
+ _name?: string;
106
+ };
107
+
108
+ /** Shape of the GET response from /api/v1/canvas-definitions */
109
+ declare type ComponentDefinitionAPIResponse = {
110
+ componentDefinitions: Array<ComponentDefinition>;
111
+ };
112
+ /** Shape of the PUT request body for /api/v1/canvas-definitions */
113
+ declare type ComponentDefinitionAPIPutRequest = {
114
+ componentDefinition: CreatingComponentDefinition;
115
+ projectId: string;
116
+ };
117
+ /** Shape of the DELETE request body for /api/v1/canvas-definitions */
118
+ declare type ComponentDefinitionAPIDeleteRequest = {
119
+ /** Public ID of the component definition to delete */
120
+ componentId: string;
121
+ /** Project ID that the component definition lives on */
122
+ projectId: string;
123
+ };
124
+ /** Query parameter options for GET /api/v1/canvas-definitions */
125
+ declare type ComponentDefinitionListAPIOptions = {
126
+ /** Limit list to one result by ID (response remains an array) */
127
+ componentId?: string;
128
+ /** Number of records to skip */
129
+ offset?: number;
130
+ /** Max number of records to return (defaults to 100) */
131
+ limit?: number;
132
+ projectId: string;
133
+ };
134
+ /** The definition of a component parameter */
135
+ declare type ComponentDefinitionParameter<TConfig = unknown> = {
136
+ /** Public ID of the parameter (used in code). Do not change after creation. */
137
+ id: string;
138
+ /** Friendly name of the parameter */
139
+ name: string;
140
+ /** Type name of the parameter (provided by a Uniform integration) */
141
+ type: string;
142
+ /** The configuration object for the type (type-specific) */
143
+ typeConfig?: TConfig;
144
+ };
145
+ /** The definition of a component variant */
146
+ declare type ComponentDefinitionVariant = {
147
+ /** Public ID of the variant (used in code). Do not change after creation. */
148
+ id: string;
149
+ /** Friendly name of the variant */
150
+ name: string;
151
+ };
152
+ /** The definition of a component slug */
153
+ declare type ComponentDefinitionSlugSettings = {
154
+ /**
155
+ * Is slug required
156
+ * no: slug is optional
157
+ * yes: slug is required
158
+ * disabled: slug is disabled and will not be shown in the editor
159
+ * @default no
160
+ */
161
+ required?: 'no' | 'yes' | 'disabled';
162
+ /** Slug uniqueness configuration.
163
+ * no = no unique constraint
164
+ * local = must be unique within this component type
165
+ * global = must be unique across all component types
166
+ * @default no
167
+ */
168
+ unique?: 'no' | 'local' | 'global';
169
+ /** Regular expression slugs must match */
170
+ regularExpression?: string;
171
+ /**
172
+ * Custom error message when regular expression validation fails.
173
+ * Has no effect if `regularExpression` is not set.
174
+ */
175
+ regularExpressionMessage?: string;
176
+ };
177
+ /** The definition of a named component slot that can contain other components */
178
+ declare type ComponentDefinitionSlot = {
179
+ /** Public ID of the slot (used in code). Do not change after creation. */
180
+ id: string;
181
+ /** Friendly name of the slot */
182
+ name: string;
183
+ /** Whether this slot inherits its allowed components from the parent slot it lives in. If true, allowedComponents is irrelevant. */
184
+ inheritAllowedComponents: boolean;
185
+ /** A list of component definition public IDs that are allowed in this named slot */
186
+ allowedComponents: Array<string>;
187
+ /** Minimum valid number of components in this slot */
188
+ minComponents?: number;
189
+ /** Maximum valid number of components in this slot */
190
+ maxComponents?: number;
191
+ };
192
+ /** Defines a component type that can live on a Composition */
193
+ declare type ComponentDefinition = {
194
+ /** Public ID of the component (used in code). Do not change after creation. */
195
+ id: string;
196
+ /** Friendly name of the component definition */
197
+ name: string;
198
+ /** Icon name for the component definition (e.g. 'screen') */
199
+ icon: string;
200
+ /**
201
+ * The public ID of the parameter whose value should be used to create a display title for this component in the UI.
202
+ * The parameter type must support being used as a title parameter for this to work.
203
+ */
204
+ titleParameter?: string | null;
205
+ /** Whether this component type can be the root of a composition. If false, this component is only used within slots on other components. */
206
+ canBeComposition?: boolean;
207
+ /** The parameters for this component. Parameters are key-value pairs that can be anything from text values to links to CMS entries. */
208
+ parameters?: Array<ComponentDefinitionParameter>;
209
+ /** The named slots for this component; placement areas where arrays of other components can be added. */
210
+ slots?: Array<ComponentDefinitionSlot>;
211
+ /** Default component instance value */
212
+ defaults?: ComponentInstance | null;
213
+ /** Named variants for this component; enables creation of visual variants that use the same parameter data/ */
214
+ variants?: Array<ComponentDefinitionVariant>;
215
+ /** Setting for slug validation */
216
+ slugSettings?: ComponentDefinitionSlugSettings;
217
+ /** Created date string for this definition */
218
+ created?: string;
219
+ /** Updated date string for this definition */
220
+ updated?: string;
221
+ /** Modified date string for this definition */
222
+ modified?: string;
223
+ };
224
+ /** Defines a component type that can live on a Composition, when it is being created or updated */
225
+ declare type CreatingComponentDefinition = Omit<Partial<ComponentDefinition>, 'created' | 'modified' | 'id' | 'name'> & {
226
+ id: string;
227
+ name: string;
228
+ };
229
+
230
+ /**
231
+ * Pusher-js is large (80k) and not tree shakable so it is always bundled if directly referenced,
232
+ * when it's only needed during preview mode. To avoid bundling it for all, we use an old-school
233
+ * write-a-script-tag hack to load it in a poor man's approximation of a dynamic import ;)
234
+ */
235
+ declare type ChannelSubscription = {
236
+ addEventHandler: (eventName: string, handler: (data: unknown) => void) => () => void;
237
+ unsubscribe: () => void;
238
+ };
239
+ declare type PreviewEventBus = {
240
+ subscribe: (channel: string) => ChannelSubscription;
241
+ };
242
+ declare global {
243
+ interface Window {
244
+ Pusher?: typeof Pusher;
245
+ __UNIFORM_EVENT_BUS__?: PreviewEventBus;
246
+ }
247
+ }
248
+ /**
249
+ * Creates an event bus client to receive updates from Canvas
250
+ * IMPORTANT: in a server-side context this will always return undefined
251
+ * IMPORTANT: in a browser context this is cached in window and does not create multiple instances
252
+ */
253
+ declare function createEventBus(): Promise<PreviewEventBus | undefined>;
254
+
255
+ export { ComponentInstance as C, PreviewEventBus as P, RootComponentInstance as R, ComponentParameter as a, CompositionAPIOptions as b, CompositionListAPIResponse as c, CompositionAPIResponse as d, CompositionAPIPutRequest as e, CompositionAPIDeleteRequest as f, ComponentDefinitionListAPIOptions as g, ComponentDefinitionAPIResponse as h, ComponentDefinitionAPIPutRequest as i, ComponentDefinitionAPIDeleteRequest as j, ComponentDefinitionParameter as k, ComponentDefinitionVariant as l, ComponentDefinitionSlugSettings as m, ComponentDefinitionSlot as n, ComponentDefinition as o, CreatingComponentDefinition as p, CompositionFetchState as q, ChannelSubscription as r, createEventBus as s };