@sassoftware/vi-api 1.7.1 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/api.module.js +60 -72
  2. package/component/bindings.d.ts +44 -0
  3. package/config/config-api.d.ts +57 -0
  4. package/control/control-api.d.ts +14 -0
  5. package/control/events.d.ts +1 -0
  6. package/control/page.d.ts +2 -2
  7. package/control/restrictions.d.ts +5 -1
  8. package/event/event-api.d.ts +3 -1
  9. package/event/event-api.js +2 -0
  10. package/index.d.ts +70 -65
  11. package/index.js +1 -1
  12. package/init/index.d.ts +54 -0
  13. package/init/index.js +17 -0
  14. package/init/init-api.d.ts +26 -0
  15. package/init/init-api.js +83 -0
  16. package/init/package.json +9 -0
  17. package/init/public-api.d.ts +1 -0
  18. package/init/public-api.js +1 -0
  19. package/localization/localization-api.d.ts +75 -0
  20. package/metadata/metadata-api.d.ts +40 -3
  21. package/object/object-api.d.ts +36 -9
  22. package/object/object-api.js +5 -0
  23. package/package.json +1 -1
  24. package/page-state/page-state-api.d.ts +5 -32
  25. package/property/property-api.d.ts +71 -1
  26. package/public-api.d.ts +1 -1
  27. package/public-api.js +1 -1
  28. package/resource/resource-api.d.ts +1 -0
  29. package/search/client/client-search-api.d.ts +22 -17
  30. package/sheet/sheet-api.d.ts +7 -7
  31. package/shell-tabs/package.json +9 -0
  32. package/shell-tabs/public-api.d.ts +2 -0
  33. package/shell-tabs/public-api.js +2 -0
  34. package/shell-tabs/shell-tabs-api.d.ts +199 -0
  35. package/shell-tabs/shell-tabs-api.js +6 -0
  36. package/shell-tabs/shell-tabs-lifecycle-api.d.ts +69 -0
  37. package/shell-tabs/shell-tabs-lifecycle-api.js +14 -0
  38. package/alert-reps/index.d.ts +0 -681
  39. package/alert-reps/package.json +0 -5
  40. package/score-reps/index.d.ts +0 -133
  41. package/score-reps/package.json +0 -5
  42. package/svi-datahub/index.d.ts +0 -4559
  43. package/svi-datahub/package.json +0 -5
  44. package/svi-sand/index.d.ts +0 -1064
  45. package/svi-sand/package.json +0 -5
