@uniformdev/canvas 12.0.1-alpha.87 → 12.2.1-alpha.107
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.
- package/LICENSE.txt +1 -1
- package/README.md +5 -5
- package/dist/chunk-FS5XXLSV.mjs +2 -0
- package/dist/cli/cli.d.ts +14 -0
- package/dist/cli/cli.js +4 -0
- package/dist/cli/cli.mjs +3 -0
- package/dist/createEventBus-39df132f.d.ts +253 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.esm.js +4 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +4 -0
- package/package.json +33 -33
- package/dist/cjs/CanvasClient.d.ts +0 -50
- package/dist/cjs/CanvasClient.js +0 -1
- package/dist/cjs/cli/arraySyncEngineDataSource.d.ts +0 -10
- package/dist/cjs/cli/arraySyncEngineDataSource.js +0 -1
- package/dist/cjs/cli/cli.d.ts +0 -3
- package/dist/cjs/cli/cli.js +0 -1
- package/dist/cjs/cli/commands/component/_util.d.ts +0 -3
- package/dist/cjs/cli/commands/component/_util.js +0 -1
- package/dist/cjs/cli/commands/component/get.d.ts +0 -7
- package/dist/cjs/cli/commands/component/get.js +0 -1
- package/dist/cjs/cli/commands/component/list.d.ts +0 -6
- package/dist/cjs/cli/commands/component/list.js +0 -1
- package/dist/cjs/cli/commands/component/pull.d.ts +0 -10
- package/dist/cjs/cli/commands/component/pull.js +0 -1
- package/dist/cjs/cli/commands/component/push.d.ts +0 -9
- package/dist/cjs/cli/commands/component/push.js +0 -1
- package/dist/cjs/cli/commands/component/remove.d.ts +0 -7
- package/dist/cjs/cli/commands/component/remove.js +0 -1
- package/dist/cjs/cli/commands/component/update.d.ts +0 -7
- package/dist/cjs/cli/commands/component/update.js +0 -1
- package/dist/cjs/cli/commands/component.d.ts +0 -2
- package/dist/cjs/cli/commands/component.js +0 -1
- package/dist/cjs/cli/commands/composition/_util.d.ts +0 -3
- package/dist/cjs/cli/commands/composition/_util.js +0 -1
- package/dist/cjs/cli/commands/composition/get.d.ts +0 -8
- package/dist/cjs/cli/commands/composition/get.js +0 -1
- package/dist/cjs/cli/commands/composition/list.d.ts +0 -8
- package/dist/cjs/cli/commands/composition/list.js +0 -1
- package/dist/cjs/cli/commands/composition/pull.d.ts +0 -10
- package/dist/cjs/cli/commands/composition/pull.js +0 -1
- package/dist/cjs/cli/commands/composition/push.d.ts +0 -9
- package/dist/cjs/cli/commands/composition/push.js +0 -1
- package/dist/cjs/cli/commands/composition/remove.d.ts +0 -7
- package/dist/cjs/cli/commands/composition/remove.js +0 -1
- package/dist/cjs/cli/commands/composition/update.d.ts +0 -7
- package/dist/cjs/cli/commands/composition/update.js +0 -1
- package/dist/cjs/cli/commands/composition.d.ts +0 -2
- package/dist/cjs/cli/commands/composition.js +0 -1
- package/dist/cjs/cli/componentDefinitionEngineDataSource.d.ts +0 -7
- package/dist/cjs/cli/componentDefinitionEngineDataSource.js +0 -1
- package/dist/cjs/cli/componentInstanceEngineDataSource.d.ts +0 -9
- package/dist/cjs/cli/componentInstanceEngineDataSource.js +0 -1
- package/dist/cjs/cli/fileSyncEngineDataSource.d.ts +0 -9
- package/dist/cjs/cli/fileSyncEngineDataSource.js +0 -1
- package/dist/cjs/cli/package.d.ts +0 -7
- package/dist/cjs/cli/package.js +0 -1
- package/dist/cjs/cli/syncEngine.d.ts +0 -49
- package/dist/cjs/cli/syncEngine.js +0 -1
- package/dist/cjs/cli/syncEngineConsoleLogger.d.ts +0 -5
- package/dist/cjs/cli/syncEngineConsoleLogger.js +0 -1
- package/dist/cjs/cli/util.d.ts +0 -43
- package/dist/cjs/cli/util.js +0 -1
- package/dist/cjs/enhancement/EnhancerBuilder.d.ts +0 -66
- package/dist/cjs/enhancement/EnhancerBuilder.js +0 -1
- package/dist/cjs/enhancement/UniqueBatchEntries.d.ts +0 -17
- package/dist/cjs/enhancement/UniqueBatchEntries.js +0 -1
- package/dist/cjs/enhancement/batchEnhancer.d.ts +0 -39
- package/dist/cjs/enhancement/batchEnhancer.js +0 -1
- package/dist/cjs/enhancement/compose.d.ts +0 -6
- package/dist/cjs/enhancement/compose.js +0 -1
- package/dist/cjs/enhancement/createLimitPolicy.d.ts +0 -8
- package/dist/cjs/enhancement/createLimitPolicy.js +0 -1
- package/dist/cjs/enhancement/enhance.d.ts +0 -18
- package/dist/cjs/enhancement/enhance.js +0 -1
- package/dist/cjs/enhancement/localize.d.ts +0 -11
- package/dist/cjs/enhancement/localize.js +0 -1
- package/dist/cjs/enhancement/walkComponentTree.d.ts +0 -14
- package/dist/cjs/enhancement/walkComponentTree.js +0 -1
- package/dist/cjs/index.d.ts +0 -16
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/preview/EventNames.d.ts +0 -1
- package/dist/cjs/preview/EventNames.js +0 -1
- package/dist/cjs/preview/createEventBus.d.ts +0 -6
- package/dist/cjs/preview/createEventBus.js +0 -1
- package/dist/cjs/preview/getChannelName.d.ts +0 -1
- package/dist/cjs/preview/getChannelName.js +0 -1
- package/dist/cjs/preview/subscribeToComposition.d.ts +0 -13
- package/dist/cjs/preview/subscribeToComposition.js +0 -1
- package/dist/cjs/types/componentDefinitions.d.ts +0 -90
- package/dist/cjs/types/componentDefinitions.js +0 -1
- package/dist/cjs/types/componentInstances.d.ts +0 -104
- package/dist/cjs/types/componentInstances.js +0 -1
- package/dist/cjs/types/enhancement.d.ts +0 -79
- package/dist/cjs/types/enhancement.js +0 -1
- package/dist/cjs/types/index.d.ts +0 -3
- package/dist/cjs/types/index.js +0 -1
- package/dist/cjs/utils/constants.d.ts +0 -20
- package/dist/cjs/utils/constants.js +0 -1
- package/dist/cjs/utils/isSystemComponentDefinition.d.ts +0 -2
- package/dist/cjs/utils/isSystemComponentDefinition.js +0 -1
- package/dist/cjs/utils/mapSlotToPersonalizedVariations.d.ts +0 -7
- package/dist/cjs/utils/mapSlotToPersonalizedVariations.js +0 -1
- package/dist/esm/CanvasClient.d.ts +0 -50
- package/dist/esm/CanvasClient.js +0 -1
- package/dist/esm/cli/arraySyncEngineDataSource.d.ts +0 -10
- package/dist/esm/cli/arraySyncEngineDataSource.js +0 -1
- package/dist/esm/cli/cli.d.ts +0 -3
- package/dist/esm/cli/cli.js +0 -1
- package/dist/esm/cli/commands/component/_util.d.ts +0 -3
- package/dist/esm/cli/commands/component/_util.js +0 -1
- package/dist/esm/cli/commands/component/get.d.ts +0 -7
- package/dist/esm/cli/commands/component/get.js +0 -1
- package/dist/esm/cli/commands/component/list.d.ts +0 -6
- package/dist/esm/cli/commands/component/list.js +0 -1
- package/dist/esm/cli/commands/component/pull.d.ts +0 -10
- package/dist/esm/cli/commands/component/pull.js +0 -1
- package/dist/esm/cli/commands/component/push.d.ts +0 -9
- package/dist/esm/cli/commands/component/push.js +0 -1
- package/dist/esm/cli/commands/component/remove.d.ts +0 -7
- package/dist/esm/cli/commands/component/remove.js +0 -1
- package/dist/esm/cli/commands/component/update.d.ts +0 -7
- package/dist/esm/cli/commands/component/update.js +0 -1
- package/dist/esm/cli/commands/component.d.ts +0 -2
- package/dist/esm/cli/commands/component.js +0 -1
- package/dist/esm/cli/commands/composition/_util.d.ts +0 -3
- package/dist/esm/cli/commands/composition/_util.js +0 -1
- package/dist/esm/cli/commands/composition/get.d.ts +0 -8
- package/dist/esm/cli/commands/composition/get.js +0 -1
- package/dist/esm/cli/commands/composition/list.d.ts +0 -8
- package/dist/esm/cli/commands/composition/list.js +0 -1
- package/dist/esm/cli/commands/composition/pull.d.ts +0 -10
- package/dist/esm/cli/commands/composition/pull.js +0 -1
- package/dist/esm/cli/commands/composition/push.d.ts +0 -9
- package/dist/esm/cli/commands/composition/push.js +0 -1
- package/dist/esm/cli/commands/composition/remove.d.ts +0 -7
- package/dist/esm/cli/commands/composition/remove.js +0 -1
- package/dist/esm/cli/commands/composition/update.d.ts +0 -7
- package/dist/esm/cli/commands/composition/update.js +0 -1
- package/dist/esm/cli/commands/composition.d.ts +0 -2
- package/dist/esm/cli/commands/composition.js +0 -1
- package/dist/esm/cli/componentDefinitionEngineDataSource.d.ts +0 -7
- package/dist/esm/cli/componentDefinitionEngineDataSource.js +0 -1
- package/dist/esm/cli/componentInstanceEngineDataSource.d.ts +0 -9
- package/dist/esm/cli/componentInstanceEngineDataSource.js +0 -1
- package/dist/esm/cli/fileSyncEngineDataSource.d.ts +0 -9
- package/dist/esm/cli/fileSyncEngineDataSource.js +0 -1
- package/dist/esm/cli/package.d.ts +0 -7
- package/dist/esm/cli/package.js +0 -1
- package/dist/esm/cli/syncEngine.d.ts +0 -49
- package/dist/esm/cli/syncEngine.js +0 -1
- package/dist/esm/cli/syncEngineConsoleLogger.d.ts +0 -5
- package/dist/esm/cli/syncEngineConsoleLogger.js +0 -1
- package/dist/esm/cli/util.d.ts +0 -43
- package/dist/esm/cli/util.js +0 -1
- package/dist/esm/enhancement/EnhancerBuilder.d.ts +0 -66
- package/dist/esm/enhancement/EnhancerBuilder.js +0 -1
- package/dist/esm/enhancement/UniqueBatchEntries.d.ts +0 -17
- package/dist/esm/enhancement/UniqueBatchEntries.js +0 -1
- package/dist/esm/enhancement/batchEnhancer.d.ts +0 -39
- package/dist/esm/enhancement/batchEnhancer.js +0 -1
- package/dist/esm/enhancement/compose.d.ts +0 -6
- package/dist/esm/enhancement/compose.js +0 -1
- package/dist/esm/enhancement/createLimitPolicy.d.ts +0 -8
- package/dist/esm/enhancement/createLimitPolicy.js +0 -1
- package/dist/esm/enhancement/enhance.d.ts +0 -18
- package/dist/esm/enhancement/enhance.js +0 -1
- package/dist/esm/enhancement/localize.d.ts +0 -11
- package/dist/esm/enhancement/localize.js +0 -1
- package/dist/esm/enhancement/walkComponentTree.d.ts +0 -14
- package/dist/esm/enhancement/walkComponentTree.js +0 -1
- package/dist/esm/index.d.ts +0 -16
- package/dist/esm/index.js +0 -1
- package/dist/esm/preview/EventNames.d.ts +0 -1
- package/dist/esm/preview/EventNames.js +0 -0
- package/dist/esm/preview/createEventBus.d.ts +0 -6
- package/dist/esm/preview/createEventBus.js +0 -1
- package/dist/esm/preview/getChannelName.d.ts +0 -1
- package/dist/esm/preview/getChannelName.js +0 -1
- package/dist/esm/preview/subscribeToComposition.d.ts +0 -13
- package/dist/esm/preview/subscribeToComposition.js +0 -1
- package/dist/esm/types/componentDefinitions.d.ts +0 -90
- package/dist/esm/types/componentDefinitions.js +0 -0
- package/dist/esm/types/componentInstances.d.ts +0 -104
- package/dist/esm/types/componentInstances.js +0 -0
- package/dist/esm/types/enhancement.d.ts +0 -79
- package/dist/esm/types/enhancement.js +0 -0
- package/dist/esm/types/index.d.ts +0 -3
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/utils/constants.d.ts +0 -20
- package/dist/esm/utils/constants.js +0 -1
- package/dist/esm/utils/isSystemComponentDefinition.d.ts +0 -2
- package/dist/esm/utils/isSystemComponentDefinition.js +0 -1
- package/dist/esm/utils/mapSlotToPersonalizedVariations.d.ts +0 -7
- package/dist/esm/utils/mapSlotToPersonalizedVariations.js +0 -1
@@ -1,20 +0,0 @@
|
|
1
|
-
/** Public ID of Canvas personalization component type */
|
2
|
-
export declare const CANVAS_PERSONALIZE_TYPE = "$personalization";
|
3
|
-
/** Public ID of Canvas A/B test component type */
|
4
|
-
export declare const CANVAS_TEST_TYPE = "$test";
|
5
|
-
/** Public ID of Canvas localization component type */
|
6
|
-
export declare const CANVAS_LOCALIZATION_TYPE = "$localization";
|
7
|
-
/** Public ID of the intent tag parameter on the Canvas personalization component type */
|
8
|
-
export declare const CANVAS_INTENT_TAG_PARAM = "intentTag";
|
9
|
-
/** Public ID of the locale parameter on Canvas components */
|
10
|
-
export declare const CANVAS_LOCALE_TAG_PARAM = "locale";
|
11
|
-
/** Name of the slot on CANVAS_PERSONALIZE_TYPE */
|
12
|
-
export declare const CANVAS_PERSONALIZE_SLOT = "pz";
|
13
|
-
/** Name of the slot on CANVAS_TEST_TYPE */
|
14
|
-
export declare const CANVAS_TEST_SLOT = "test";
|
15
|
-
/** Name of the slot on CANVAS_TEST_TYPE */
|
16
|
-
export declare const CANVAS_LOCALIZATION_SLOT = "localized";
|
17
|
-
/** Constant for a draft composition state. Subject to change. */
|
18
|
-
export declare const CANVAS_DRAFT_STATE = 0;
|
19
|
-
/** Constatnt for a published composition state. Subject to change. */
|
20
|
-
export declare const CANVAS_PUBLISHED_STATE = 64;
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CANVAS_PUBLISHED_STATE=exports.CANVAS_DRAFT_STATE=exports.CANVAS_LOCALIZATION_SLOT=exports.CANVAS_TEST_SLOT=exports.CANVAS_PERSONALIZE_SLOT=exports.CANVAS_LOCALE_TAG_PARAM=exports.CANVAS_INTENT_TAG_PARAM=exports.CANVAS_LOCALIZATION_TYPE=exports.CANVAS_TEST_TYPE=exports.CANVAS_PERSONALIZE_TYPE=void 0,exports.CANVAS_PERSONALIZE_TYPE="$personalization",exports.CANVAS_TEST_TYPE="$test",exports.CANVAS_LOCALIZATION_TYPE="$localization",exports.CANVAS_INTENT_TAG_PARAM="intentTag",exports.CANVAS_LOCALE_TAG_PARAM="locale",exports.CANVAS_PERSONALIZE_SLOT="pz",exports.CANVAS_TEST_SLOT="test",exports.CANVAS_LOCALIZATION_SLOT="localized",exports.CANVAS_DRAFT_STATE=0,exports.CANVAS_PUBLISHED_STATE=64;
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSystemComponentDefinition=void 0;var isSystemComponentDefinition=function(e){return e.startsWith("$")};exports.isSystemComponentDefinition=isSystemComponentDefinition;
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { PersonalizableListItem } from '@uniformdev/optimize-tracker-common';
|
2
|
-
import { ComponentInstance } from '../types/componentInstances';
|
3
|
-
/**
|
4
|
-
* Converts components in a slot into personalized variations (based on each component's intent tag in Canvas) suitable to pass to a personalize component
|
5
|
-
* Useful when implementing custom personalization settings for Canvas components.
|
6
|
-
*/
|
7
|
-
export declare function mapSlotToPersonalizedVariations(slot: ComponentInstance[] | undefined): Array<ComponentInstance & PersonalizableListItem>;
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var n,a=1,o=arguments.length;a<o;a++)for(var s in n=arguments[a])Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.mapSlotToPersonalizedVariations=void 0;var constants_1=require("./constants");function mapSlotToPersonalizedVariations(t){return t?t.map(function(t){return __assign(__assign({},t),{intentTag:null===(t=null===(t=t.parameters)||void 0===t?void 0:t[constants_1.CANVAS_INTENT_TAG_PARAM])||void 0===t?void 0:t.value})}):[]}exports.mapSlotToPersonalizedVariations=mapSlotToPersonalizedVariations;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { LimitPolicy } from './enhancement/createLimitPolicy';
|
2
|
-
import { ComponentDefinitionAPIDeleteRequest, ComponentDefinitionAPIPutRequest, ComponentDefinitionAPIResponse, ComponentDefinitionListAPIOptions } from './types/componentDefinitions';
|
3
|
-
import { CompositionAPIDeleteRequest, CompositionAPIOptions, CompositionAPIPutRequest, CompositionAPIResponse, CompositionListAPIResponse } from './types/componentInstances';
|
4
|
-
export declare type CanvasClientOptions = {
|
5
|
-
/** The Uniform API host to use. Internal use. */
|
6
|
-
apiHost?: string;
|
7
|
-
/** The Uniform API key to use when sending API requests. This or bearer token must be specified. */
|
8
|
-
apiKey?: string | null;
|
9
|
-
/** The Uniform bearer token to use. Internal use. */
|
10
|
-
bearerToken?: string | null;
|
11
|
-
/** The Uniform project ID to connect to */
|
12
|
-
projectId?: string | null;
|
13
|
-
/** Specify a fetch implementation to use when fetching data. Useful if you want to only polyfill selectively. */
|
14
|
-
fetch?: typeof fetch;
|
15
|
-
/**
|
16
|
-
* Specify how to retry and throttle requests.
|
17
|
-
* Default: retry 3x on failures with exponential backoff, up to 10 requests per second.
|
18
|
-
* Use createLimitPolicy() to help creating a policy. */
|
19
|
-
limitPolicy?: LimitPolicy;
|
20
|
-
};
|
21
|
-
export declare class CanvasClientError extends Error {
|
22
|
-
errorMessage: string;
|
23
|
-
fetchMethod: string;
|
24
|
-
fetchUri: string;
|
25
|
-
statusCode?: number | undefined;
|
26
|
-
statusText?: string | undefined;
|
27
|
-
constructor(errorMessage: string, fetchMethod: string, fetchUri: string, statusCode?: number | undefined, statusText?: string | undefined);
|
28
|
-
}
|
29
|
-
export declare class CanvasClient {
|
30
|
-
private options;
|
31
|
-
constructor(options: CanvasClientOptions);
|
32
|
-
/** Fetches lists of Canvas compositions, optionally by type */
|
33
|
-
getCompositionList(options?: Omit<CompositionAPIOptions, 'projectId'>): Promise<CompositionListAPIResponse>;
|
34
|
-
/** Fetches a Canvas composition by string name (slug) */
|
35
|
-
getCompositionBySlug(options: Pick<CompositionAPIOptions, 'slug' | 'state' | 'skipEnhance' | 'skipPatternResolution'>): Promise<CompositionAPIResponse>;
|
36
|
-
/** Fetches a Canvas composition by its public UUID */
|
37
|
-
getCompositionById(options: Pick<CompositionAPIOptions, 'compositionId' | 'state' | 'skipEnhance' | 'skipPatternResolution'>): Promise<CompositionAPIResponse>;
|
38
|
-
/** Updates or creates a Canvas component definition */
|
39
|
-
updateComposition(body: Omit<CompositionAPIPutRequest, 'projectId'>): Promise<void>;
|
40
|
-
/** Deletes a Canvas component definition */
|
41
|
-
removeComposition(body: Omit<CompositionAPIDeleteRequest, 'projectId'>): Promise<void>;
|
42
|
-
/** Fetches all Canvas component definitions */
|
43
|
-
getComponentDefinitions(options?: Omit<ComponentDefinitionListAPIOptions, 'projectId'>): Promise<ComponentDefinitionAPIResponse>;
|
44
|
-
/** Updates or creates a Canvas component definition */
|
45
|
-
updateComponentDefinition(body: Omit<ComponentDefinitionAPIPutRequest, 'projectId'>): Promise<void>;
|
46
|
-
/** Deletes a Canvas component definition */
|
47
|
-
removeComponentDefinition(body: Omit<ComponentDefinitionAPIDeleteRequest, 'projectId'>): Promise<void>;
|
48
|
-
private apiClient;
|
49
|
-
private createUrl;
|
50
|
-
}
|
package/dist/esm/CanvasClient.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
var __extends=this&&this.__extends||function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(t,a,s,c){return new(s=s||Promise)(function(n,e){function r(t){try{o(c.next(t))}catch(t){e(t)}}function i(t){try{o(c.throw(t))}catch(t){e(t)}}function o(t){var e;t.done?n(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(r,i)}o((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(n,r){var i,o,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,o=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=r.call(n,s)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}},__read=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a};import{createLimitPolicy}from"./enhancement/createLimitPolicy";var CanvasClientError=function(a){function s(t,e,n,r,i){var o=a.call(this,t+"\n "+r+(i?" "+i:"")+" ("+e+" "+n+")")||this;return o.errorMessage=t,o.fetchMethod=e,o.fetchUri=n,o.statusCode=r,o.statusText=i,Object.setPrototypeOf(o,s.prototype),o}return __extends(s,a),s}(Error),CanvasClient=function(){function t(t){var e;if(!t.apiKey&&!t.bearerToken)throw new Error("You must provide an API key or a bearer token");this.options=__assign(__assign({},t),{fetch:null!==(e=t.fetch)&&void 0!==e?e:fetch,apiHost:null!==(e=t.apiHost)&&void 0!==e?e:"https://uniform.app",apiKey:null!==(e=t.apiKey)&&void 0!==e?e:null,projectId:null!==(e=t.projectId)&&void 0!==e?e:null,bearerToken:null!==(e=t.bearerToken)&&void 0!==e?e:null,limitPolicy:null!==(t=t.limitPolicy)&&void 0!==t?t:createLimitPolicy({})})}return t.prototype.getCompositionList=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.options.projectId,e=this.createUrl("/api/v1/canvas",__assign(__assign({},n),{projectId:e})),[4,this.apiClient(e)];case 1:return[2,t.sent()]}})})},t.prototype.getCompositionBySlug=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.options.projectId,e=this.createUrl("/api/v1/canvas",__assign(__assign({},n),{projectId:e})),[4,this.apiClient(e)];case 1:return[2,t.sent()]}})})},t.prototype.getCompositionById=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.options.projectId,e=this.createUrl("/api/v1/canvas",__assign(__assign({},n),{projectId:e})),[4,this.apiClient(e)];case 1:return[2,t.sent()]}})})},t.prototype.updateComposition=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.createUrl("/api/v1/canvas"),[4,this.apiClient(e,{method:"PUT",body:JSON.stringify(__assign(__assign({},n),{projectId:this.options.projectId})),expectNoContent:!0})];case 1:return t.sent(),[2]}})})},t.prototype.removeComposition=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.createUrl("/api/v1/canvas"),[4,this.apiClient(e,{method:"DELETE",body:JSON.stringify(__assign(__assign({},n),{projectId:this.options.projectId})),expectNoContent:!0})];case 1:return t.sent(),[2]}})})},t.prototype.getComponentDefinitions=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.options.projectId,e=this.createUrl("/api/v1/canvas-definitions",__assign(__assign({},n),{projectId:e})),[4,this.apiClient(e)];case 1:return[2,t.sent()]}})})},t.prototype.updateComponentDefinition=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.createUrl("/api/v1/canvas-definitions"),[4,this.apiClient(e,{method:"PUT",body:JSON.stringify(__assign(__assign({},n),{projectId:this.options.projectId})),expectNoContent:!0})];case 1:return t.sent(),[2]}})})},t.prototype.removeComponentDefinition=function(n){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return e=this.createUrl("/api/v1/canvas-definitions"),[4,this.apiClient(e,{method:"DELETE",body:JSON.stringify(__assign(__assign({},n),{projectId:this.options.projectId})),expectNoContent:!0})];case 1:return t.sent(),[2]}})})},t.prototype.apiClient=function(a,s){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(t){return[2,this.options.limitPolicy(function(){return __awaiter(e,void 0,void 0,function(){var e,n,r,i,o;return __generator(this,function(t){switch(t.label){case 0:return e=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:"Bearer "+this.options.bearerToken},[4,fetch(a.toString(),__assign(__assign({},s),{headers:__assign(__assign({},null==s?void 0:s.headers),e)}))];case 1:if((n=t.sent()).ok)return[3,6];r="",t.label=2;case 2:return t.trys.push([2,4,,5]),[4,n.text()];case 3:o=t.sent();try{i=JSON.parse(o),r=i.errorMessage?Array.isArray(i.errorMessage)?i.errorMessage.join(", "):i.errorMessage:o}catch(t){r=o}return[3,5];case 4:return t.sent(),r="General error",[3,5];case 5:throw new CanvasClientError(r,null!==(o=null==s?void 0:s.method)&&void 0!==o?o:"GET",a.toString(),n.status);case 6:return null!=s&&s.expectNoContent?[2,null]:[4,n.json()];case 7:return[2,t.sent()]}})})})]})})},t.prototype.createUrl=function(t,e){var n=new URL(""+this.options.apiHost+t);return Object.entries(null!=e?e:{}).forEach(function(t){var e=__read(t,2),t=e[0],e=e[1];null!==e&&n.searchParams.append(t,null!==(e=null==e?void 0:e.toString())&&void 0!==e?e:"")}),n},t}();export{CanvasClientError,CanvasClient};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { SyncEngineDataSource } from './syncEngine';
|
2
|
-
export declare type CreateArraySyncEngineDataSourceOptions<TObject> = {
|
3
|
-
objects: Array<TObject>;
|
4
|
-
selectIdentifier: (object: TObject) => string;
|
5
|
-
selectDisplayName?: (object: TObject) => string;
|
6
|
-
onSyncComplete?: (isTarget: boolean, result: Array<TObject>) => Promise<void>;
|
7
|
-
};
|
8
|
-
export declare function createArraySyncEngineDataSource<TObject>({ objects, selectIdentifier, selectDisplayName, onSyncComplete, }: CreateArraySyncEngineDataSourceOptions<TObject>): Promise<SyncEngineDataSource<TObject> & {
|
9
|
-
extractCurrent: () => Array<TObject>;
|
10
|
-
}>;
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,a,u,c){return new(u=u||Promise)(function(n,e){function r(t){try{i(c.next(t))}catch(t){e(t)}}function o(t){try{i(c.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?n(t.value):((e=t.value)instanceof u?e:new u(function(t){t(e)})).then(r,o)}i((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(n,r){var o,i,a,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,i&&(a=2&e[0]?i.return:e[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,e[1])).done)return a;switch(i=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,i=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(a=0<(a=u.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){u.label=e[1];break}if(6===e[0]&&u.label<a[1]){u.label=a[1],a=e;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(e);break}a[2]&&u.ops.pop(),u.trys.pop();continue}e=r.call(n,u)}catch(t){e=[6,t],i=0}finally{o=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}},__await=this&&this.__await||function(t){return this instanceof __await?(this.v=t,this):new __await(t)},__asyncGenerator=this&&this.__asyncGenerator||function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(t,e||[]),i=[],a={};return r("next"),r("throw"),r("return"),a[Symbol.asyncIterator]=function(){return this},a;function r(r){o[r]&&(a[r]=function(n){return new Promise(function(t,e){1<i.push([r,n,t,e])||u(r,n)})})}function u(t,e){try{(n=o[t](e)).value instanceof __await?Promise.resolve(n.value.v).then(c,s):l(i[0][2],n)}catch(t){l(i[0][3],t)}var n}function c(t){u("next",t)}function s(t){u("throw",t)}function l(t,e){t(e),i.shift(),i.length&&u(i[0][0],i[0][1])}},__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function createArraySyncEngineDataSource(t){var n=t.objects,o=t.selectIdentifier,e=t.selectDisplayName,i=void 0===e?o:e,u=t.onSyncComplete;return __awaiter(this,void 0,void 0,function(){function e(){return Object.entries(a).sort(function(t,e){return t[0].localeCompare(e[0])}).map(function(t){return t[1].object})}var a,r=this;return __generator(this,function(t){return a=n.reduce(function(t,e){var n=o(e);if(t[n])throw new Error("Identifier "+n+" was not unique.");return t[n]={id:n,object:e,providerId:n,displayName:i(e)},t},{}),[2,{objects:function(){return __asyncGenerator(this,arguments,function(){var e,n,r,o,i;return __generator(this,function(t){switch(t.label){case 0:t.trys.push([0,6,7,8]),e=__values(Object.values(a)),n=e.next(),t.label=1;case 1:return n.done?[3,5]:(r=n.value,[4,__await(r)]);case 2:return[4,t.sent()];case 3:t.sent(),t.label=4;case 4:return n=e.next(),[3,1];case 5:return[3,8];case 6:return o=t.sent(),o={error:o},[3,8];case 7:try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(o)throw o.error}return[7];case 8:return[2]}})})}(),deleteObject:function(e){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(t){return delete a[e],[2]})})},writeObject:function(n){return __awaiter(r,void 0,void 0,function(){var e;return __generator(this,function(t){return e=o(n.object),a[e]=n,[2]})})},extractCurrent:e,onSyncComplete:u?function(t){return u(t,e())}:void 0}]})})}export{createArraySyncEngineDataSource};
|
package/dist/esm/cli/cli.d.ts
DELETED
package/dist/esm/cli/cli.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import yargs from"yargs";import{ComponentModule}from"./commands/component";import{CompositionModule}from"./commands/composition";export*from"./package";var uniformCLI={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:function(o){return o.command(CompositionModule).command(ComponentModule).demandCommand()},handler:function(){yargs.showHelp()}}]};export{uniformCLI};
|
@@ -1 +0,0 @@
|
|
1
|
-
var selectIdentifier=function(e){return e.id},selectDisplayName=function(e){return e.name+" (pid: "+e.id+")"};export{selectIdentifier,selectDisplayName};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, FormatArgs, ProjectArgs } from '../../util';
|
3
|
-
declare type GetComponentArgs = {
|
4
|
-
id: string;
|
5
|
-
} & ApiArgs & FormatArgs & ProjectArgs;
|
6
|
-
export declare const ComponentGetModule: CommandModule<GetComponentArgs, GetComponentArgs>;
|
7
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,a,c,l){return new(c=c||Promise)(function(n,e){function o(t){try{r(l.next(t))}catch(t){e(t)}}function i(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof c?e:new c(function(t){t(e)})).then(o,i)}r((l=l.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(n,o){var i,r,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,r&&(a=2&e[0]?r.return:e[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,e[1])).done)return a;switch(r=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return c.label++,{value:e[1],done:!1};case 5:c.label++,r=e[1],e=[0];continue;case 7:e=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){c=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){c.label=e[1];break}if(6===e[0]&&c.label<a[1]){c.label=a[1],a=e;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(e);break}a[2]&&c.ops.pop(),c.trys.pop();continue}e=o.call(n,c)}catch(t){e=[6,t],r=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};import{CanvasClient}from"../../../CanvasClient";import{emitWithFormat,withApiOptions,withFormatOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";var ComponentGetModule={command:"get <id>",describe:"Fetch a component definition",builder:function(t){return withFormatOptions(withApiOptions(withProjectOptions(t.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"}))))},handler:function(t){var n=t.apiHost,o=t.apiKey,i=t.id,r=t.format,a=t.project,c=t.filename;return __awaiter(void 0,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return[4,new CanvasClient({apiKey:o,apiHost:n,fetch:fetch,projectId:a}).getComponentDefinitions({componentId:i,limit:1})];case 1:return 0===(e=t.sent()).componentDefinitions.length?(console.error("Component did not exist"),process.exit(1)):emitWithFormat(e.componentDefinitions[0],r,c),[2]}})})}};export{ComponentGetModule};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, FormatArgs, ProjectArgs } from '../../util';
|
3
|
-
import { ComponentDefinitionListAPIOptions } from '../../../types/componentDefinitions';
|
4
|
-
declare type ListComponentArgs = Pick<ComponentDefinitionListAPIOptions, 'offset' | 'limit'> & ApiArgs & FormatArgs & ProjectArgs;
|
5
|
-
export declare const ComponentListModule: CommandModule<ListComponentArgs, ListComponentArgs>;
|
6
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,a,s,c){return new(s=s||Promise)(function(n,e){function i(t){try{r(c.next(t))}catch(t){e(t)}}function o(t){try{r(c.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(i,o)}r((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(n,i){var o,r,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(a=2&e[0]?r.return:e[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,e[1])).done)return a;switch(r=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,r=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=i.call(n,s)}catch(t){e=[6,t],r=0}finally{o=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};import{CanvasClient}from"../../../CanvasClient";import{emitWithFormat,withApiOptions,withFormatOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";var ComponentListModule={command:"list",describe:"List component definitions",aliases:["ls"],builder:function(t){return withFormatOptions(withApiOptions(withProjectOptions(t.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:function(t){var n=t.apiHost,i=t.apiKey,o=t.limit,r=t.offset,a=t.format,s=t.filename,c=t.project;return __awaiter(void 0,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return[4,new CanvasClient({apiKey:i,apiHost:n,fetch:fetch,projectId:c}).getComponentDefinitions({limit:o,offset:r})];case 1:return e=t.sent(),emitWithFormat(e.componentDefinitions,a,s),[2]}})})}};export{ComponentListModule};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, DiffArgs, ProjectArgs } from '../../util';
|
3
|
-
declare type PullComponentArgs = {
|
4
|
-
directory: string;
|
5
|
-
format: 'yaml' | 'json';
|
6
|
-
whatIf: boolean;
|
7
|
-
mode: 'mirror' | 'createOrUpdate' | 'create';
|
8
|
-
} & ApiArgs & ProjectArgs & DiffArgs;
|
9
|
-
export declare const ComponentPullModule: CommandModule<PullComponentArgs, PullComponentArgs>;
|
10
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,l){return new(c=c||Promise)(function(n,t){function i(e){try{o(l.next(e))}catch(e){t(e)}}function r(e){try{o(l.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(i,r)}o((l=l.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,i){var r,o,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,o=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=i.call(n,c)}catch(e){t=[6,e],o=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{isPathAPackageFile,limitPolicy,withApiOptions,withDiffOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";import{syncEngine}from"../../syncEngine";import{createFileSyncEngineDataSource}from"../../fileSyncEngineDataSource";import{createComponentDefinitionEngineDataSource}from"../../componentDefinitionEngineDataSource";import{createSyncEngineConsoleLogger}from"../../syncEngineConsoleLogger";import{readCanvasPackage,writeCanvasPackage}from"../../package";import{createArraySyncEngineDataSource}from"../../arraySyncEngineDataSource";import{selectDisplayName,selectIdentifier}from"./_util";var ComponentPullModule={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:function(e){return withApiOptions(withProjectOptions(withDiffOptions(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:function(e){var o=e.apiHost,a=e.apiKey,c=e.directory,l=e.format,s=e.mode,f=e.whatIf,u=e.project,p=e.diff;return __awaiter(void 0,void 0,void 0,function(){var t,n,i,r;return __generator(this,function(e){switch(e.label){case 0:return(r=new CanvasClient({apiKey:a,apiHost:o,fetch:fetch,projectId:u,limitPolicy:limitPolicy}),t=createComponentDefinitionEngineDataSource({client:r}),isPathAPackageFile(c))?(i=readCanvasPackage(c,!1),[4,createArraySyncEngineDataSource({objects:null!==(r=i.components)&&void 0!==r?r:[],selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName,onSyncComplete:function(e,t){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){return i.components=t,writeCanvasPackage(c,i),[2]})})}})]):[3,2];case 1:return n=e.sent(),[3,4];case 2:return[4,createFileSyncEngineDataSource({directory:c,selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName,format:l})];case 3:n=e.sent(),e.label=4;case 4:return[4,syncEngine({source:t,target:n,mode:s,whatIf:f,log:createSyncEngineConsoleLogger({diffMode:p})})];case 5:return e.sent(),[2]}})})}};export{ComponentPullModule};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, DiffArgs, ProjectArgs } from '../../util';
|
3
|
-
declare type PushComponentArgs = {
|
4
|
-
directory: string;
|
5
|
-
whatIf: boolean;
|
6
|
-
mode: 'mirror' | 'createOrUpdate' | 'create';
|
7
|
-
} & ApiArgs & ProjectArgs & DiffArgs;
|
8
|
-
export declare const ComponentPushModule: CommandModule<PushComponentArgs, PushComponentArgs>;
|
9
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,s){return new(c=c||Promise)(function(n,t){function i(e){try{o(s.next(e))}catch(e){t(e)}}function r(e){try{o(s.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(i,r)}o((s=s.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,i){var r,o,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,o=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=i.call(n,c)}catch(e){t=[6,e],o=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{isPathAPackageFile,limitPolicy,withApiOptions,withDiffOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";import{createComponentDefinitionEngineDataSource}from"../../componentDefinitionEngineDataSource";import{syncEngine}from"../../syncEngine";import{createSyncEngineConsoleLogger}from"../../syncEngineConsoleLogger";import{createFileSyncEngineDataSource}from"../../fileSyncEngineDataSource";import{readCanvasPackage}from"../../package";import{createArraySyncEngineDataSource}from"../../arraySyncEngineDataSource";import{selectDisplayName,selectIdentifier}from"./_util";var ComponentPushModule={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Optimize",builder:function(e){return withApiOptions(withProjectOptions(withDiffOptions(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:function(e){var r=e.apiHost,o=e.apiKey,a=e.directory,c=e.mode,s=e.whatIf,l=e.project,u=e.diff;return __awaiter(void 0,void 0,void 0,function(){var t,n,i;return __generator(this,function(e){switch(e.label){case 0:return(t=new CanvasClient({apiKey:o,apiHost:r,fetch:fetch,projectId:l,limitPolicy:limitPolicy}),isPathAPackageFile(a))?(i=readCanvasPackage(a,!0),[4,createArraySyncEngineDataSource({objects:null!==(i=i.components)&&void 0!==i?i:[],selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName})]):[3,2];case 1:return n=e.sent(),[3,4];case 2:return[4,createFileSyncEngineDataSource({directory:a,selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName})];case 3:n=e.sent(),e.label=4;case 4:return i=createComponentDefinitionEngineDataSource({client:t}),[4,syncEngine({source:n,target:i,mode:c,whatIf:s,log:createSyncEngineConsoleLogger({diffMode:u})})];case 5:return e.sent(),[2]}})})}};export{ComponentPushModule};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, ProjectArgs } from '../../util';
|
3
|
-
declare type DeleteComponentArgs = {
|
4
|
-
id: string;
|
5
|
-
} & ApiArgs & ProjectArgs;
|
6
|
-
export declare const ComponentRemoveModule: CommandModule<DeleteComponentArgs, DeleteComponentArgs>;
|
7
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,l){return new(c=c||Promise)(function(n,t){function o(e){try{i(l.next(e))}catch(e){t(e)}}function r(e){try{i(l.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(o,r)}i((l=l.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,o){var r,i,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,i&&(a=2&t[0]?i.return:t[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,t[1])).done)return a;switch(i=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,i=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=o.call(n,c)}catch(e){t=[6,e],i=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{withApiOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";var ComponentRemoveModule={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:function(e){return withApiOptions(withProjectOptions(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"})))},handler:function(e){var t=e.apiHost,n=e.apiKey,o=e.id,r=e.project;return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new CanvasClient({apiKey:n,apiHost:t,fetch:fetch,projectId:r}).removeComponentDefinition({componentId:o})];case 1:return e.sent(),[2]}})})}};export{ComponentRemoveModule};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, ProjectArgs } from '../../util';
|
3
|
-
declare type UpdateComponentArgs = {
|
4
|
-
filename: string;
|
5
|
-
} & ApiArgs & ProjectArgs;
|
6
|
-
export declare const ComponentUpdateModule: CommandModule<UpdateComponentArgs, UpdateComponentArgs>;
|
7
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,u){return new(c=c||Promise)(function(n,t){function o(e){try{r(u.next(e))}catch(e){t(e)}}function i(e){try{r(u.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(o,i)}r((u=u.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,o){var i,r,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,r&&(a=2&t[0]?r.return:t[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,t[1])).done)return a;switch(r=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,r=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=o.call(n,c)}catch(e){t=[6,e],r=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{readFileToObject,withApiOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";var ComponentUpdateModule={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:function(e){return withApiOptions(withProjectOptions(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"})))},handler:function(e){var o=e.apiHost,i=e.apiKey,r=e.filename,a=e.project;return __awaiter(void 0,void 0,void 0,function(){var t,n;return __generator(this,function(e){switch(e.label){case 0:return t=new CanvasClient({apiKey:i,apiHost:o,fetch:fetch,projectId:a}),n=readFileToObject(r),[4,t.updateComponentDefinition({componentDefinition:n})];case 1:return e.sent(),[2]}})})}};export{ComponentUpdateModule};
|
@@ -1 +0,0 @@
|
|
1
|
-
import yargs from"yargs";import{ComponentGetModule}from"./component/get";import{ComponentListModule}from"./component/list";import{ComponentPullModule}from"./component/pull";import{ComponentPushModule}from"./component/push";import{ComponentRemoveModule}from"./component/remove";import{ComponentUpdateModule}from"./component/update";var ComponentModule={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:function(o){return o.command(ComponentPullModule).command(ComponentPushModule).command(ComponentGetModule).command(ComponentRemoveModule).command(ComponentListModule).command(ComponentUpdateModule).demandCommand()},handler:function(){return yargs.help()}};export{ComponentModule};
|
@@ -1 +0,0 @@
|
|
1
|
-
var selectIdentifier=function(i){return i.composition._id},selectDisplayName=function(i){var o;return(null!==(o=null!==(o=i.composition._name)&&void 0!==o?o:i.composition._slug)&&void 0!==o?o:i.composition._id)+" (pid: "+i.composition._id+")"};export{selectIdentifier,selectDisplayName};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, FormatArgs, ProjectArgs, StateArgs } from '../../util';
|
3
|
-
declare type GetCompositionArgs = {
|
4
|
-
id: string;
|
5
|
-
resolvePatterns?: boolean;
|
6
|
-
} & ApiArgs & FormatArgs & StateArgs & ProjectArgs;
|
7
|
-
export declare const CompositionGetModule: CommandModule<GetCompositionArgs, GetCompositionArgs>;
|
8
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,a,s,c){return new(s=s||Promise)(function(o,e){function n(t){try{r(c.next(t))}catch(t){e(t)}}function i(t){try{r(c.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?o(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(n,i)}r((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(o,n){var i,r,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(a=2&e[0]?r.return:e[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,e[1])).done)return a;switch(r=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,r=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=n.call(o,s)}catch(t){e=[6,t],r=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};import{CanvasClient}from"../../../CanvasClient";import{convertCompositionState,emitWithFormat,prepCompositionForDisk,withApiOptions,withFormatOptions,withProjectOptions,withStateOptions}from"../../util";import fetch from"isomorphic-unfetch";var CompositionGetModule={command:"get <id>",describe:"Fetch a composition",builder:function(t){return withFormatOptions(withApiOptions(withProjectOptions(withStateOptions(t.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"}})))))},handler:function(t){var n=t.apiHost,i=t.apiKey,r=t.id,a=t.format,s=t.filename,c=t.state,p=t.project,l=t.resolvePatterns;return __awaiter(void 0,void 0,void 0,function(){var e,o;return __generator(this,function(t){switch(t.label){case 0:return e=new CanvasClient({apiKey:i,apiHost:n,fetch:fetch,projectId:p}),o=prepCompositionForDisk,[4,e.getCompositionById({compositionId:r,state:convertCompositionState(c),skipPatternResolution:!l})];case 1:return e=o.apply(void 0,[t.sent()]),emitWithFormat(e,a,s),[2]}})})}};export{CompositionGetModule};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, FormatArgs, ProjectArgs, StateArgs } from '../../util';
|
3
|
-
import { CompositionAPIOptions } from '../../../types/componentInstances';
|
4
|
-
declare type ListCompositionArgs = {
|
5
|
-
resolvePatterns?: boolean;
|
6
|
-
} & Pick<CompositionAPIOptions, 'offset' | 'limit'> & ApiArgs & FormatArgs & ProjectArgs & StateArgs;
|
7
|
-
export declare const CompositionListModule: CommandModule<ListCompositionArgs, ListCompositionArgs>;
|
8
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,a,s,c){return new(s=s||Promise)(function(o,e){function i(t){try{r(c.next(t))}catch(t){e(t)}}function n(t){try{r(c.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?o(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(i,n)}r((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(o,i){var n,r,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(a=2&e[0]?r.return:e[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,e[1])).done)return a;switch(r=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,r=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=i.call(o,s)}catch(t){e=[6,t],r=0}finally{n=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};import{CanvasClient}from"../../../CanvasClient";import{convertCompositionState,emitWithFormat,withApiOptions,withFormatOptions,withProjectOptions,withStateOptions}from"../../util";import fetch from"isomorphic-unfetch";var CompositionListModule={command:"list",describe:"List compositions",aliases:["ls"],builder:function(t){return withFormatOptions(withApiOptions(withProjectOptions(withStateOptions(t.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:function(t){var o=t.apiHost,i=t.apiKey,n=t.limit,r=t.offset,a=t.format,s=t.filename,c=t.project,l=t.state,u=t.resolvePatterns;return __awaiter(void 0,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:return[4,new CanvasClient({apiKey:i,apiHost:o,fetch:fetch,projectId:c}).getCompositionList({limit:n,offset:r,state:convertCompositionState(l),skipPatternResolution:!u})];case 1:return e=t.sent(),emitWithFormat(e.compositions,a,s),[2]}})})}};export{CompositionListModule};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, DiffArgs, ProjectArgs, StateArgs } from '../../util';
|
3
|
-
declare type PullCompositionArgs = {
|
4
|
-
directory: string;
|
5
|
-
format: 'yaml' | 'json';
|
6
|
-
whatIf: boolean;
|
7
|
-
mode: 'mirror' | 'createOrUpdate' | 'create';
|
8
|
-
} & ApiArgs & StateArgs & ProjectArgs & DiffArgs;
|
9
|
-
export declare const CompositionPullModule: CommandModule<PullCompositionArgs, PullCompositionArgs>;
|
10
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,s){return new(c=c||Promise)(function(n,t){function i(e){try{o(s.next(e))}catch(e){t(e)}}function r(e){try{o(s.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(i,r)}o((s=s.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,i){var r,o,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,o=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=i.call(n,c)}catch(e){t=[6,e],o=0}finally{r=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{isPathAPackageFile,limitPolicy,withApiOptions,withDiffOptions,withProjectOptions,withStateOptions}from"../../util";import fetch from"isomorphic-unfetch";import{syncEngine}from"../../syncEngine";import{createFileSyncEngineDataSource}from"../../fileSyncEngineDataSource";import{createComponentInstanceEngineDataSource}from"../../componentInstanceEngineDataSource";import{createSyncEngineConsoleLogger}from"../../syncEngineConsoleLogger";import{readCanvasPackage,writeCanvasPackage}from"../../package";import{createArraySyncEngineDataSource}from"../../arraySyncEngineDataSource";import{selectDisplayName,selectIdentifier}from"./_util";var CompositionPullModule={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:function(e){return withApiOptions(withProjectOptions(withStateOptions(withDiffOptions(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:function(e){var o=e.apiHost,a=e.apiKey,c=e.directory,s=e.format,l=e.mode,u=e.whatIf,f=e.state,p=e.project,d=e.diff;return __awaiter(void 0,void 0,void 0,function(){var t,n,i,r;return __generator(this,function(e){switch(e.label){case 0:return(r=new CanvasClient({apiKey:a,apiHost:o,fetch:fetch,projectId:p,limitPolicy:limitPolicy}),t=createComponentInstanceEngineDataSource({client:r,state:f}),isPathAPackageFile(c))?(i=readCanvasPackage(c,!1),[4,createArraySyncEngineDataSource({objects:null!==(r=null==i?void 0:i.compositions)&&void 0!==r?r:[],selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName,onSyncComplete:function(e,t){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){return i.compositions=t,writeCanvasPackage(c,i),[2]})})}})]):[3,2];case 1:return n=e.sent(),[3,4];case 2:return[4,createFileSyncEngineDataSource({directory:c,selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName,format:s})];case 3:n=e.sent(),e.label=4;case 4:return[4,syncEngine({source:t,target:n,mode:l,whatIf:u,log:createSyncEngineConsoleLogger({diffMode:d})})];case 5:return e.sent(),[2]}})})}};export{CompositionPullModule};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, DiffArgs, ProjectArgs, StateArgs } from '../../util';
|
3
|
-
declare type PushCompositionArgs = {
|
4
|
-
directory: string;
|
5
|
-
whatIf: boolean;
|
6
|
-
mode: 'mirror' | 'createOrUpdate' | 'create';
|
7
|
-
} & ApiArgs & StateArgs & ProjectArgs & DiffArgs;
|
8
|
-
export declare const CompositionPushModule: CommandModule<PushCompositionArgs, PushCompositionArgs>;
|
9
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,o,c,s){return new(c=c||Promise)(function(n,t){function i(e){try{a(s.next(e))}catch(e){t(e)}}function r(e){try{a(s.throw(e))}catch(e){t(e)}}function a(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(i,r)}a((s=s.apply(e,o||[])).next())})},__generator=this&&this.__generator||function(n,i){var r,a,o,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,a&&(o=2&t[0]?a.return:t[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,t[1])).done)return o;switch(a=0,(t=o?[2&t[0],o.value]:t)[0]){case 0:case 1:o=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,a=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(o=0<(o=c.trys).length&&o[o.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!o||t[1]>o[0]&&t[1]<o[3])){c.label=t[1];break}if(6===t[0]&&c.label<o[1]){c.label=o[1],o=t;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(t);break}o[2]&&c.ops.pop(),c.trys.pop();continue}t=i.call(n,c)}catch(e){t=[6,e],a=0}finally{r=o=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{isPathAPackageFile,limitPolicy,withApiOptions,withDiffOptions,withProjectOptions,withStateOptions}from"../../util";import fetch from"isomorphic-unfetch";import{syncEngine}from"../../syncEngine";import{createSyncEngineConsoleLogger}from"../../syncEngineConsoleLogger";import{createFileSyncEngineDataSource}from"../../fileSyncEngineDataSource";import{createComponentInstanceEngineDataSource}from"../../componentInstanceEngineDataSource";import{readCanvasPackage}from"../../package";import{createArraySyncEngineDataSource}from"../../arraySyncEngineDataSource";import{selectDisplayName,selectIdentifier}from"./_util";var CompositionPushModule={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Optimize",builder:function(e){return withApiOptions(withProjectOptions(withStateOptions(withDiffOptions(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:function(e){var r=e.apiHost,a=e.apiKey,o=e.directory,c=e.mode,s=e.whatIf,l=e.state,u=e.project,p=e.diff;return __awaiter(void 0,void 0,void 0,function(){var t,n,i;return __generator(this,function(e){switch(e.label){case 0:return(t=new CanvasClient({apiKey:a,apiHost:r,fetch:fetch,projectId:u,limitPolicy:limitPolicy}),isPathAPackageFile(o))?(i=readCanvasPackage(o,!0),[4,createArraySyncEngineDataSource({objects:null!==(i=i.compositions)&&void 0!==i?i:[],selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName})]):[3,2];case 1:return n=e.sent(),[3,4];case 2:return[4,createFileSyncEngineDataSource({directory:o,selectIdentifier:selectIdentifier,selectDisplayName:selectDisplayName})];case 3:n=e.sent(),e.label=4;case 4:return i=createComponentInstanceEngineDataSource({client:t,state:l}),[4,syncEngine({source:n,target:i,mode:c,whatIf:s,log:createSyncEngineConsoleLogger({diffMode:p})})];case 5:return e.sent(),[2]}})})}};export{CompositionPushModule};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, ProjectArgs } from '../../util';
|
3
|
-
declare type DeleteCompositionArgs = {
|
4
|
-
id: string;
|
5
|
-
} & ApiArgs & ProjectArgs;
|
6
|
-
export declare const CompositionRemoveModule: CommandModule<DeleteCompositionArgs, DeleteCompositionArgs>;
|
7
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,l){return new(c=c||Promise)(function(n,t){function o(e){try{r(l.next(e))}catch(e){t(e)}}function i(e){try{r(l.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(o,i)}r((l=l.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,o){var i,r,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,r&&(a=2&t[0]?r.return:t[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,t[1])).done)return a;switch(r=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,r=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=o.call(n,c)}catch(e){t=[6,e],r=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}};import{CanvasClient}from"../../../CanvasClient";import{withApiOptions,withProjectOptions}from"../../util";import fetch from"isomorphic-unfetch";var CompositionRemoveModule={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:function(e){return withApiOptions(withProjectOptions(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"})))},handler:function(e){var t=e.apiHost,n=e.apiKey,o=e.id,i=e.project;return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,new CanvasClient({apiKey:n,apiHost:t,fetch:fetch,projectId:i}).removeComposition({compositionId:o})];case 1:return e.sent(),[2]}})})}};export{CompositionRemoveModule};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { CommandModule } from 'yargs';
|
2
|
-
import { ApiArgs, ProjectArgs, StateArgs } from '../../util';
|
3
|
-
declare type UpdateCompositionArgs = {
|
4
|
-
filename: string;
|
5
|
-
} & ApiArgs & ProjectArgs & StateArgs;
|
6
|
-
export declare const CompositionUpdateModule: CommandModule<UpdateCompositionArgs, UpdateCompositionArgs>;
|
7
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(t,a,s,c){return new(s=s||Promise)(function(n,e){function i(t){try{r(c.next(t))}catch(t){e(t)}}function o(t){try{r(c.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?n(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(i,o)}r((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(n,i){var o,r,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(a=2&e[0]?r.return:e[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,e[1])).done)return a;switch(r=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,r=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=i.call(n,s)}catch(t){e=[6,t],r=0}finally{o=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}};import{CanvasClient}from"../../../CanvasClient";import{convertCompositionState,readFileToObject,withApiOptions,withProjectOptions,withStateOptions}from"../../util";import fetch from"isomorphic-unfetch";var CompositionUpdateModule={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:function(t){return withApiOptions(withProjectOptions(withStateOptions(t.positional("filename",{demandOption:!0,describe:"Composition file to put"}))))},handler:function(t){var i=t.apiHost,o=t.apiKey,r=t.filename,a=t.project,s=t.state;return __awaiter(void 0,void 0,void 0,function(){var e,n;return __generator(this,function(t){switch(t.label){case 0:return e=new CanvasClient({apiKey:o,apiHost:i,fetch:fetch,projectId:a}),n=readFileToObject(r),[4,e.updateComposition(__assign(__assign({},n),{state:convertCompositionState(s)}))];case 1:return t.sent(),[2]}})})}};export{CompositionUpdateModule};
|
@@ -1 +0,0 @@
|
|
1
|
-
import yargs from"yargs";import{CompositionGetModule}from"./composition/get";import{CompositionListModule}from"./composition/list";import{CompositionPullModule}from"./composition/pull";import{CompositionPushModule}from"./composition/push";import{CompositionRemoveModule}from"./composition/remove";import{CompositionUpdateModule}from"./composition/update";var CompositionModule={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:function(o){return o.command(CompositionPullModule).command(CompositionPushModule).command(CompositionGetModule).command(CompositionRemoveModule).command(CompositionListModule).command(CompositionUpdateModule).demandCommand()},handler:function(){return yargs.help()}};export{CompositionModule};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { ComponentDefinition } from '../types';
|
2
|
-
import { CanvasClient } from '../CanvasClient';
|
3
|
-
import { SyncEngineDataSource } from './syncEngine';
|
4
|
-
export declare type CreateComponentDefinitionEngineDataSource = {
|
5
|
-
client: CanvasClient;
|
6
|
-
};
|
7
|
-
export declare function createComponentDefinitionEngineDataSource({ client, }: CreateComponentDefinitionEngineDataSource): SyncEngineDataSource<ComponentDefinition>;
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,s){return new(c=c||Promise)(function(n,t){function r(e){try{i(s.next(e))}catch(e){t(e)}}function o(e){try{i(s.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(r,o)}i((s=s.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,r){var o,i,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(a=2&t[0]?i.return:t[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,t[1])).done)return a;switch(i=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,i=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=r.call(n,c)}catch(e){t=[6,e],i=0}finally{o=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}},__asyncValues=this&&this.__asyncValues||function(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,t=a[Symbol.asyncIterator];return t?t.call(a):(a="function"==typeof __values?__values(a):a[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=a[i]&&function(o){return new Promise(function(e,t){var n,r;o=a[i](o),n=e,e=t,r=o.done,t=o.value,Promise.resolve(t).then(function(e){n({value:e,done:r})},e)})}}},__await=this&&this.__await||function(e){return this instanceof __await?(this.v=e,this):new __await(e)},__asyncGenerator=this&&this.__asyncGenerator||function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(e,t||[]),i=[],a={};return r("next"),r("throw"),r("return"),a[Symbol.asyncIterator]=function(){return this},a;function r(r){o[r]&&(a[r]=function(n){return new Promise(function(e,t){1<i.push([r,n,e,t])||c(r,n)})})}function c(e,t){try{(n=o[e](t)).value instanceof __await?Promise.resolve(n.value.v).then(s,u):l(i[0][2],n)}catch(e){l(i[0][3],e)}var n}function s(e){c("next",e)}function u(e){c("throw",e)}function l(e,t){e(t),i.shift(),i.length&&c(i[0][0],i[0][1])}};import{paginateAsync}from"./util";import{selectDisplayName,selectIdentifier}from"./commands/component/_util";function createComponentDefinitionEngineDataSource(e){var n=this,s=e.client;return{objects:function(){return __asyncGenerator(this,arguments,function(){var t,n,r,o,i,a,c=this;return __generator(this,function(e){switch(e.label){case 0:t=paginateAsync(function(t,n){return __awaiter(c,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,s.getComponentDefinitions({limit:n,offset:t})];case 1:return[2,e.sent().componentDefinitions]}})})},{pageSize:100}),e.label=1;case 1:e.trys.push([1,8,9,14]),n=__asyncValues(t),e.label=2;case 2:return[4,__await(n.next())];case 3:return(r=e.sent()).done?[3,7]:(o=r.value,o={id:selectIdentifier(o),displayName:selectDisplayName(o),providerId:o.id,object:o},[4,__await(o)]);case 4:return[4,e.sent()];case 5:e.sent(),e.label=6;case 6:return[3,2];case 7:return[3,14];case 8:return i=e.sent(),i={error:i},[3,14];case 9:return e.trys.push([9,,12,13]),r&&!r.done&&(a=n.return)?[4,__await(a.call(n))]:[3,11];case 10:e.sent(),e.label=11;case 11:return[3,13];case 12:if(i)throw i.error;return[7];case 13:return[7];case 14:return[2]}})})}(),deleteObject:function(t){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,s.removeComponentDefinition({componentId:t})];case 1:return e.sent(),[2]}})})},writeObject:function(t){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,s.updateComponentDefinition({componentDefinition:t.object})];case 1:return e.sent(),[2]}})})}}}export{createComponentDefinitionEngineDataSource};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { CompositionAPIResponse } from '../types';
|
2
|
-
import { CanvasClient } from '../CanvasClient';
|
3
|
-
import { SyncEngineDataSource } from './syncEngine';
|
4
|
-
import { CLICompositionState } from './util';
|
5
|
-
export declare type CreateComponentInstanceEngineDataSource = {
|
6
|
-
client: CanvasClient;
|
7
|
-
state: CLICompositionState;
|
8
|
-
};
|
9
|
-
export declare function createComponentInstanceEngineDataSource({ client, state, }: CreateComponentInstanceEngineDataSource): SyncEngineDataSource<CompositionAPIResponse>;
|
@@ -1 +0,0 @@
|
|
1
|
-
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},__awaiter=this&&this.__awaiter||function(t,a,s,c){return new(s=s||Promise)(function(n,e){function r(t){try{i(c.next(t))}catch(t){e(t)}}function o(t){try{i(c.throw(t))}catch(t){e(t)}}function i(t){var e;t.done?n(t.value):((e=t.value)instanceof s?e:new s(function(t){t(e)})).then(r,o)}i((c=c.apply(t,a||[])).next())})},__generator=this&&this.__generator||function(n,r){var o,i,a,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,i&&(a=2&e[0]?i.return:e[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,e[1])).done)return a;switch(i=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,i=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=r.call(n,s)}catch(t){e=[6,t],i=0}finally{o=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}},__asyncValues=this&&this.__asyncValues||function(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,e=a[Symbol.asyncIterator];return e?e.call(a):(a="function"==typeof __values?__values(a):a[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=a[i]&&function(o){return new Promise(function(t,e){var n,r;o=a[i](o),n=t,t=e,r=o.done,e=o.value,Promise.resolve(e).then(function(t){n({value:t,done:r})},t)})}}},__await=this&&this.__await||function(t){return this instanceof __await?(this.v=t,this):new __await(t)},__asyncGenerator=this&&this.__asyncGenerator||function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(t,e||[]),i=[],a={};return r("next"),r("throw"),r("return"),a[Symbol.asyncIterator]=function(){return this},a;function r(r){o[r]&&(a[r]=function(n){return new Promise(function(t,e){1<i.push([r,n,t,e])||s(r,n)})})}function s(t,e){try{(n=o[t](e)).value instanceof __await?Promise.resolve(n.value.v).then(c,u):l(i[0][2],n)}catch(t){l(i[0][3],t)}var n}function c(t){s("next",t)}function u(t){s("throw",t)}function l(t,e){t(e),i.shift(),i.length&&s(i[0][0],i[0][1])}};import{convertCompositionState,paginateAsync,prepCompositionForDisk}from"./util";import{selectDisplayName,selectIdentifier}from"./commands/composition/_util";function createComponentInstanceEngineDataSource(t){var n=this,c=t.client,t=t.state,u=convertCompositionState(t);return{objects:function(){return __asyncGenerator(this,arguments,function(){var e,n,r,o,i,a,s=this;return __generator(this,function(t){switch(t.label){case 0:e=paginateAsync(function(e,n){return __awaiter(s,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,c.getCompositionList({limit:n,offset:e,state:u,skipPatternResolution:!0})];case 1:return[2,t.sent().compositions]}})})},{pageSize:100}),t.label=1;case 1:t.trys.push([1,8,9,14]),n=__asyncValues(e),t.label=2;case 2:return[4,__await(n.next())];case 3:return(r=t.sent()).done?[3,7]:(o=r.value,o={id:selectIdentifier(o),displayName:selectDisplayName(o),providerId:o.composition._id,object:prepCompositionForDisk(o)},[4,__await(o)]);case 4:return[4,t.sent()];case 5:t.sent(),t.label=6;case 6:return[3,2];case 7:return[3,14];case 8:return i=t.sent(),i={error:i},[3,14];case 9:return t.trys.push([9,,12,13]),r&&!r.done&&(a=n.return)?[4,__await(a.call(n))]:[3,11];case 10:t.sent(),t.label=11;case 11:return[3,13];case 12:if(i)throw i.error;return[7];case 13:return[7];case 14:return[2]}})})}(),deleteObject:function(e){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,c.removeComposition({compositionId:e})];case 1:return t.sent(),[2]}})})},writeObject:function(e){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,c.updateComposition(__assign(__assign({},e.object),{state:u}))];case 1:return t.sent(),[2]}})})}}}export{createComponentInstanceEngineDataSource};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { SyncEngineDataSource } from './syncEngine';
|
2
|
-
export declare type CreateFileSyncEngineDataSourceOptions<TObject> = {
|
3
|
-
directory: string;
|
4
|
-
selectIdentifier: (object: TObject) => string;
|
5
|
-
selectDisplayName?: (object: TObject) => string;
|
6
|
-
selectFilename?: (object: TObject) => string;
|
7
|
-
format?: 'json' | 'yaml';
|
8
|
-
};
|
9
|
-
export declare function createFileSyncEngineDataSource<TObject>({ directory, format, selectIdentifier, selectDisplayName, }: CreateFileSyncEngineDataSourceOptions<TObject>): Promise<SyncEngineDataSource<TObject>>;
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,a,c,u){return new(c=c||Promise)(function(n,t){function r(e){try{o(u.next(e))}catch(e){t(e)}}function i(e){try{o(u.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(r,i)}o((u=u.apply(e,a||[])).next())})},__generator=this&&this.__generator||function(n,r){var i,o,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,o&&(a=2&t[0]?o.return:t[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,t[1])).done)return a;switch(o=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,o=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(a=0<(a=c.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){c.label=t[1];break}if(6===t[0]&&c.label<a[1]){c.label=a[1],a=t;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(t);break}a[2]&&c.ops.pop(),c.trys.pop();continue}t=r.call(n,c)}catch(e){t=[6,e],o=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}},__await=this&&this.__await||function(e){return this instanceof __await?(this.v=e,this):new __await(e)},__asyncGenerator=this&&this.__asyncGenerator||function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=n.apply(e,t||[]),o=[],a={};return r("next"),r("throw"),r("return"),a[Symbol.asyncIterator]=function(){return this},a;function r(r){i[r]&&(a[r]=function(n){return new Promise(function(e,t){1<o.push([r,n,e,t])||c(r,n)})})}function c(e,t){try{(n=i[e](t)).value instanceof __await?Promise.resolve(n.value.v).then(u,s):l(o[0][2],n)}catch(e){l(o[0][3],e)}var n}function u(e){c("next",e)}function s(e){c("throw",e)}function l(e,t){e(t),o.shift(),o.length&&c(o[0][0],o[0][1])}},__values=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&r>=e.length?void 0:e)&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};import chalk from"chalk";import{existsSync,mkdirSync}from"fs";import{readdir,unlink}from"fs/promises";import{extname,join}from"path";import{emitWithFormat,readFileToObject}from"./util";function createFileSyncEngineDataSource(e){var u=e.directory,t=e.format,i=void 0===t?"yaml":t,s=e.selectIdentifier,e=e.selectDisplayName,l=void 0===e?s:e;return __awaiter(this,void 0,void 0,function(){var t,c,n,r=this;return __generator(this,function(e){switch(e.label){case 0:return existsSync(u)||mkdirSync(u,{recursive:!0}),[4,readdir(u,"utf-8")];case 1:return t=e.sent(),c=new Set(t.filter(function(e){e=extname(e);return".json"===e||".yaml"===e||".yml"===e})),n=function(e){return join(u,e+"."+i)},[2,{objects:function(){return __asyncGenerator(this,arguments,function(){var t,n,r,i,o,a;return __generator(this,function(e){switch(e.label){case 0:e.trys.push([0,9,10,11]),t=__values(c),n=t.next(),e.label=1;case 1:if(n.done)return[3,8];r=n.value,r=join(u,r),e.label=2;case 2:return e.trys.push([2,6,,7]),[4,__await(readFileToObject(r))];case 3:return i=e.sent(),i={id:s(i),displayName:l(i),providerId:r,object:i},[4,__await(i)];case 4:return[4,e.sent()];case 5:return e.sent(),[3,7];case 6:throw i=e.sent(),console.error(chalk.red("Failed to read "+r+", data is likely invalid.\n"+(null==i?void 0:i.message))),i;case 7:return n=t.next(),[3,1];case 8:return[3,11];case 9:return o=e.sent(),o={error:o},[3,11];case 10:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(o)throw o.error}return[7];case 11:return[2]}})})}(),deleteObject:function(t){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return[4,unlink(t)];case 1:return e.sent(),[2]}})})},writeObject:function(t){return __awaiter(r,void 0,void 0,function(){return __generator(this,function(e){return emitWithFormat(t.object,i,n(t.id)),[2]})})}}]}})})}export{createFileSyncEngineDataSource};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { ComponentDefinition, CompositionAPIResponse } from '../types';
|
2
|
-
export declare type CanvasPackage = {
|
3
|
-
components?: Array<ComponentDefinition>;
|
4
|
-
compositions?: Array<CompositionAPIResponse>;
|
5
|
-
};
|
6
|
-
export declare function readCanvasPackage(filename: string, assertExists: boolean): CanvasPackage;
|
7
|
-
export declare function writeCanvasPackage(filename: string, packageContents: CanvasPackage): void;
|
package/dist/esm/cli/package.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{emitWithFormat,readFileToObject}from"./util";import fs from"fs";function readCanvasPackage(a,e){if(!e&&!fs.existsSync(a))return{};e=readFileToObject(a);if("object"!=typeof e)throw new Error("Package "+a+" does not appear valid.");return e}function writeCanvasPackage(a,e){emitWithFormat(e,void 0,a)}export{readCanvasPackage,writeCanvasPackage};
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { Change } from 'diff';
|
2
|
-
export declare type SyncEngineLogOptions = {
|
3
|
-
id: string;
|
4
|
-
providerId: string;
|
5
|
-
displayName: string;
|
6
|
-
action: 'create' | 'update' | 'delete';
|
7
|
-
whatIf: boolean;
|
8
|
-
diff: Change[];
|
9
|
-
};
|
10
|
-
export declare type SyncEngineObject<TObject> = {
|
11
|
-
/** Unique ID that is identical across all providers */
|
12
|
-
id: string;
|
13
|
-
/** Provider specific ID. Value is provided to deleteObject() function (always the provider ID from the same provider that issued it). */
|
14
|
-
providerId: string;
|
15
|
-
/** Optional display name of the object for log messages. The providerId will be used if this is not set. */
|
16
|
-
displayName?: string;
|
17
|
-
/** The object being synced. */
|
18
|
-
object: TObject;
|
19
|
-
};
|
20
|
-
export declare type SyncEngineDataSource<TObject> = {
|
21
|
-
/** The objects to sync. */
|
22
|
-
objects: AsyncIterable<SyncEngineObject<TObject>>;
|
23
|
-
/**
|
24
|
-
* Called when the sync engine detects a need to update a synced object.
|
25
|
-
* Only called if this source is the target of a sync operation.
|
26
|
-
*/
|
27
|
-
writeObject: (obj: SyncEngineObject<TObject>) => Promise<void>;
|
28
|
-
/**
|
29
|
-
* Called when the sync engine detects a need to delete an object in this data source.
|
30
|
-
* Only called if this source is the target of a sync operation.
|
31
|
-
*/
|
32
|
-
deleteObject: (providerId: string) => Promise<void>;
|
33
|
-
/**
|
34
|
-
* Called when the sync engine finishes synchronization.
|
35
|
-
*/
|
36
|
-
onSyncComplete?: (isTarget: boolean) => Promise<void>;
|
37
|
-
};
|
38
|
-
export declare type SyncEngineOptions<TObject> = {
|
39
|
-
source: SyncEngineDataSource<TObject>;
|
40
|
-
target: SyncEngineDataSource<TObject>;
|
41
|
-
compareContents?: (source: SyncEngineObject<TObject>, target: SyncEngineObject<TObject>) => boolean;
|
42
|
-
mode: 'mirror' | 'createOrUpdate' | 'create';
|
43
|
-
/** Compare sources, but do not execute actions */
|
44
|
-
whatIf?: boolean;
|
45
|
-
/** An exception will normally br thrown if the sync source has nothing in it; this option allows the sync to continue (potentially deleting everything in the target) */
|
46
|
-
allowEmptySource?: boolean;
|
47
|
-
log?: (options: SyncEngineLogOptions) => void;
|
48
|
-
};
|
49
|
-
export declare function syncEngine<TObject>({ source, target, compareContents, mode, allowEmptySource, whatIf, log, }: SyncEngineOptions<TObject>): Promise<void>;
|
@@ -1 +0,0 @@
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,o,s,u){return new(s=s||Promise)(function(t,r){function n(e){try{i(u.next(e))}catch(e){r(e)}}function a(e){try{i(u.throw(e))}catch(e){r(e)}}function i(e){var r;e.done?t(e.value):((r=e.value)instanceof s?r:new s(function(e){e(r)})).then(n,a)}i((u=u.apply(e,o||[])).next())})},__generator=this&&this.__generator||function(t,n){var a,i,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},e={next:r(0),throw:r(1),return:r(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function r(r){return function(e){return function(r){if(a)throw new TypeError("Generator is already executing.");for(;s;)try{if(a=1,i&&(o=2&r[0]?i.return:r[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,r[1])).done)return o;switch(i=0,(r=o?[2&r[0],o.value]:r)[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=0<(o=s.trys).length&&o[o.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]<o[3])){s.label=r[1];break}if(6===r[0]&&s.label<o[1]){s.label=o[1],o=r;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(r);break}o[2]&&s.ops.pop(),s.trys.pop();continue}r=n.call(t,s)}catch(e){r=[6,e],i=0}finally{a=o=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,e])}}},__asyncValues=this&&this.__asyncValues||function(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=o[Symbol.asyncIterator];return r?r.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),e={},t("next"),t("throw"),t("return"),e[Symbol.asyncIterator]=function(){return this},e);function t(i){e[i]=o[i]&&function(a){return new Promise(function(e,r){var t,n;a=o[i](a),t=e,e=r,n=a.done,r=a.value,Promise.resolve(r).then(function(e){t({value:e,done:n})},e)})}}};import{diffJson,diffLines}from"diff";import isEqualWith from"lodash.isequalwith";function syncEngine(e){var v,p,y,b,_,w=e.source,m=e.target,r=e.compareContents,g=void 0===r?function(e,r){return isEqualWith(e.object,r.object,function(e,r,t){return"created"===t||"updated"===t||void 0})}:r,I=e.mode,r=e.allowEmptySource,S=void 0!==r&&r,r=e.whatIf,j=void 0!==r&&r,e=e.log,x=void 0===e?function(){}:e;return __awaiter(this,void 0,void 0,function(){var r,t,n,a,i,o,s,u,c,l,d,f,h=this;return __generator(this,function(e){switch(e.label){case 0:r=new Map,e.label=1;case 1:e.trys.push([1,6,7,12]),t=__asyncValues(m.objects),e.label=2;case 2:return[4,t.next()];case 3:if((n=e.sent()).done)return[3,5];l=n.value,r.set(l.id,l),e.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return c=e.sent(),v={error:c},[3,12];case 7:return e.trys.push([7,,10,11]),n&&!n.done&&(p=t.return)?[4,p.call(t)]:[3,9];case 8:e.sent(),e.label=9;case 9:return[3,11];case 10:if(v)throw v.error;return[7];case 11:return[7];case 12:i=!(a=[]),e.label=13;case 13:e.trys.push([13,18,19,24]),o=__asyncValues(w.objects),e.label=14;case 14:return[4,o.next()];case 15:if((s=e.sent()).done)return[3,17];d=s.value,i=!0,u=d.id,(l=r.get(u))?(g(d,l)||"createOrUpdate"!==I&&"mirror"!==I||(c=function(t,n){return __awaiter(h,void 0,void 0,function(){var r;return __generator(this,function(e){switch(e.label){case 0:return j?[3,2]:[4,m.writeObject(t)];case 1:e.sent(),e.label=2;case 2:return x({action:"update",id:u,providerId:t.providerId,displayName:null!==(r=t.displayName)&&void 0!==r?r:t.providerId,whatIf:j,diff:diffJson(n.object,t.object)}),[2]}})})},a.push(c(d,l))),r.delete(u)):(l=function(t,n){return __awaiter(h,void 0,void 0,function(){var r;return __generator(this,function(e){switch(e.label){case 0:return j?[3,2]:[4,m.writeObject(t)];case 1:e.sent(),e.label=2;case 2:return x({action:"create",id:n,providerId:n,displayName:null!==(r=t.displayName)&&void 0!==r?r:t.providerId,whatIf:j,diff:diffLines("",JSON.stringify(t.object,null,2))}),[2]}})})},a.push(l(d,u))),e.label=16;case 16:return[3,14];case 17:return[3,24];case 18:return d=e.sent(),y={error:d},[3,24];case 19:return e.trys.push([19,,22,23]),s&&!s.done&&(b=o.return)?[4,b.call(o)]:[3,21];case 20:e.sent(),e.label=21;case 21:return[3,23];case 22:if(y)throw y.error;return[7];case 23:return[7];case 24:return[4,Promise.all(a)];case 25:if(e.sent(),"mirror"!==I)return[3,27];if(!i&&!S)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.");return f=[],r.forEach(function(t){return __awaiter(h,void 0,void 0,function(){var r,n=this;return __generator(this,function(e){return r=function(t){return __awaiter(n,void 0,void 0,function(){var r;return __generator(this,function(e){switch(e.label){case 0:return j?[3,2]:[4,m.deleteObject(t.providerId)];case 1:e.sent(),e.label=2;case 2:return x({action:"delete",id:t.id,providerId:t.providerId,displayName:null!==(r=t.displayName)&&void 0!==r?r:t.providerId,whatIf:j,diff:diffLines(JSON.stringify(t.object,null,2),"")}),[2]}})})},f.push(r(t)),[2]})})}),[4,Promise.all(f)];case 26:e.sent(),e.label=27;case 27:return[4,Promise.all([null===(_=w.onSyncComplete)||void 0===_?void 0:_.call(w,!1),null===(_=m.onSyncComplete)||void 0===_?void 0:_.call(m,!0)])];case 28:return e.sent(),[2]}})})}export{syncEngine};
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { SyncEngineLogOptions } from './syncEngine';
|
2
|
-
export declare type DiffMode = 'off' | 'on' | 'update';
|
3
|
-
export declare function createSyncEngineConsoleLogger({ diffMode }: {
|
4
|
-
diffMode: DiffMode;
|
5
|
-
}): ({ action, displayName, whatIf, diff }: SyncEngineLogOptions) => void;
|