@uniformdev/mesh-sdk 17.7.0 → 17.7.1-alpha.167

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/dist/index.d.ts CHANGED
@@ -1,46 +1,36 @@
1
- import { DataType, DataSource, DataResourceVariables, RootComponentInstance, ComponentInstance, ComponentDefinition, ComponentDefinitionParameter } from '@uniformdev/canvas';
1
+ import { DataSource, RootComponentInstance, ComponentInstance, ComponentDefinition, ComponentDefinitionParameter, DataType as DataType$1, DataResourceVariables } from '@uniformdev/canvas';
2
+ import { DataType } from '@uniformdev/canvas/.';
2
3
  import { Emitter } from 'mitt';
3
4
 
4
- declare type DataTypeLocationValue = Pick<DataType, 'body' | 'method' | 'path' | 'custom' | 'headers' | 'parameters' | 'variables'>;
5
- declare type DataConnectorInfo = {
6
- type: string;
7
- displayName: string;
8
- installedIntegrationId: string;
9
- };
10
- declare type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = {
11
- settings: TIntegrationConfiguration;
12
- projectId: string;
13
- dataSource: DataSource;
14
- dataConnector: DataConnectorInfo;
15
- };
16
- declare type DataTypeLocation = MeshLocationCore<DataTypeLocationValue, DataTypeLocationMetadata, DataTypeLocationValue, 'dataType'>;
17
-
18
- declare type DataTypeInstanceLocationMetadata<TIntegrationConfiguration = unknown> = {
5
+ type DataSourceLocationValue = Pick<DataSource, 'baseUrl' | 'custom' | 'headers' | 'parameters' | 'variables'>;
6
+ type DataSourceLocationMetadata<TIntegrationConfiguration = unknown> = {
7
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
19
8
  settings: TIntegrationConfiguration;
20
- dataType: DataType;
21
- dataConnector: DataConnectorInfo;
9
+ /** The Uniform project ID */
22
10
  projectId: string;
23
11
  };
24
- declare type DataTypeInstanceLocation = MeshLocationCore<DataResourceVariables, DataTypeInstanceLocationMetadata, DataResourceVariables, 'dataTypeInstance'>;
12
+ type DataSourceLocation = MeshLocationCore<DataSourceLocationValue, DataSourceLocationMetadata, DataSourceLocationValue, 'dataSource'>;
25
13
 
26
- declare type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = {
14
+ type ParamTypeLocationMetadata<TParamConfiguration = unknown, TIntegrationConfiguration = unknown> = {
27
15
  rootNode: Omit<RootComponentInstance, 'slots' | '_data'>;
28
16
  parameterConfiguration: TParamConfiguration;
29
17
  component: Omit<ComponentInstance, 'slots' | '_parameters' | '_id'>;
30
18
  componentDefinitions: Record<string, ComponentDefinition | undefined>;
31
19
  parameterDefinition: ComponentDefinitionParameter;
20
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
32
21
  settings: TIntegrationConfiguration;
22
+ /** The Uniform project ID */
33
23
  projectId: string;
34
24
  };
35
- declare type ParamTypeLocation<TParamValue = unknown, TParamConfiguration = unknown, TParamSetValue = TParamValue, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue, ParamTypeLocationMetadata<TParamConfiguration, TIntegrationConfiguration>, TParamSetValue, 'paramType'>;
25
+ type ParamTypeLocation<TParamValue = unknown, TParamConfiguration = unknown, TParamSetValue = TParamValue, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue, ParamTypeLocationMetadata<TParamConfiguration, TIntegrationConfiguration>, TParamSetValue, 'paramType'>;
36
26
 
37
- declare type SettingsLocation<TSettingsType> = MeshLocationCore<TSettingsType, undefined, TSettingsType, 'settings'>;
27
+ type SettingsLocation<TSettingsType> = MeshLocationCore<TSettingsType, undefined, TSettingsType, 'settings'>;
38
28
 
39
29
  /**
40
30
  * Defines methods used for interacting with a Mesh location
41
31
  * To receive useful typings, check the `type` property of the location to narrow the typing.
42
32
  */
43
- declare type MeshLocation<TValue = unknown, TSetValue = TValue> = ParamTypeLocation<TValue, unknown, TSetValue> | ParamTypeConfigLocation<TValue> | SettingsLocation<TValue> | DataSourceLocation | DataTypeLocation | DataTypeInstanceLocation;
33
+ type MeshLocation<TValue = unknown, TSetValue = TValue> = ParamTypeLocation<TValue, unknown, TSetValue> | ParamTypeConfigLocation<TValue> | SettingsLocation<TValue> | DataSourceLocation | DataTypeLocation | DataTypeInstanceLocation | DataResourceLocation;
44
34
  interface MeshContextData {
45
35
  locationKey: string;
46
36
  locationType: MeshLocationTypes;
@@ -67,8 +57,8 @@ interface DialogResponseData {
67
57
  dialogId: string;
68
58
  error?: string;
69
59
  }
70
- declare type DialogType = 'location' | 'confirm';
71
- declare type OpenDialogResult = {
60
+ type DialogType = 'location' | 'confirm';
61
+ type OpenDialogResult = {
72
62
  /** Unique ID of this dialog which can be used to close it */
73
63
  dialogId: string;
74
64
  /**
@@ -110,20 +100,51 @@ interface DialogOptions<TDialogParams = DialogParams> {
110
100
  */
111
101
  contentHeight?: CSSHeight;
112
102
  }
113
- declare type DialogParamValue = string | number | boolean | null | DialogParamValue[] | {
103
+ type DialogParamValue = string | number | boolean | null | DialogParamValue[] | {
114
104
  [key: string]: DialogParamValue;
115
105
  };
116
- declare type DialogParams = {
106
+ type DialogParams = {
117
107
  [paramName: string]: DialogParamValue;
118
108
  };
119
- declare type CSSHeight = '-moz-initial' | 'inherit' | 'initial' | 'revert' | 'unset' | '-moz-max-content' | '-moz-min-content' | '-webkit-fit-content' | 'auto' | 'fit-content' | 'max-content' | 'min-content' | `${number}${'px' | 'em' | 'rem' | 'vh'}`;
120
- declare type ValidationResult = {
109
+ type CSSHeight = '-moz-initial' | 'inherit' | 'initial' | 'revert' | 'unset' | '-moz-max-content' | '-moz-min-content' | '-webkit-fit-content' | 'auto' | 'fit-content' | 'max-content' | 'min-content' | `${number}${'px' | 'em' | 'rem' | 'vh'}`;
110
+ type ValidationResult = {
121
111
  isValid: false;
122
112
  validationMessage: string;
123
113
  } | {
124
114
  isValid: true;
125
115
  };
116
+ type OpenDialogMessage = {
117
+ dialogType: DialogType;
118
+ dialogData: unknown;
119
+ options?: DialogOptions;
120
+ };
121
+ type CloseDialogMessage = {
122
+ dialogId: string | undefined;
123
+ dialogType: DialogType;
124
+ dialogData?: unknown;
125
+ };
126
+ type GetDataResourceMessage = Pick<DataType, 'path' | 'headers' | 'parameters' | 'body' | 'method'>;
126
127
 
128
+ /**
129
+ * Imports the iframe communications library and provides an interface for interacting with
130
+ * the parent window via said communications library.
131
+ */
132
+ declare function connectToParent({ dialogResponseHandlers, }: {
133
+ dialogResponseHandlers: DialogResponseHandlers;
134
+ }): Promise<{
135
+ initData: MeshContextData;
136
+ parent: {
137
+ resize: (height: CSSHeight) => Promise<void>;
138
+ getValue: () => Promise<unknown>;
139
+ setValue: (value: unknown, options?: SetValueOptions) => Promise<void>;
140
+ getMetadata: () => Promise<unknown>;
141
+ openDialog: (message: OpenDialogMessage) => Promise<Pick<DialogResponseData, "value" | "dialogId"> | undefined>;
142
+ closeDialog: (message: CloseDialogMessage) => Promise<void>;
143
+ getDataResource: <TExpectedResult>(message: GetDataResourceMessage) => Promise<TExpectedResult>;
144
+ };
145
+ }>;
146
+
147
+ type SetLocationFunction<TSetValue> = (value: TSetValue, options?: SetValueOptions) => Promise<void> | void;
127
148
  /** Core shared generic for a mesh location context */
128
149
  interface MeshLocationCore<TValue = unknown, TMetadata = unknown, TSetValue = TValue, TType extends MeshLocationTypes = MeshLocationTypes> {
129
150
  /** The current location type (where in the Uniform app the mesh app is rendering) */
@@ -139,7 +160,7 @@ interface MeshLocationCore<TValue = unknown, TMetadata = unknown, TSetValue = TV
139
160
  * All locations other than 'settings' update into a parent form state and should be updated live as changes occur in the Mesh app.
140
161
  * The 'settings' location writes to the database each time its value is set, and it should be treated as a form with a submit button.
141
162
  */
142
- setValue: (value: TSetValue, options?: SetValueOptions) => Promise<void>;
163
+ setValue: SetLocationFunction<TSetValue>;
143
164
  /** @deprecated use metadata property instead */
144
165
  getMetadata: () => TMetadata;
145
166
  /**
@@ -172,21 +193,69 @@ interface MeshLocationCore<TValue = unknown, TMetadata = unknown, TSetValue = TV
172
193
  /**
173
194
  * Known location types that can be passed to a mesh location
174
195
  */
175
- declare type MeshLocationTypes = 'paramType' | 'paramTypeConfig' | 'settings' | 'dataSource' | 'dataType' | 'dataTypeInstance';
176
- declare type SetValueOptions = ValidationResult;
196
+ type MeshLocationTypes = 'paramType' | 'paramTypeConfig' | 'settings' | 'dataSource' | 'dataType'
197
+ /** @deprecated use dataResource */
198
+ | 'dataTypeInstance' | 'dataResource';
199
+ type SetValueOptions = ValidationResult;
200
+ type SetValueMessage = {
201
+ uniformMeshLocationValue: unknown;
202
+ options?: SetValueOptions;
203
+ };
204
+ type GetDataResourceLocation = {
205
+ getDataResource: Awaited<ReturnType<typeof connectToParent>>['parent']['getDataResource'];
206
+ };
177
207
 
178
- declare type DataSourceLocationValue = Pick<DataSource, 'baseUrl' | 'custom' | 'headers' | 'parameters' | 'variables'>;
179
- declare type DataSourceLocationMetadata<TIntegrationConfiguration = unknown> = {
208
+ type DataTypeLocationValue = Pick<DataType$1, 'body' | 'method' | 'path' | 'custom' | 'headers' | 'parameters' | 'variables'>;
209
+ type DataConnectorInfo = {
210
+ type: string;
211
+ displayName: string;
212
+ installedIntegrationId: string;
213
+ };
214
+ type DataTypeLocationMetadata<TIntegrationConfiguration = unknown> = {
215
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
180
216
  settings: TIntegrationConfiguration;
217
+ /** The Uniform project ID */
218
+ projectId: string;
219
+ /**
220
+ * The current data type's data source. NOTE: param and header values are not available in this context.
221
+ */
222
+ dataSource: DataSource;
223
+ /** The data connector type of the current data type's data source */
224
+ dataConnector: DataConnectorInfo;
225
+ /** The data type's archetype value. */
226
+ archetype: string;
227
+ };
228
+ type DataTypeLocation = MeshLocationCore<DataTypeLocationValue, DataTypeLocationMetadata, DataTypeLocationValue, 'dataType'> & GetDataResourceLocation;
229
+
230
+ /** @deprecated use DataResourceLocationMetadata */
231
+ type DataTypeInstanceLocationMetadata<TIntegrationConfiguration = unknown> = DataResourceLocationMetadata<TIntegrationConfiguration>;
232
+ type DataResourceLocationMetadata<TIntegrationConfiguration = unknown> = {
233
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
234
+ settings: TIntegrationConfiguration;
235
+ /** The current data resource's data type */
236
+ dataType: DataType$1;
237
+ /** The data type's archetype value. */
238
+ archetype: string;
239
+ /**
240
+ * The current data resource's data source. NOTE: param and header values are not available in this context.
241
+ */
242
+ dataSource: DataSource;
243
+ /** The data connector type of the current data resource's data source */
244
+ dataConnector: DataConnectorInfo;
245
+ /** The Uniform project ID */
181
246
  projectId: string;
182
247
  };
183
- declare type DataSourceLocation = MeshLocationCore<DataSourceLocationValue, DataSourceLocationMetadata, DataSourceLocationValue, 'dataSource'>;
248
+ type DataResourceLocation = MeshLocationCore<DataResourceVariables, DataResourceLocationMetadata, DataResourceVariables, 'dataResource'> & GetDataResourceLocation;
249
+ /** @deprecated use DataResourceLocation */
250
+ type DataTypeInstanceLocation = MeshLocationCore<DataResourceVariables, DataResourceLocationMetadata, DataResourceVariables, 'dataTypeInstance'>;
184
251
 
185
- declare type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = {
252
+ type ParamTypeConfigLocationMetadata<TIntegrationConfiguration = unknown> = {
253
+ /** Settings defined at the integration level (arbitrary type used on settings location) */
186
254
  settings: TIntegrationConfiguration;
255
+ /** The Uniform project ID */
187
256
  projectId: string;
188
257
  };
189
- declare type ParamTypeConfigLocation<TParamValue = unknown, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeConfigLocationMetadata<TIntegrationConfiguration>, TParamValue, 'paramTypeConfig'>;
258
+ type ParamTypeConfigLocation<TParamValue = unknown, TIntegrationConfiguration = unknown> = MeshLocationCore<TParamValue | undefined, ParamTypeConfigLocationMetadata<TIntegrationConfiguration>, TParamValue, 'paramTypeConfig'>;
190
259
 
191
260
  interface SdkWindow {
192
261
  /** The current window object. */
@@ -205,7 +274,7 @@ interface SdkWindow {
205
274
  updateHeight: (height: CSSHeight) => void;
206
275
  }
207
276
 
208
- declare type OpenLocationDialogOptions<TDialogParams> = {
277
+ type OpenLocationDialogOptions<TDialogParams> = {
209
278
  /**
210
279
  * Name of the location key in the Mesh App definition (stored on uniform.app) to open in a dialog.
211
280
  * For example if the current location is integration settings, this would be an object key on:
@@ -216,16 +285,16 @@ declare type OpenLocationDialogOptions<TDialogParams> = {
216
285
  locationKey: string;
217
286
  options?: DialogOptions<TDialogParams>;
218
287
  };
219
- declare type OpenConfirmationDialogOptions = {
288
+ type OpenConfirmationDialogOptions = {
220
289
  titleText: string;
221
290
  bodyText: string;
222
291
  options?: Omit<DialogOptions<void>, 'disableCloseDialogOnSetValue' | 'params'>;
223
292
  };
224
- declare type OpenConfirmationDialogResult = {
293
+ type OpenConfirmationDialogResult = {
225
294
  value: 'confirm' | 'cancel';
226
295
  closeDialog: () => Promise<void>;
227
296
  };
228
- declare type CloseLocationDialogOptions = {
297
+ type CloseLocationDialogOptions = {
229
298
  /** Id of the dialog to close. If no dialog with the given id exists, nothing will happen. */
230
299
  dialogId: string;
231
300
  };
@@ -239,7 +308,7 @@ interface LocationDialogResponse<TDialogValue> {
239
308
  closeDialog: () => Promise<void>;
240
309
  }
241
310
  /** Events that can be emitted from the Mesh SDK */
242
- declare type UniformMeshSDKEvents = {
311
+ type UniformMeshSDKEvents = {
243
312
  /** Fired when the location value has changed */
244
313
  onValueChanged: {
245
314
  newValue: unknown;
@@ -283,4 +352,4 @@ declare function initializeUniformMeshSDK({ autoResizingDisabled, }?: {
283
352
  autoResizingDisabled?: boolean;
284
353
  }): Promise<UniformMeshSDK | undefined>;
285
354
 
286
- export { CSSHeight, CloseLocationDialogOptions, DataConnectorInfo, DataSourceLocation, DataSourceLocationMetadata, DataSourceLocationValue, DataTypeInstanceLocation, DataTypeInstanceLocationMetadata, DataTypeLocation, DataTypeLocationMetadata, DataTypeLocationValue, DialogContext, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, LocationDialogResponse, MeshContextData, MeshLocation, MeshLocationCore, MeshLocationTypes, OpenConfirmationDialogOptions, OpenConfirmationDialogResult, OpenDialogResult, OpenLocationDialogOptions, ParamTypeConfigLocation, ParamTypeConfigLocationMetadata, ParamTypeLocation, ParamTypeLocationMetadata, SdkWindow, SetValueOptions, SettingsLocation, UniformMeshSDK, UniformMeshSDKEvents, ValidationResult, initializeUniformMeshSDK };
355
+ export { CSSHeight, CloseDialogMessage, CloseLocationDialogOptions, DataConnectorInfo, DataResourceLocation, DataResourceLocationMetadata, DataSourceLocation, DataSourceLocationMetadata, DataSourceLocationValue, DataTypeInstanceLocation, DataTypeInstanceLocationMetadata, DataTypeLocation, DataTypeLocationMetadata, DataTypeLocationValue, DialogContext, DialogOptions, DialogParamValue, DialogParams, DialogResponseData, DialogResponseHandler, DialogResponseHandlers, DialogType, GetDataResourceLocation, GetDataResourceMessage, LocationDialogResponse, MeshContextData, MeshLocation, MeshLocationCore, MeshLocationTypes, OpenConfirmationDialogOptions, OpenConfirmationDialogResult, OpenDialogMessage, OpenDialogResult, OpenLocationDialogOptions, ParamTypeConfigLocation, ParamTypeConfigLocationMetadata, ParamTypeLocation, ParamTypeLocationMetadata, SdkWindow, SetLocationFunction, SetValueMessage, SetValueOptions, SettingsLocation, UniformMeshSDK, UniformMeshSDKEvents, ValidationResult, initializeUniformMeshSDK };