@@ -0,0 +1,83 @@
1
+ import { ReplaySubject, throwError } from "rxjs";
2
+ import { take, timeoutWith } from "rxjs/operators";
3
+ import { APP_INIT_TIMEOUT_MS, ERR_INIT_TIMEOUT, SviInitEvent, ERR_EXISTING_APP_DECLARED, ERR_EXISTING_RESOURCE_BUNDLE_DECLARED } from ".";
4
+ export class SviInitApi {
5
+ constructor(globalI18nResources) {
6
+ this.globalI18nResources = globalI18nResources;
7
+ this.appReadyStates = new Map();
8
+ this.resourceReadyStates = new Map();
9
+ this.resourceServiceSubject = new ReplaySubject();
10
+ this.resourceService$ = this.resourceServiceSubject.pipe(take(1));
11
+ this.defaultTimeout = APP_INIT_TIMEOUT_MS;
12
+ }
13
+ declareApp(appName, i18nResourceBundleName) {
14
+ if (this.isAppDeclared(appName)) {
15
+ throw ERR_EXISTING_APP_DECLARED(appName);
16
+ }
17
+ this.initReadyState(this.appReadyStates, appName, true);
18
+ if (!i18nResourceBundleName) {
19
+ return;
20
+ }
21
+ if (this.isResourceBundleDeclared(i18nResourceBundleName)) {
22
+ throw ERR_EXISTING_RESOURCE_BUNDLE_DECLARED(i18nResourceBundleName);
23
+ }
24
+ this.initReadyState(this.resourceReadyStates, i18nResourceBundleName, true);
25
+ }
26
+ async whenAppReady(appName, timeout) {
27
+ return this.whenReady(this.appReadyStates, appName, timeout);
28
+ }
29
+ notifyAppReady(appName) {
30
+ this.notifyReady(this.appReadyStates, appName);
31
+ }
32
+ registerResourceBundle(bundleName, resources) {
33
+ // register bundle with the global i18nResources object which will be picked up by our resource services on construction.
34
+ this.globalI18nResources[bundleName] = resources;
35
+ this.notifyReady(this.resourceReadyStates, bundleName);
36
+ // also register the bundle to be added when the resource service is ready.
37
+ // this supports any consumers which may call this after init
38
+ this.resourceService$.subscribe(resourceService => {
39
+ resourceService.registerResourceBundle(bundleName, resources);
40
+ });
41
+ }
42
+ checkAllDeclaredAppsReady() {
43
+ this.whenAllDeclaredReady(this.appReadyStates).then(() => this.notifyAppReady(SviInitEvent.AllDeclaredApps));
44
+ }
45
+ checkAllDeclaredResourcesReady() {
46
+ this.whenAllDeclaredReady(this.resourceReadyStates).then(() => this.notifyAppReady(SviInitEvent.AllDeclaredI18nResourceBundles));
47
+ }
48
+ setResourceApi(resourceService) {
49
+ this.resourceServiceSubject.next(resourceService);
50
+ this.resourceServiceSubject.complete();
51
+ }
52
+ isAppDeclared(appName) {
53
+ return !!this.appReadyStates.get(appName)?.isDeclared;
54
+ }
55
+ isResourceBundleDeclared(bundleName) {
56
+ return !!this.resourceReadyStates.get(bundleName)?.isDeclared;
57
+ }
58
+ notifyReady(map, name) {
59
+ const readyState = this.initReadyState(map, name);
60
+ readyState.subject.next(undefined);
61
+ readyState.subject.complete();
62
+ }
63
+ async whenReady(map, name, timeout) {
64
+ const readySubject = this.initReadyState(map, name).subject;
65
+ const timeoutMs = timeout ?? this.defaultTimeout;
66
+ await readySubject.pipe(timeoutWith(timeoutMs, throwError(ERR_INIT_TIMEOUT(name, timeoutMs)))).toPromise();
67
+ }
68
+ async whenAllDeclaredReady(map) {
69
+ const toWaitFor = [];
70
+ for (const [name, readyState] of map.entries()) {
71
+ if (readyState.isDeclared) {
72
+ toWaitFor.push(this.whenReady(map, name).catch(console.error));
73
+ }
74
+ }
75
+ await Promise.all(toWaitFor);
76
+ }
77
+ initReadyState(map, name, declare) {
78
+ const state = map.get(name) ?? { subject: new ReplaySubject() };
79
+ state.isDeclared = declare ?? state.isDeclared;
80
+ map.set(name, state);
81
+ return state;
82
+ }
83
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@sassoftware/vi-api/init",
3
+ "files": [
4
+ "**/*.d.ts",
5
+ "**/*.js"
6
+ ],
7
+ "main": "public-api.js",
8
+ "types": "public-api.d.ts"
9
+ }
@@ -0,0 +1 @@
1
+ export * from "./index";
@@ -0,0 +1 @@
1
+ export * from "./index";
@@ -23,4 +23,79 @@ export interface LocalizationApi {
23
23
  * @returns The current application display direction.
24
24
  */
25
25
  getDirection(): "ltr" | "rtl";
26
+ /**
27
+ * Methods related to Solution content localization.
28
+ */
29
+ solution: SolutionLocalizationApi;
30
+ }
31
+ export interface SolutionLocalizationApi {
32
+ /**
33
+ * if {@link isEnabled}, returns the {@link SolutionLocalizationBundle} used to lookup translations.
34
+ */
35
+ getLocalizationBundle(): SolutionLocalizationBundle | undefined;
36
+ /**
37
+ * returns true if solution localization is enabled.
38
+ * methods will return unmodified inputs if not enabled.
39
+ * note that solution localization is disabled in the administration application.
40
+ */
41
+ isEnabled(): boolean;
42
+ /**
43
+ * returns the localized value for the given resource key, else, undefined.
44
+ * @param resourceKey
45
+ */
46
+ getLocalizedResource(resourceKey: string): string | undefined;
47
+ /**
48
+ * localize a string using a resourceKey.
49
+ * fallback to lookup by value if the resourceKey is not supplied/found.
50
+ * mappings are defined by the contents of {@link getLocalizationBundle}
51
+ * @param str string to localize
52
+ * @param resourceKey a resource key used to lookup the localized value
53
+ * @returns the localized string
54
+ * @example
55
+ * localize("red", "colours.red.txt") === "rouge"
56
+ */
57
+ localize(str: string, resourceKey?: string): string;
58
+ /**
59
+ * localize string properties of an object
60
+ * properties are provided as a map of <propertyKey, resourceKey>, deep property keys are accepted.
61
+ * {@link localize} is applied to each property with its given resourceKey.
62
+ * @param obj source object to localize
63
+ * @param props properties to localize and their resource keys
64
+ * @returns the localized object
65
+ * @example
66
+ * localizeObject({ label: "red" }, { "label": "colours.red.txt" }) === { label: "rouge" }
67
+ */
68
+ localizeObject<T extends object>(obj: T, props: Record<string, string | undefined>): T;
69
+ /**
70
+ * localize a list of objects.
71
+ * {@link localizeObject} is applied to each element in the list.
72
+ * @param list objects to translate
73
+ * @param getProps callback to return a map of properties and resource keys for the given list element
74
+ * @returns the localized list
75
+ * @example
76
+ * localizeList(
77
+ * [{ id: "red", label: "Red" }, { id: "blue", label: "Blue"} ],
78
+ * (item) => ({ "label": `colours.${item.id}.title` })
79
+ * ) === [{ id: "red", label: "Rouge" }, { id: "blue", label: "Bleu"} ]
80
+ */
81
+ localizeList<T extends object>(list: T[], getProps: (obj: T) => Record<string, string | undefined>): T[];
82
+ }
83
+ /**
84
+ * Stores localized strings by key and value.
85
+ * @example
86
+ * {
87
+ * bykey: {
88
+ * "colours.red.label": "rouge",
89
+ * "colours.blue.label": "bleu"
90
+ * },
91
+ * byValue: {
92
+ * "red": "rouge",
93
+ * "blue": "bleu"
94
+ * }
95
+ * }
96
+ */
97
+ interface SolutionLocalizationBundle {
98
+ byKey: Record<string, string>;
99
+ byValue: Record<string, string>;
26
100
  }
101
+ export {};
@@ -1,4 +1,9 @@
1
1
  import { CoreStoredObjectField, Entity, Relationship, RelationshipDTO, StoredObjectDTO } from "../svi-datahub";
2
+ import { IdentitySummary } from "../current-user/currentUser-api";
3
+ export interface IdentityOption extends IdentitySummary {
4
+ label?: string;
5
+ icon?: string;
6
+ }
2
7
  export interface NodeShapeMultipliers {
3
8
  square: number;
4
9
  circle: number;
@@ -28,8 +33,8 @@ export interface SandDataObject extends DataObject {
28
33
  }
29
34
  export interface DataObject extends PersistableObject {
30
35
  name: string;
31
- dataStoreName: string;
32
- tableName: string;
36
+ dataStoreName?: string;
37
+ tableName?: string;
33
38
  deleteTableName?: string;
34
39
  readOnly: boolean;
35
40
  archived: boolean;
@@ -78,6 +83,8 @@ export interface DataObjectField extends PersistableObject, LocalizableObject {
78
83
  cascadingReferenceDataName?: string;
79
84
  cascadingReferenceDataFilterByCode?: string;
80
85
  cascadingReferenceDataFilterByField?: string;
86
+ masked?: boolean;
87
+ authorizedToRevealMasked?: IdentityOption[];
81
88
  [index: string]: any;
82
89
  }
83
90
  export interface LocalizableObject {
@@ -116,6 +123,15 @@ export interface EntityAccessRules {
116
123
  read: Promise<boolean>;
117
124
  update: Promise<boolean>;
118
125
  }
126
+ export interface EntityAccessRule {
127
+ documentType: string;
128
+ access?: boolean;
129
+ }
130
+ export interface EntitiesAccessRules {
131
+ create: Promise<EntityAccessRule[]>;
132
+ read: Promise<EntityAccessRule[]>;
133
+ update: Promise<EntityAccessRule[]>;
134
+ }
119
135
  export interface ReferenceDataItem {
120
136
  group?: string;
121
137
  displayText: string;
@@ -141,6 +157,13 @@ export interface MetadataApi {
141
157
  * @returns Object with a Promise of type boolean for each rule.
142
158
  */
143
159
  getEntityAccessRules(objectType: string): EntityAccessRules;
160
+ /**
161
+ * @method
162
+ * @description Gets create, read, and update access rights for the provided entities via Batch call.
163
+ * @param objectType {string[]} Entity name(s).
164
+ * @returns Object with a Promise of type EntityAccessRule[] for each rule, where EntityAccessRule maps to the access rule of a given entity name.
165
+ */
166
+ getEntitiesAccessRules(objectTypes: string[]): EntitiesAccessRules;
144
167
  /**
145
168
  * @method
146
169
  * @description Checks access rights and gets metadata for an entity. Returns undefined if the entity does not exist.
@@ -183,10 +206,11 @@ export interface MetadataApi {
183
206
  * @param objectType {string} Finds relationships for the entity.
184
207
  * @param [relationshipObjectType] {string} Used for filtering the name of an expected related entity.
185
208
  * @param [relationshipName] {string} Used for filtering the name of an expected relationship.
209
+ * @param flattenMultiLinkIntoSingles whether Relationships with a One->(multiple) links will get flattened into many One->Single relationships
186
210
  * @returns A Promise resolving to an object containing relationship type metadata.
187
211
  * The object is empty if no relationship types exist.
188
212
  */
189
- getAllValidRelationshipTypes(objectType: string, relationshipObjectType?: string, relationshipName?: string): Promise<ValidRelationshipTypes>;
213
+ getAllValidRelationshipTypes(objectType: string, relationshipObjectType?: string, relationshipName?: string, flattenMultiLinkIntoSingles?: boolean): Promise<ValidRelationshipTypes>;
190
214
  /**
191
215
  * @method
192
216
  * @description Gets metadata for all resolved entities.
@@ -230,6 +254,7 @@ export interface MetadataApi {
230
254
  parentCode?: string;
231
255
  }): Promise<Picklist | undefined>;
232
256
  /**
257
+ * @deprecated
233
258
  * @method
234
259
  * @description Gets relationships with a specified end type.
235
260
  * @param endType {string} End type entity name.
@@ -237,4 +262,16 @@ export interface MetadataApi {
237
262
  * @returns A Promise resolving to a list of relationships, or an empty list if none are found.
238
263
  */
239
264
  getRelationshipsFilteredByEndType(endType: string, includeHeterogeneous?: boolean): Promise<RelationshipWithLabel[]>;
265
+ /**
266
+ * @method
267
+ * @description Gets relationships with a specified end type.
268
+ * @param endType endType {string} End type entity name.
269
+ * @param options see {@link OptionsForGetRelationshipsForObjectType}
270
+ */
271
+ getRelationshipsForObjectType(endType: string, options: OptionsForGetRelationshipsForObjectType): Promise<RelationshipWithLabel[]>;
272
+ }
273
+ export interface OptionsForGetRelationshipsForObjectType {
274
+ includeHeterogeneous?: boolean;
275
+ includeMultipleTypeRelationships?: boolean;
276
+ expandMultipleRelationshipsToSingle?: boolean;
240
277
  }
@@ -1,4 +1,4 @@
1
- import { Relationship, StoredObjectFieldDTO, Comment } from "../svi-datahub";
1
+ import { Comment, Relationship, StoredObjectFieldDTO } from "../svi-datahub";
2
2
  import { FileOperation } from "../file/file-api";
3
3
  import { PageModel } from "../page-model/page-model-api";
4
4
  import { ClientSheet, Sheet } from "../sheet/sheet-api";
@@ -84,6 +84,19 @@ export interface ObjectApi {
84
84
  * @return A Promise that resolves to the updated object when the object has successfully been updated.
85
85
  */
86
86
  updateObject(objectType: string, objectId: string, objectTypeId: number, objectTypeVersion: number, fieldValues: FieldValues, options?: UpdateObjectOptions): Promise<VIObject>;
87
+ /**
88
+ * @method
89
+ * @description Updates an existing object with the provided data.
90
+ * @param objectType {string} Object type.
91
+ * @param objectId {string} Object ID.
92
+ * @param objectTypeId {number} Object type ID.
93
+ * @param objectTypeVersion {number} Object type version.
94
+ * @param originalFieldValues {FieldValues} Field values before the object was edited
95
+ * @param newFieldValues {FieldValues} Field values after the object was edited
96
+ * @param [options] {UpdateObjectOptions} Optional extra parameters.
97
+ * @return A Promise that resolves to the updated object when the object has successfully been updated.
98
+ */
99
+ patchObject(objectType: string, objectId: string, objectTypeId: number, objectTypeVersion: number, originalFieldValues: FieldValues, newFieldValues: FieldValues, options?: UpdateObjectOptions): Promise<VIObject>;
87
100
  /**
88
101
  * @method
89
102
  * @description Deletes an object.
@@ -117,6 +130,15 @@ export interface ObjectApi {
117
130
  * @return A Promise that resolves to a relationship.
118
131
  */
119
132
  updateObjectRelationship(relationshipId: string, payload: any): Promise<ObjectRelationship>;
133
+ /**
134
+ * @method
135
+ * @description Updates an existing relationship in SAS Visual Investigator.
136
+ * @param relationshipId {string} Relationship ID.
137
+ * @param originalFieldValues {FieldValues} Field values before the relationship was edited
138
+ * @param newFieldValues {FieldValues} Field values after the relationship was edited
139
+ * @return A Promise that resolves to a relationship.
140
+ */
141
+ patchObjectRelationship(relationshipId: string, originalFieldValues: FieldValues, newFieldValues: FieldValues): Promise<ObjectRelationship>;
120
142
  /**
121
143
  * @method
122
144
  * @description Deletes relationship with the specified ID.
@@ -127,12 +149,12 @@ export interface ObjectApi {
127
149
  /**
128
150
  * @method
129
151
  * @description Creates a relationship between two objects.
130
- * @param from {VIObject} Object that relationship is from.
131
- * @param to {VIObject} Object that relationship is to.
152
+ * @param from {LinkObject} Object that relationship is from.
153
+ * @param to {LinkObject} Object that relationship is to.
132
154
  * @param relationship {ObjectRelationship} The relationship.
133
155
  * @return A Promise that resolves to an object.
134
156
  */
135
- relateObject(from: VIObject, to: VIObject, relationship: ObjectRelationship): Promise<ObjectRelationship>;
157
+ relateObject(from: LinkObject, to: LinkObject, relationship: ObjectRelationship): Promise<ObjectRelationship>;
136
158
  /**
137
159
  * @method
138
160
  * @description Gets object summary label.
@@ -144,12 +166,12 @@ export interface ObjectApi {
144
166
  /**
145
167
  * @method
146
168
  * @description Creates a new object and relates it with an existing one.
147
- * @param from {VIObject} Object that the relationship is from.
148
- * @param to {VIObject} Object that the relationship is to.
169
+ * @param from {LinkObject} existing Object that the relationship is from.
170
+ * @param to {NewLinkObject} new Object to be created and related to.
149
171
  * @param relationship {ObjectRelationship} The relationship.
150
172
  * @return A Promise that resolves to a newly created relationship.
151
173
  */
152
- createAndRelateObject(from: VIObject, to: VIObject, relationship: ObjectRelationship): Promise<ObjectRelationship>;
174
+ createAndRelateObject(from: LinkObject, to: NewLinkObject, relationship: ObjectRelationship): Promise<ObjectRelationship>;
153
175
  /**
154
176
  * @method
155
177
  * @description Processes an array of objects and formats them for display.
@@ -225,6 +247,8 @@ export interface VIObject {
225
247
  id: string;
226
248
  title?: string;
227
249
  }
250
+ export declare type LinkObject = Pick<VIObject, "id" | "objectTypeName">;
251
+ export declare type NewLinkObject = Pick<VIObject, "objectTypeName" | "fieldValues" | "fileOperations">;
228
252
  export interface ValidationResult {
229
253
  isValid: boolean;
230
254
  message?: string;
@@ -295,11 +319,14 @@ export interface NodeAttributes extends TypeAttributes {
295
319
  }>;
296
320
  };
297
321
  }
322
+ export declare enum ActionState {
323
+ Disabled = "disabled",
324
+ Hidden = "hidden"
325
+ }
298
326
  export interface ChildNodeAttrs {
299
327
  attributes?: {
300
328
  disabled: boolean;
301
- showActionHistory: boolean;
302
- showVersionHistory: boolean;
329
+ state?: ActionState;
303
330
  };
304
331
  id: string;
305
332
  category: string;
@@ -1,3 +1,8 @@
1
+ export var ActionState;
2
+ (function (ActionState) {
3
+ ActionState["Disabled"] = "disabled";
4
+ ActionState["Hidden"] = "hidden";
5
+ })(ActionState || (ActionState = {}));
1
6
  export var ConditionReferenceType;
2
7
  (function (ConditionReferenceType) {
3
8
  ConditionReferenceType["TemplateControl"] = "TEMPLATE_CONTROL";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sassoftware/vi-api",
3
- "version": "1.7.1",
3
+ "version": "1.15.2",
4
4
  "description": "Types used in the SAS Visual Investigator API",
5
5
  "keywords": [
6
6
  "SAS",
@@ -1,31 +1,4 @@
1
- import { Template, StoredObjectDTO } from "../svi-datahub";
2
- /**
3
- * SAS Visual Investigator API's representation of a UI-Router state.
4
- * Accessed from the window at window.sas.vi.pageState.
5
- */
6
- export interface StateObject {
7
- /** The parent StateObject. */
8
- parent: StateObject;
9
- /** Name used to register the state. */
10
- name: string;
11
- /** Parent StateObject array from this state up to the root. */
12
- path: StateObject[];
13
- data: any;
14
- /**
15
- * An object containing the parent States' names as keys and
16
- * true as their values.
17
- */
18
- includes: {
19
- [name: string]: boolean;
20
- };
21
- /**
22
- * Function to return the root node of this state's tree.
23
- *
24
- * @returns The root of this state's tree.
25
- */
26
- root(): StateObject;
27
- toString(): string;
28
- }
1
+ import { StoredObjectDTO, Template } from "../svi-datahub";
29
2
  export interface HomepageDesignerState {
30
3
  isNew: boolean;
31
4
  page: Template;
@@ -48,21 +21,21 @@ export interface PageStateApi {
48
21
  * @description Returns the state of the current page.
49
22
  * @returns An object containing the page state data or undefined if no page exists.
50
23
  */
51
- getCurrent(): StateObject | undefined;
24
+ getCurrent(): HomepageDesignerState | ObjectPageDesignerState | undefined;
52
25
  /**
53
26
  * @method
54
27
  * @description Returns the state of the page matching the ID.
55
28
  * @param id {string | number} Page ID for which the state will be returned.
56
29
  * @returns An object containing the page state data or undefined if the ID doesn't exist.
57
30
  */
58
- get(id: string | number): StateObject | undefined;
31
+ get(id: string | number): HomepageDesignerState | ObjectPageDesignerState | undefined;
59
32
  /**
60
33
  * @method
61
34
  * @description Creates a page state.
62
35
  * @param id {string | number} Page ID to be created.
63
- * @param state {StateObject} Object containing the state data required to create the page.
36
+ * @param state {HomepageDesignerState | ObjectPageDesignerState} Object containing the state data required to create the page.
64
37
  */
65
- add(id: string | number, state: StateObject): void;
38
+ add(id: string | number, state: HomepageDesignerState | ObjectPageDesignerState): void;
66
39
  /**
67
40
  * @method
68
41
  * @description Deletes a page state.
@@ -5,6 +5,12 @@ import { PageTemplateMetadata } from "../page-model/page-model-api";
5
5
  export interface ToolbarPropertyControl {
6
6
  typeAttributes: TypeAttributes;
7
7
  }
8
+ export interface EntityToolbarItem {
9
+ actionName: string;
10
+ attributes: {
11
+ [attr: string]: any;
12
+ };
13
+ }
8
14
  export interface PropertyConfig {
9
15
  [property: string]: any;
10
16
  order?: number;
@@ -28,6 +34,64 @@ export interface SelectedNode {
28
34
  [property: string]: any;
29
35
  };
30
36
  }
37
+ export declare type LocalizerType = "page" | "toolbar";
38
+ export declare type ControlPropertyLocalizer = ToolbarControlPropertyLocalizer | PageControlPropertyLocalizer;
39
+ export interface ToolbarControlPropertyLocalizer extends PropertyLocalizer<EntityToolbarItem> {
40
+ localizerType: "toolbar";
41
+ /**
42
+ * Generate resources to be inluded when the toolbar item is saved.
43
+ *
44
+ * @param propertyKey the control attribute
45
+ * @param control the toolbar item
46
+ * @returns the resource keys and values for the given toolbar item property
47
+ */
48
+ createResources: (propertyKey: string, control: EntityToolbarItem) => Record<string, string>;
49
+ /**
50
+ * Use generated resource keys & values to localize the given control property.
51
+ *
52
+ * @param propertyKey the control attribute to be localized
53
+ * @param control the toolbar item
54
+ * @param resources toolbar item resources
55
+ */
56
+ localizeControlAttribute: (propertyKey: string, control: EntityToolbarItem, resources: Record<string, string>) => void;
57
+ }
58
+ export interface PageControlPropertyLocalizer extends PropertyLocalizer<Control> {
59
+ localizerType: "page";
60
+ /**
61
+ * Generate resources to be included when the page control is saved.
62
+ * Page control resources are stored on the page template metadata
63
+ * and so resource keys should be made to be unique per control.
64
+ *
65
+ * @param propertyKey the control attribute
66
+ * @param control the page control
67
+ * @returns the resource keys and values for the given control property
68
+ */
69
+ createResources: (propertyKey: string, control: Control) => Record<string, string>;
70
+ /**
71
+ * Use generated resource keys & values to localize the given control property.
72
+ *
73
+ * @param propertyKey the control attribute to be localized
74
+ * @param control the page control
75
+ * @param resources page template resources
76
+ */
77
+ localizeControlAttribute: (propertyKey: string, control: Control, resources: Record<string, string>) => void;
78
+ }
79
+ /**
80
+ * Handle the localization of control properties for a given property type.
81
+ */
82
+ export interface PropertyLocalizer<T> {
83
+ /**
84
+ * control type to be localized
85
+ */
86
+ localizerType: LocalizerType;
87
+ /**
88
+ * property type to be localized.
89
+ * (the type that the property editor is registered against)
90
+ */
91
+ propertyType: string;
92
+ createResources: (propertyKey: string, control: T) => Record<string, string>;
93
+ localizeControlAttribute: (propertyKey: string, control: T, resources: Record<string, string>) => void;
94
+ }
31
95
  /**
32
96
  * This API is available on property editors.
33
97
  */
@@ -41,7 +105,7 @@ export interface EditorApi {
41
105
  onPropertyChange(handler: (category: string, property: string, currentValue: any, previousValue: any) => void): () => void;
42
106
  }
43
107
  /**
44
- * This API provides the utility or miscellaneous functionality in SAS Visual Investigator.
108
+ * This API pertains to page/toolbar control properties in SAS Visual Investigator.
45
109
  * Accessed from the window at window.sas.vi.property.
46
110
  */
47
111
  export interface PropertyApi {
@@ -57,6 +121,12 @@ export interface PropertyApi {
57
121
  * @param [metadataFn] {PropertyApi~getPropertyEditorMetadata} Function to provide custom metadata.
58
122
  */
59
123
  registerCustomEditor(elementName: string, type: string, validatorFn?: (propertyConfig: PropertyConfig, propertyKey: string, control: Control | ToolbarPropertyControl) => boolean, metadataFn?: (propertyConfig: PropertyConfig, propertyKey: string, control: Control | ToolbarPropertyControl) => PageTemplateMetadata): void;
124
+ /**
125
+ * Register a localizer to manage internationalization resources for control properties of a given type.
126
+ * Properties will be localized unless they they are explicitly configured with localizable=false (see {@link PropertyConfig})
127
+ * @param localizer property localizer which defines resource keys to be saved, and parses the same keys to localize the properties.
128
+ */
129
+ registerPropertyLocalizer(localizer: ControlPropertyLocalizer): void;
60
130
  /**
61
131
  * @method
62
132
  * @description Determines whether or not the child object data source property editor is valid.
package/public-api.d.ts CHANGED
@@ -1 +1 @@
1
- export { SviClientApi, SviAdminApi, SviWindow } from "./index";
1
+ export { SviClientApi, SviAdminApi, SviWindow, SviApi } from "./index";
package/public-api.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -2,6 +2,7 @@ export interface I18nResources {
2
2
  [key: string]: string | I18nResources;
3
3
  }
4
4
  /**
5
+ * @deprecated Use window.sas.viInit.registerResourceBundle to register resources before the rest of the Visual Investigator API is ready.
5
6
  * This API provides the resource functionality in SAS Visual Investigator.
6
7
  * Accessed from the window at window.sas.vi.resource.
7
8
  */