@vcd/sdk 0.13.0 → 15.0.0
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/README.md +3 -118
- package/client/client/api.result.service.d.ts +20 -0
- package/client/client/constants.d.ts +10 -0
- package/client/client/index.d.ts +7 -0
- package/client/client/logging.interceptor.d.ts +14 -0
- package/client/client/request.headers.interceptor.d.ts +20 -0
- package/client/client/response.normalization.interceptor.d.ts +39 -0
- package/client/client/vcd.api.client.d.ts +351 -0
- package/client/client/vcd.http.client.d.ts +32 -0
- package/client/client/vcd.transfer.client.d.ts +121 -0
- package/client/container-hooks/index.d.ts +58 -0
- package/client/index.d.ts +2 -0
- package/client/openapi.d.ts +76 -0
- package/client/query/filter.builder.d.ts +162 -0
- package/client/query/index.d.ts +2 -0
- package/client/query/query.builder.d.ts +30 -0
- package/common/container-hooks.d.ts +2 -2
- package/core/plugin.module.d.ts +10 -5
- package/esm2020/client/client/api.result.service.mjs +43 -0
- package/esm2020/client/client/constants.mjs +13 -0
- package/esm2020/client/client/index.mjs +8 -0
- package/esm2020/client/client/logging.interceptor.mjs +44 -0
- package/esm2020/client/client/request.headers.interceptor.mjs +91 -0
- package/esm2020/client/client/response.normalization.interceptor.mjs +59 -0
- package/esm2020/client/client/vcd.api.client.mjs +602 -0
- package/esm2020/client/client/vcd.http.client.mjs +52 -0
- package/esm2020/client/client/vcd.transfer.client.mjs +166 -0
- package/esm2020/client/container-hooks/index.mjs +57 -0
- package/esm2020/client/index.mjs +3 -0
- package/esm2020/client/openapi.mjs +16 -0
- package/esm2020/client/query/filter.builder.mjs +195 -0
- package/esm2020/client/query/index.mjs +3 -0
- package/esm2020/client/query/query.builder.mjs +79 -0
- package/esm2020/common/container-hooks.mjs +74 -0
- package/esm2020/common/index.mjs +2 -0
- package/esm2020/core/index.mjs +2 -0
- package/esm2020/core/plugin.module.mjs +18 -0
- package/esm2020/main.mjs +45 -0
- package/esm2020/public-api.mjs +8 -0
- package/esm2020/vcd-sdk.mjs +5 -0
- package/fesm2015/vcd-sdk.mjs +1513 -0
- package/fesm2015/vcd-sdk.mjs.map +1 -0
- package/fesm2020/vcd-sdk.mjs +1508 -0
- package/fesm2020/vcd-sdk.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/main.d.ts +11 -5
- package/package.json +30 -39
- package/public-api.d.ts +1 -1
- package/LICENSE.txt +0 -12
- package/bundles/vcd-sdk.umd.js +0 -810
- package/bundles/vcd-sdk.umd.js.map +0 -1
- package/bundles/vcd-sdk.umd.min.js +0 -16
- package/bundles/vcd-sdk.umd.min.js.map +0 -1
- package/esm2015/common/container-hooks.js +0 -219
- package/esm2015/common/index.js +0 -6
- package/esm2015/core/index.js +0 -6
- package/esm2015/core/plugin.module.js +0 -53
- package/esm2015/i18n/index.js +0 -8
- package/esm2015/i18n/translate.pipe.js +0 -92
- package/esm2015/i18n/translate.service.js +0 -229
- package/esm2015/i18n/translation.loader.js +0 -63
- package/esm2015/main.js +0 -37
- package/esm2015/public-api.js +0 -12
- package/esm2015/vcd-sdk.js +0 -10
- package/esm5/common/container-hooks.js +0 -266
- package/esm5/common/index.js +0 -6
- package/esm5/core/index.js +0 -6
- package/esm5/core/plugin.module.js +0 -64
- package/esm5/i18n/index.js +0 -8
- package/esm5/i18n/translate.pipe.js +0 -108
- package/esm5/i18n/translate.service.js +0 -280
- package/esm5/i18n/translation.loader.js +0 -68
- package/esm5/main.js +0 -41
- package/esm5/public-api.js +0 -12
- package/esm5/vcd-sdk.js +0 -10
- package/fesm2015/vcd-sdk.js +0 -511
- package/fesm2015/vcd-sdk.js.map +0 -1
- package/fesm5/vcd-sdk.js +0 -620
- package/fesm5/vcd-sdk.js.map +0 -1
- package/i18n/index.d.ts +0 -3
- package/i18n/translate.pipe.d.ts +0 -12
- package/i18n/translate.service.d.ts +0 -21
- package/i18n/translation.loader.d.ts +0 -11
- package/schematics/collection.json +0 -10
- package/schematics/ng-add/index.d.ts +0 -3
- package/schematics/ng-add/index.js +0 -101
- package/schematics/ng-add/index.ts +0 -134
- package/schematics/ng-add/schema.d.ts +0 -8
- package/schematics/ng-add/schema.json +0 -19
- package/vcd-sdk.d.ts +0 -5
- package/vcd-sdk.metadata.json +0 -1
package/fesm5/vcd-sdk.js
DELETED
|
@@ -1,620 +0,0 @@
|
|
|
1
|
-
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
2
|
-
import { InjectionToken, Injectable, Inject, Pipe, ChangeDetectorRef, NgModule } from '@angular/core';
|
|
3
|
-
import { CommonModule } from '@angular/common';
|
|
4
|
-
import { RequestHeadersInterceptor, LoggingInterceptor, ResponseNormalizationInterceptor, VcdHttpClient, VcdApiClient } from '@vcd/angular-client';
|
|
5
|
-
export { ApiResult, ApiResultService, Filter, HATEOAS_HEADER, LinkRelType, LoggingInterceptor, MAX_CHUNK_RETRY_COUNT, MAX_CHUNK_SIZE, Query, RequestHeadersInterceptor, ResponseNormalizationInterceptor, TRANSFER_LINK_REL, TransferError, VcdApiClient, VcdHttpClient, VcdTransferClient, client, parseHeaderHateoasLinks, query } from '@vcd/angular-client';
|
|
6
|
-
import { __extends, __spread } from 'tslib';
|
|
7
|
-
import { of, Observable } from 'rxjs';
|
|
8
|
-
import { share, take } from 'rxjs/operators';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @fileoverview added by tsickle
|
|
12
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
13
|
-
*/
|
|
14
|
-
// Bind straight into the hooks provided by the container.
|
|
15
|
-
if (!((/** @type {?} */ (window))).System || !((/** @type {?} */ (window))).System.registry || !((/** @type {?} */ (window))).System.registry.get) {
|
|
16
|
-
throw new Error('SystemJS registry not found');
|
|
17
|
-
}
|
|
18
|
-
/** @type {?} */
|
|
19
|
-
var containerHooks = ((/** @type {?} */ (window))).System.registry.get('@vcd/common');
|
|
20
|
-
if (!containerHooks) {
|
|
21
|
-
containerHooks = ((/** @type {?} */ (window))).System.registry.get('@vcd-ui/common');
|
|
22
|
-
}
|
|
23
|
-
if (!containerHooks) {
|
|
24
|
-
throw new Error('VCD UI container hooks not present in SystemJS registry');
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Wire in as a string. Gives the root URL for API access (for example, the load balancer URL
|
|
28
|
-
* or the single-cell URL).
|
|
29
|
-
* @type {?}
|
|
30
|
-
*/
|
|
31
|
-
var API_ROOT_URL = containerHooks.API_ROOT_URL;
|
|
32
|
-
/**
|
|
33
|
-
* Wire in as a string. Gives the root URL for the legacy Flex application.
|
|
34
|
-
* @type {?}
|
|
35
|
-
*/
|
|
36
|
-
var FLEX_APP_URL = containerHooks.API_ROOT_URL;
|
|
37
|
-
/**
|
|
38
|
-
* Wire in as a string. Gives the current scope of the VCD-UI. As of current, this will be
|
|
39
|
-
* either 'tenant' for the tenant portal, or 'service-provider' for the service-provider portal.
|
|
40
|
-
* @type {?}
|
|
41
|
-
*/
|
|
42
|
-
var SESSION_SCOPE = containerHooks.SESSION_SCOPE;
|
|
43
|
-
/**
|
|
44
|
-
* Wire in as a string. Gives the unique name (not the display name) of the current tenant
|
|
45
|
-
* organization that the VCD-UI is being used for.
|
|
46
|
-
* @type {?}
|
|
47
|
-
*/
|
|
48
|
-
var SESSION_ORGANIZATION = containerHooks.SESSION_ORGANIZATION;
|
|
49
|
-
/**
|
|
50
|
-
* Wire in as a string. Gives the UUID identifier of the current tenant
|
|
51
|
-
* organization that the VCD-UI is being used for.
|
|
52
|
-
* @type {?}
|
|
53
|
-
*/
|
|
54
|
-
var SESSION_ORG_ID = containerHooks.SESSION_ORG_ID ? containerHooks.SESSION_ORG_ID : '';
|
|
55
|
-
/**
|
|
56
|
-
* Wire in as a string. Gives the full root path for module assets (e.g. images, scripts, text files)
|
|
57
|
-
*
|
|
58
|
-
* ATTENTION!
|
|
59
|
-
* Add || new InjectionToken to workaround the Angular security mechanics which prevent use of injection tokens
|
|
60
|
-
* which potentially are not defiend. The same fix can be applied for the rest tokens if needed.
|
|
61
|
-
* @type {?}
|
|
62
|
-
*/
|
|
63
|
-
var EXTENSION_ASSET_URL = containerHooks.EXTENSION_ASSET_URL || new InjectionToken('EXTENSION_ASSET_URL');
|
|
64
|
-
/**
|
|
65
|
-
* Wire in as a string. Gives the Angular 2 route that the module is registered under.
|
|
66
|
-
* @type {?}
|
|
67
|
-
*/
|
|
68
|
-
var EXTENSION_ROUTE = containerHooks.EXTENSION_ROUTE;
|
|
69
|
-
/**
|
|
70
|
-
* Wire in as a boolean. True if running under the SDK, false if running in production.
|
|
71
|
-
* @type {?}
|
|
72
|
-
*/
|
|
73
|
-
var SDK_MODE = containerHooks.SDK_MODE;
|
|
74
|
-
// WARNING: interface has both a type and a value, skipping emit
|
|
75
|
-
/** @type {?} */
|
|
76
|
-
var ExtensionNavRegistrationAction = containerHooks.ExtensionNavRegistrationAction;
|
|
77
|
-
// WARNING: interface has both a type and a value, skipping emit
|
|
78
|
-
/** @type {?} */
|
|
79
|
-
var AuthTokenHolderService = containerHooks.AuthTokenHolderService;
|
|
80
|
-
/**
|
|
81
|
-
* Every component referenced by an entity action extension point must inherit from this.
|
|
82
|
-
* @abstract
|
|
83
|
-
*/
|
|
84
|
-
// tslint:disable-next-line:class-name
|
|
85
|
-
var /**
|
|
86
|
-
* Every component referenced by an entity action extension point must inherit from this.
|
|
87
|
-
* @abstract
|
|
88
|
-
*/
|
|
89
|
-
// tslint:disable-next-line:class-name
|
|
90
|
-
_EntityActionExtensionComponent = /** @class */ (function () {
|
|
91
|
-
function _EntityActionExtensionComponent() {
|
|
92
|
-
}
|
|
93
|
-
return _EntityActionExtensionComponent;
|
|
94
|
-
}());
|
|
95
|
-
/** @type {?} */
|
|
96
|
-
var EntityActionExtensionComponent = containerHooks.EntityActionExtensionComponent;
|
|
97
|
-
// tslint:disable-next-line:class-name
|
|
98
|
-
/**
|
|
99
|
-
* @abstract
|
|
100
|
-
* @template P, R, E
|
|
101
|
-
*/
|
|
102
|
-
var
|
|
103
|
-
// tslint:disable-next-line:class-name
|
|
104
|
-
/**
|
|
105
|
-
* @abstract
|
|
106
|
-
* @template P, R, E
|
|
107
|
-
*/
|
|
108
|
-
_WizardExtensionComponent = /** @class */ (function () {
|
|
109
|
-
function _WizardExtensionComponent() {
|
|
110
|
-
}
|
|
111
|
-
return _WizardExtensionComponent;
|
|
112
|
-
}());
|
|
113
|
-
/** @type {?} */
|
|
114
|
-
var WizardExtensionComponent = containerHooks.WizardExtensionComponent;
|
|
115
|
-
// tslint:disable-next-line:class-name
|
|
116
|
-
/**
|
|
117
|
-
* @abstract
|
|
118
|
-
* @template P, R, E
|
|
119
|
-
*/
|
|
120
|
-
var
|
|
121
|
-
// tslint:disable-next-line:class-name
|
|
122
|
-
/**
|
|
123
|
-
* @abstract
|
|
124
|
-
* @template P, R, E
|
|
125
|
-
*/
|
|
126
|
-
_WizardExtensionWithValidationComponent = /** @class */ (function (_super) {
|
|
127
|
-
__extends(_WizardExtensionWithValidationComponent, _super);
|
|
128
|
-
function _WizardExtensionWithValidationComponent() {
|
|
129
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
130
|
-
}
|
|
131
|
-
return _WizardExtensionWithValidationComponent;
|
|
132
|
-
}(_WizardExtensionComponent));
|
|
133
|
-
// tslint:disable-next-line:max-line-length
|
|
134
|
-
/** @type {?} */
|
|
135
|
-
var WizardExtensionWithValidationComponent = containerHooks.WizardExtensionWithValidationComponent;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @fileoverview added by tsickle
|
|
139
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
143
|
-
__proto__: null,
|
|
144
|
-
API_ROOT_URL: API_ROOT_URL,
|
|
145
|
-
FLEX_APP_URL: FLEX_APP_URL,
|
|
146
|
-
SESSION_SCOPE: SESSION_SCOPE,
|
|
147
|
-
SESSION_ORGANIZATION: SESSION_ORGANIZATION,
|
|
148
|
-
SESSION_ORG_ID: SESSION_ORG_ID,
|
|
149
|
-
EXTENSION_ASSET_URL: EXTENSION_ASSET_URL,
|
|
150
|
-
EXTENSION_ROUTE: EXTENSION_ROUTE,
|
|
151
|
-
SDK_MODE: SDK_MODE,
|
|
152
|
-
ExtensionNavRegistrationAction: ExtensionNavRegistrationAction,
|
|
153
|
-
AuthTokenHolderService: AuthTokenHolderService,
|
|
154
|
-
_EntityActionExtensionComponent: _EntityActionExtensionComponent,
|
|
155
|
-
EntityActionExtensionComponent: EntityActionExtensionComponent,
|
|
156
|
-
_WizardExtensionComponent: _WizardExtensionComponent,
|
|
157
|
-
WizardExtensionComponent: WizardExtensionComponent,
|
|
158
|
-
_WizardExtensionWithValidationComponent: _WizardExtensionWithValidationComponent,
|
|
159
|
-
WizardExtensionWithValidationComponent: WizardExtensionWithValidationComponent
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* @fileoverview added by tsickle
|
|
164
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
165
|
-
*/
|
|
166
|
-
var PluginModule = /** @class */ (function () {
|
|
167
|
-
function PluginModule(appStore, translate) {
|
|
168
|
-
this.appStore = appStore;
|
|
169
|
-
if (translate) {
|
|
170
|
-
this.translate = translate;
|
|
171
|
-
this.translate.prepareTranslations(this.getSupportedLanguages(), this.getDefaultLanguage());
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @protected
|
|
176
|
-
* @param {?} extension
|
|
177
|
-
* @return {?}
|
|
178
|
-
*/
|
|
179
|
-
PluginModule.prototype.registerExtension = /**
|
|
180
|
-
* @protected
|
|
181
|
-
* @param {?} extension
|
|
182
|
-
* @return {?}
|
|
183
|
-
*/
|
|
184
|
-
function (extension) {
|
|
185
|
-
this.appStore.dispatch(new ExtensionNavRegistrationAction(extension));
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* @protected
|
|
189
|
-
* @return {?}
|
|
190
|
-
*/
|
|
191
|
-
PluginModule.prototype.getDefaultLanguage = /**
|
|
192
|
-
* @protected
|
|
193
|
-
* @return {?}
|
|
194
|
-
*/
|
|
195
|
-
function () {
|
|
196
|
-
return 'en';
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* @protected
|
|
200
|
-
* @return {?}
|
|
201
|
-
*/
|
|
202
|
-
PluginModule.prototype.getSupportedLanguages = /**
|
|
203
|
-
* @protected
|
|
204
|
-
* @return {?}
|
|
205
|
-
*/
|
|
206
|
-
function () {
|
|
207
|
-
return ['en'];
|
|
208
|
-
};
|
|
209
|
-
return PluginModule;
|
|
210
|
-
}());
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* @fileoverview added by tsickle
|
|
214
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
var index$1 = /*#__PURE__*/Object.freeze({
|
|
218
|
-
__proto__: null,
|
|
219
|
-
PluginModule: PluginModule
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @fileoverview added by tsickle
|
|
224
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
225
|
-
*/
|
|
226
|
-
var TranslationLoader = /** @class */ (function () {
|
|
227
|
-
function TranslationLoader(http, assetUrl) {
|
|
228
|
-
this.http = http;
|
|
229
|
-
this.assetUrl = assetUrl;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* @param {?} language
|
|
233
|
-
* @return {?}
|
|
234
|
-
*/
|
|
235
|
-
TranslationLoader.prototype.getTranslation = /**
|
|
236
|
-
* @param {?} language
|
|
237
|
-
* @return {?}
|
|
238
|
-
*/
|
|
239
|
-
function (language) {
|
|
240
|
-
return this.http.get("" + this.assetUrl + TranslationLoader.PREFIX + language + TranslationLoader.SUFFIX);
|
|
241
|
-
};
|
|
242
|
-
/**
|
|
243
|
-
* @return {?}
|
|
244
|
-
*/
|
|
245
|
-
TranslationLoader.prototype.getCombinedTranslation = /**
|
|
246
|
-
* @return {?}
|
|
247
|
-
*/
|
|
248
|
-
function () {
|
|
249
|
-
return this.http.get(this.assetUrl + "/../i18n" + TranslationLoader.SUFFIX);
|
|
250
|
-
};
|
|
251
|
-
TranslationLoader.PREFIX = '/i18n/';
|
|
252
|
-
TranslationLoader.SUFFIX = '.json';
|
|
253
|
-
TranslationLoader.decorators = [
|
|
254
|
-
{ type: Injectable }
|
|
255
|
-
];
|
|
256
|
-
/** @nocollapse */
|
|
257
|
-
TranslationLoader.ctorParameters = function () { return [
|
|
258
|
-
{ type: HttpClient },
|
|
259
|
-
{ type: String, decorators: [{ type: Inject, args: [EXTENSION_ASSET_URL,] }] }
|
|
260
|
-
]; };
|
|
261
|
-
return TranslationLoader;
|
|
262
|
-
}());
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* @fileoverview added by tsickle
|
|
266
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
267
|
-
*/
|
|
268
|
-
var TranslateService = /** @class */ (function () {
|
|
269
|
-
function TranslateService(loader) {
|
|
270
|
-
this.loader = loader;
|
|
271
|
-
this.pending = false;
|
|
272
|
-
this.translations = {};
|
|
273
|
-
this._combinedTranslations = true;
|
|
274
|
-
this._supportedLanguages = [];
|
|
275
|
-
this._defaultLanguage = '';
|
|
276
|
-
}
|
|
277
|
-
Object.defineProperty(TranslateService.prototype, "combinedTranslations", {
|
|
278
|
-
get: /**
|
|
279
|
-
* @return {?}
|
|
280
|
-
*/
|
|
281
|
-
function () {
|
|
282
|
-
return this._combinedTranslations;
|
|
283
|
-
},
|
|
284
|
-
set: /**
|
|
285
|
-
* @param {?} _combinedTranslations
|
|
286
|
-
* @return {?}
|
|
287
|
-
*/
|
|
288
|
-
function (_combinedTranslations) {
|
|
289
|
-
this._combinedTranslations = _combinedTranslations;
|
|
290
|
-
},
|
|
291
|
-
enumerable: true,
|
|
292
|
-
configurable: true
|
|
293
|
-
});
|
|
294
|
-
Object.defineProperty(TranslateService.prototype, "supportedLanguages", {
|
|
295
|
-
get: /**
|
|
296
|
-
* @return {?}
|
|
297
|
-
*/
|
|
298
|
-
function () {
|
|
299
|
-
return this._supportedLanguages;
|
|
300
|
-
},
|
|
301
|
-
set: /**
|
|
302
|
-
* @param {?} _supportedLanguages
|
|
303
|
-
* @return {?}
|
|
304
|
-
*/
|
|
305
|
-
function (_supportedLanguages) {
|
|
306
|
-
this._supportedLanguages = _supportedLanguages;
|
|
307
|
-
},
|
|
308
|
-
enumerable: true,
|
|
309
|
-
configurable: true
|
|
310
|
-
});
|
|
311
|
-
Object.defineProperty(TranslateService.prototype, "defaultLanguage", {
|
|
312
|
-
get: /**
|
|
313
|
-
* @return {?}
|
|
314
|
-
*/
|
|
315
|
-
function () {
|
|
316
|
-
return this._defaultLanguage;
|
|
317
|
-
},
|
|
318
|
-
set: /**
|
|
319
|
-
* @param {?} _defaultLanguage
|
|
320
|
-
* @return {?}
|
|
321
|
-
*/
|
|
322
|
-
function (_defaultLanguage) {
|
|
323
|
-
this._defaultLanguage = _defaultLanguage;
|
|
324
|
-
},
|
|
325
|
-
enumerable: true,
|
|
326
|
-
configurable: true
|
|
327
|
-
});
|
|
328
|
-
/**
|
|
329
|
-
* @param {?} supportedLanguages
|
|
330
|
-
* @param {?} defaultLanguage
|
|
331
|
-
* @return {?}
|
|
332
|
-
*/
|
|
333
|
-
TranslateService.prototype.prepareTranslations = /**
|
|
334
|
-
* @param {?} supportedLanguages
|
|
335
|
-
* @param {?} defaultLanguage
|
|
336
|
-
* @return {?}
|
|
337
|
-
*/
|
|
338
|
-
function (supportedLanguages, defaultLanguage) {
|
|
339
|
-
this._supportedLanguages = supportedLanguages;
|
|
340
|
-
this._defaultLanguage = defaultLanguage;
|
|
341
|
-
this._selectedLanguage = this.getBestMatchSupportedLanguage(navigator.language);
|
|
342
|
-
this.getTranslation(this._selectedLanguage);
|
|
343
|
-
};
|
|
344
|
-
/**
|
|
345
|
-
* @private
|
|
346
|
-
* @param {?} requestedLanguage
|
|
347
|
-
* @return {?}
|
|
348
|
-
*/
|
|
349
|
-
TranslateService.prototype.getBestMatchSupportedLanguage = /**
|
|
350
|
-
* @private
|
|
351
|
-
* @param {?} requestedLanguage
|
|
352
|
-
* @return {?}
|
|
353
|
-
*/
|
|
354
|
-
function (requestedLanguage) {
|
|
355
|
-
if (this._supportedLanguages.indexOf(requestedLanguage) > -1) {
|
|
356
|
-
return requestedLanguage;
|
|
357
|
-
}
|
|
358
|
-
/** @type {?} */
|
|
359
|
-
var altLanguage = requestedLanguage.split('-')[0];
|
|
360
|
-
if (altLanguage === requestedLanguage) {
|
|
361
|
-
return this._defaultLanguage;
|
|
362
|
-
}
|
|
363
|
-
return (this._supportedLanguages.indexOf(altLanguage) > -1) ? altLanguage : this._defaultLanguage;
|
|
364
|
-
};
|
|
365
|
-
/**
|
|
366
|
-
* @param {?} language
|
|
367
|
-
* @return {?}
|
|
368
|
-
*/
|
|
369
|
-
TranslateService.prototype.getTranslation = /**
|
|
370
|
-
* @param {?} language
|
|
371
|
-
* @return {?}
|
|
372
|
-
*/
|
|
373
|
-
function (language) {
|
|
374
|
-
var _this = this;
|
|
375
|
-
this.pending = true;
|
|
376
|
-
this.translation$ = this._combinedTranslations ?
|
|
377
|
-
this.loader.getCombinedTranslation() : this.loader.getTranslation(language).pipe(share());
|
|
378
|
-
this.translation$.pipe(take(1)).subscribe((/**
|
|
379
|
-
* @param {?} result
|
|
380
|
-
* @return {?}
|
|
381
|
-
*/
|
|
382
|
-
function (result) {
|
|
383
|
-
_this.translations = result;
|
|
384
|
-
_this.pending = false;
|
|
385
|
-
}), (/**
|
|
386
|
-
* @param {?} error
|
|
387
|
-
* @return {?}
|
|
388
|
-
*/
|
|
389
|
-
function (error) {
|
|
390
|
-
_this.pending = false;
|
|
391
|
-
}));
|
|
392
|
-
return this.translation$;
|
|
393
|
-
};
|
|
394
|
-
/**
|
|
395
|
-
* @private
|
|
396
|
-
* @param {?} key
|
|
397
|
-
* @param {...?} args
|
|
398
|
-
* @return {?}
|
|
399
|
-
*/
|
|
400
|
-
TranslateService.prototype.getParsedResult = /**
|
|
401
|
-
* @private
|
|
402
|
-
* @param {?} key
|
|
403
|
-
* @param {...?} args
|
|
404
|
-
* @return {?}
|
|
405
|
-
*/
|
|
406
|
-
function (key) {
|
|
407
|
-
var args = [];
|
|
408
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
409
|
-
args[_i - 1] = arguments[_i];
|
|
410
|
-
}
|
|
411
|
-
/** @type {?} */
|
|
412
|
-
var result = (this._combinedTranslations && this.translations[this._selectedLanguage]) ?
|
|
413
|
-
this.translations[this._selectedLanguage][key] : this.translations[key];
|
|
414
|
-
if (Array.isArray(result)) {
|
|
415
|
-
result = result.join('');
|
|
416
|
-
}
|
|
417
|
-
return !result ? "#" + key + "#" : result.replace(/{([0-9]+)}/g, (/**
|
|
418
|
-
* @param {?} _
|
|
419
|
-
* @param {...?} n
|
|
420
|
-
* @return {?}
|
|
421
|
-
*/
|
|
422
|
-
function (_) {
|
|
423
|
-
var n = [];
|
|
424
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
425
|
-
n[_i - 1] = arguments[_i];
|
|
426
|
-
}
|
|
427
|
-
// tslint:disable-next-line: radix
|
|
428
|
-
/** @type {?} */
|
|
429
|
-
var idx = parseInt(n[0]);
|
|
430
|
-
if (args && typeof args[idx] !== 'undefined') {
|
|
431
|
-
return args[idx];
|
|
432
|
-
}
|
|
433
|
-
return '';
|
|
434
|
-
}));
|
|
435
|
-
};
|
|
436
|
-
/**
|
|
437
|
-
* @param {?} key
|
|
438
|
-
* @param {...?} args
|
|
439
|
-
* @return {?}
|
|
440
|
-
*/
|
|
441
|
-
TranslateService.prototype.get = /**
|
|
442
|
-
* @param {?} key
|
|
443
|
-
* @param {...?} args
|
|
444
|
-
* @return {?}
|
|
445
|
-
*/
|
|
446
|
-
function (key) {
|
|
447
|
-
var _this = this;
|
|
448
|
-
var args = [];
|
|
449
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
450
|
-
args[_i - 1] = arguments[_i];
|
|
451
|
-
}
|
|
452
|
-
if (!this.pending) {
|
|
453
|
-
return of(this.getParsedResult.apply(this, __spread([key], args)));
|
|
454
|
-
}
|
|
455
|
-
// tslint:disable-next-line: deprecation
|
|
456
|
-
return Observable.create((/**
|
|
457
|
-
* @param {?} observer
|
|
458
|
-
* @return {?}
|
|
459
|
-
*/
|
|
460
|
-
function (observer) {
|
|
461
|
-
/** @type {?} */
|
|
462
|
-
var onComplete = (/**
|
|
463
|
-
* @param {?} result
|
|
464
|
-
* @return {?}
|
|
465
|
-
*/
|
|
466
|
-
function (result) {
|
|
467
|
-
observer.next(result);
|
|
468
|
-
observer.complete();
|
|
469
|
-
});
|
|
470
|
-
/** @type {?} */
|
|
471
|
-
var onError = (/**
|
|
472
|
-
* @param {?} error
|
|
473
|
-
* @return {?}
|
|
474
|
-
*/
|
|
475
|
-
function (error) {
|
|
476
|
-
observer.error(error);
|
|
477
|
-
});
|
|
478
|
-
_this.translation$.subscribe((/**
|
|
479
|
-
* @param {?} result
|
|
480
|
-
* @return {?}
|
|
481
|
-
*/
|
|
482
|
-
function (result) {
|
|
483
|
-
result = _this.getParsedResult.apply(_this, __spread([key], args));
|
|
484
|
-
onComplete(result);
|
|
485
|
-
}), onError);
|
|
486
|
-
}));
|
|
487
|
-
};
|
|
488
|
-
TranslateService.decorators = [
|
|
489
|
-
{ type: Injectable }
|
|
490
|
-
];
|
|
491
|
-
/** @nocollapse */
|
|
492
|
-
TranslateService.ctorParameters = function () { return [
|
|
493
|
-
{ type: TranslationLoader }
|
|
494
|
-
]; };
|
|
495
|
-
return TranslateService;
|
|
496
|
-
}());
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* @fileoverview added by tsickle
|
|
500
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
501
|
-
*/
|
|
502
|
-
var TranslatePipe = /** @class */ (function () {
|
|
503
|
-
function TranslatePipe(translate, changeDetector) {
|
|
504
|
-
this.translate = translate;
|
|
505
|
-
this.changeDetector = changeDetector;
|
|
506
|
-
this.value = '';
|
|
507
|
-
this.lastKey = '';
|
|
508
|
-
this.lastArgs = [];
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* @param {?} key
|
|
512
|
-
* @param {...?} args
|
|
513
|
-
* @return {?}
|
|
514
|
-
*/
|
|
515
|
-
TranslatePipe.prototype.transform = /**
|
|
516
|
-
* @param {?} key
|
|
517
|
-
* @param {...?} args
|
|
518
|
-
* @return {?}
|
|
519
|
-
*/
|
|
520
|
-
function (key) {
|
|
521
|
-
var args = [];
|
|
522
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
523
|
-
args[_i - 1] = arguments[_i];
|
|
524
|
-
}
|
|
525
|
-
if (!key || key.length === 0) {
|
|
526
|
-
return key;
|
|
527
|
-
}
|
|
528
|
-
if (key === this.lastKey && args === this.lastArgs) {
|
|
529
|
-
return this.value;
|
|
530
|
-
}
|
|
531
|
-
this.lastKey = key;
|
|
532
|
-
this.lastArgs = args;
|
|
533
|
-
this.updateValue(key, args);
|
|
534
|
-
return this.value;
|
|
535
|
-
};
|
|
536
|
-
/**
|
|
537
|
-
* @private
|
|
538
|
-
* @param {?} key
|
|
539
|
-
* @param {?} args
|
|
540
|
-
* @return {?}
|
|
541
|
-
*/
|
|
542
|
-
TranslatePipe.prototype.updateValue = /**
|
|
543
|
-
* @private
|
|
544
|
-
* @param {?} key
|
|
545
|
-
* @param {?} args
|
|
546
|
-
* @return {?}
|
|
547
|
-
*/
|
|
548
|
-
function (key, args) {
|
|
549
|
-
var _a;
|
|
550
|
-
var _this = this;
|
|
551
|
-
(_a = this.translate).get.apply(_a, __spread([key], args)).subscribe((/**
|
|
552
|
-
* @param {?} result
|
|
553
|
-
* @return {?}
|
|
554
|
-
*/
|
|
555
|
-
function (result) {
|
|
556
|
-
_this.value = result;
|
|
557
|
-
_this.changeDetector.markForCheck();
|
|
558
|
-
}));
|
|
559
|
-
};
|
|
560
|
-
TranslatePipe.decorators = [
|
|
561
|
-
{ type: Injectable },
|
|
562
|
-
{ type: Pipe, args: [{
|
|
563
|
-
name: 'translate',
|
|
564
|
-
pure: false
|
|
565
|
-
},] }
|
|
566
|
-
];
|
|
567
|
-
/** @nocollapse */
|
|
568
|
-
TranslatePipe.ctorParameters = function () { return [
|
|
569
|
-
{ type: TranslateService },
|
|
570
|
-
{ type: ChangeDetectorRef }
|
|
571
|
-
]; };
|
|
572
|
-
return TranslatePipe;
|
|
573
|
-
}());
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* @fileoverview added by tsickle
|
|
577
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
|
-
var index$2 = /*#__PURE__*/Object.freeze({
|
|
581
|
-
__proto__: null,
|
|
582
|
-
TranslatePipe: TranslatePipe,
|
|
583
|
-
TranslateService: TranslateService,
|
|
584
|
-
TranslationLoader: TranslationLoader
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* @fileoverview added by tsickle
|
|
589
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
590
|
-
*/
|
|
591
|
-
/**
|
|
592
|
-
* Extensions should import this module. They can then wire in SDK components as desired.
|
|
593
|
-
*/
|
|
594
|
-
var VcdSdkModule = /** @class */ (function () {
|
|
595
|
-
function VcdSdkModule() {
|
|
596
|
-
}
|
|
597
|
-
VcdSdkModule.decorators = [
|
|
598
|
-
{ type: NgModule, args: [{
|
|
599
|
-
imports: [
|
|
600
|
-
HttpClientModule,
|
|
601
|
-
CommonModule,
|
|
602
|
-
],
|
|
603
|
-
declarations: [TranslatePipe],
|
|
604
|
-
exports: [TranslatePipe],
|
|
605
|
-
providers: [
|
|
606
|
-
TranslateService,
|
|
607
|
-
TranslationLoader,
|
|
608
|
-
RequestHeadersInterceptor,
|
|
609
|
-
LoggingInterceptor,
|
|
610
|
-
ResponseNormalizationInterceptor,
|
|
611
|
-
VcdHttpClient,
|
|
612
|
-
VcdApiClient,
|
|
613
|
-
]
|
|
614
|
-
},] }
|
|
615
|
-
];
|
|
616
|
-
return VcdSdkModule;
|
|
617
|
-
}());
|
|
618
|
-
|
|
619
|
-
export { API_ROOT_URL, AuthTokenHolderService, EXTENSION_ASSET_URL, EXTENSION_ROUTE, EntityActionExtensionComponent, ExtensionNavRegistrationAction, FLEX_APP_URL, PluginModule, SDK_MODE, SESSION_ORGANIZATION, SESSION_ORG_ID, SESSION_SCOPE, VcdSdkModule, WizardExtensionComponent, WizardExtensionWithValidationComponent, _EntityActionExtensionComponent, _WizardExtensionComponent, _WizardExtensionWithValidationComponent, index as common, index$1 as core, index$2 as i18n, TranslatePipe as ɵa, TranslateService as ɵb, TranslationLoader as ɵc };
|
|
620
|
-
//# sourceMappingURL=vcd-sdk.js.map
|
package/fesm5/vcd-sdk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vcd-sdk.js","sources":["ng://@vcd/sdk/common/container-hooks.ts","ng://@vcd/sdk/core/plugin.module.ts","ng://@vcd/sdk/i18n/translation.loader.ts","ng://@vcd/sdk/i18n/translate.service.ts","ng://@vcd/sdk/i18n/translate.pipe.ts","ng://@vcd/sdk/main.ts"],"sourcesContent":["/**\n * This is the currently supported - albeit very minimal - public SDK.\n */\nimport {InjectionToken} from '@angular/core';\nimport {Observable} from 'rxjs';\n\n// Bind straight into the hooks provided by the container.\nif (!(window as any).System || !(window as any).System.registry || !(window as any).System.registry.get) {\n throw new Error('SystemJS registry not found');\n}\n\nlet containerHooks: any = (window as any).System.registry.get('@vcd/common');\nif (!containerHooks) {\n containerHooks = (window as any).System.registry.get('@vcd-ui/common');\n}\n\nif (!containerHooks) {\n throw new Error('VCD UI container hooks not present in SystemJS registry');\n}\n\n/**\n * Wire in as a string. Gives the root URL for API access (for example, the load balancer URL\n * or the single-cell URL).\n */\nexport const API_ROOT_URL: InjectionToken<string> = containerHooks.API_ROOT_URL;\n\n/**\n * Wire in as a string. Gives the root URL for the legacy Flex application.\n */\nexport const FLEX_APP_URL: InjectionToken<string> = containerHooks.API_ROOT_URL;\n\n/**\n * Wire in as a string. Gives the current scope of the VCD-UI. As of current, this will be\n * either 'tenant' for the tenant portal, or 'service-provider' for the service-provider portal.\n */\nexport const SESSION_SCOPE: InjectionToken<string> = containerHooks.SESSION_SCOPE;\n\n/**\n * Wire in as a string. Gives the unique name (not the display name) of the current tenant\n * organization that the VCD-UI is being used for.\n */\nexport const SESSION_ORGANIZATION: InjectionToken<string> = containerHooks.SESSION_ORGANIZATION;\n\n/**\n * Wire in as a string. Gives the UUID identifier of the current tenant\n * organization that the VCD-UI is being used for.\n */\nexport const SESSION_ORG_ID: InjectionToken<string> = containerHooks.SESSION_ORG_ID ? containerHooks.SESSION_ORG_ID : '';\n\n/**\n * Wire in as a string. Gives the full root path for module assets (e.g. images, scripts, text files)\n *\n * ATTENTION!\n * Add || new InjectionToken to workaround the Angular security mechanics which prevent use of injection tokens\n * which potentially are not defiend. The same fix can be applied for the rest tokens if needed.\n */\nexport const EXTENSION_ASSET_URL: InjectionToken<string> = containerHooks.EXTENSION_ASSET_URL || new InjectionToken('EXTENSION_ASSET_URL');\n\n/**\n * Wire in as a string. Gives the Angular 2 route that the module is registered under.\n */\nexport const EXTENSION_ROUTE: InjectionToken<string> = containerHooks.EXTENSION_ROUTE;\n\n/**\n * Wire in as a boolean. True if running under the SDK, false if running in production.\n */\nexport const SDK_MODE: InjectionToken<boolean> = containerHooks.SDK_MODE;\n\n/**\n * Payload for registering a navigation menu entry.\n */\nexport interface ExtensionNavRegistration {\n /**\n * The router path to navigate to when selected.\n */\n path: string;\n\n /**\n * i18 key for name of extension, to be used as text for links\n */\n nameCode: string;\n\n /**\n * i18n key for description of extension, to be used on hover for links\n */\n descriptionCode: string;\n}\n\n/**\n * Dispatch this to the redux store to register a navigation menu.\n */\nexport interface ExtensionNavRegistrationAction {\n payload: ExtensionNavRegistration;\n readonly type: string;\n}\n\nexport type ExtensionNavRegistrationActionCtor = new(payload: ExtensionNavRegistration) => ExtensionNavRegistrationAction;\n\nexport const ExtensionNavRegistrationAction: ExtensionNavRegistrationActionCtor = containerHooks.ExtensionNavRegistrationAction;\n\n/**\n * Inject this to access the authentication token.\n */\nexport interface AuthTokenHolderService {\n /**\n * The authentication token.\n */\n token: string;\n}\n\nexport const AuthTokenHolderService: {token: string} = containerHooks.AuthTokenHolderService;\n\n/**\n * This represents a menu item that can be clicked to perform an action on an entity (e.g. VM).\n */\nexport interface EntityActionExtensionMenuItem {\n /**\n * This is a unique URN identifying the action. This is so the component can be notified which action was requested.\n */\n urn: string;\n\n /**\n * This is the label for the menu item. It is not automatically translated.\n */\n text: string;\n\n /**\n * This is the enabled state for the menu item.\n */\n enabled: boolean;\n\n /**\n * This is the busy state for the menu item.\n */\n busy: boolean;\n}\n\n/**\n * This represents a sub-menu that contains other sub-menus or menu actions.\n */\nexport interface EntityActionExtensionSubmenu {\n /**\n * This is the label for the sub-menu. It is not automatically translated.\n */\n text: string;\n\n /**\n * This is an arbitrary, ordered list of EntityActionMenuItem.\n */\n children: EntityActionExtensionMenuItem[];\n}\n\n/**\n * This represents menu information for an entity action.\n */\nexport type EntityActionExtensionMenuEntry = EntityActionExtensionMenuItem | EntityActionExtensionSubmenu;\n\n/**\n * Every component referenced by an entity action extension point must inherit from this.\n */\n// tslint:disable-next-line:class-name\nexport abstract class _EntityActionExtensionComponent {\n /**\n * This returns is an Observable that defines the menu entry for this component. This is actively bound -\n * the component is able to change it in order to have the menu change (for example, to change busy\n * or enabled states).\n */\n abstract getMenuEntry(entityUrn: string): Observable<EntityActionExtensionMenuEntry>;\n\n /**\n * This field is a method that is called if a menu item is clicked while enabled. It will be called with the menu\n * item's URN and the URN of the entity that the action is being called for (e.g. the URN of the VM being edited).\n * It must return a single-shot (e.g. of, fromPromise or .first) Observable on completion. This Observable returns\n * a single value, refreshRequested. If this is true, the entity being edited will be immediately refreshed.\n * @param menuItemUrn the URN of the clicked menu item\n * @param entityUrnThe URN of the entity that the action is being called for\n */\n abstract performAction(menuItemUrn: string, entityUrn: string): Observable<{ refreshRequested: boolean }>;\n}\nexport const EntityActionExtensionComponent: typeof _EntityActionExtensionComponent = containerHooks.EntityActionExtensionComponent;\n\n// tslint:disable-next-line:class-name\nexport abstract class _WizardExtensionComponent<P, R, E> {\n /**\n * Define method which will be executed by the Extension Point Orchestrator,\n * when certain event is triggered.\n * @param payload - the payload of the request triggered by the Core UI.\n * @param response - the response from the request triggered by the Core UI.\n * @param error - the Core UI will reprot any error that may appear during execution.\n */\n abstract performAction(payload: P, response: R, error: E): void;\n}\n\nexport const WizardExtensionComponent: typeof _WizardExtensionComponent = containerHooks.WizardExtensionComponent;\n\nexport interface WizardExtensionState {\n isValid: boolean;\n}\n\n// tslint:disable-next-line:class-name\nexport abstract class _WizardExtensionWithValidationComponent<P, R, E> extends _WizardExtensionComponent<P, R, E> {\n /**\n * Get extension point state.\n */\n abstract getState(): Observable<WizardExtensionState>;\n}\n\n// tslint:disable-next-line:max-line-length\nexport const WizardExtensionWithValidationComponent: typeof _WizardExtensionWithValidationComponent = containerHooks.WizardExtensionWithValidationComponent;\n","import { Store } from '@ngrx/store';\nimport { ExtensionNavRegistration, ExtensionNavRegistrationAction } from '../common';\nimport { TranslateService } from '../i18n';\n\nexport class PluginModule {\n private translate: TranslateService;\n\n constructor(private appStore: Store<any>, translate?: TranslateService) {\n if (translate) {\n this.translate = translate;\n this.translate.prepareTranslations(this.getSupportedLanguages(), this.getDefaultLanguage());\n }\n }\n\n protected registerExtension(extension: ExtensionNavRegistration): void {\n this.appStore.dispatch(new ExtensionNavRegistrationAction(extension));\n }\n\n protected getDefaultLanguage(): string {\n return 'en';\n }\n\n protected getSupportedLanguages(): string[] {\n return ['en'];\n }\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Observable } from 'rxjs';\nimport { Inject, Injectable } from '@angular/core';\nimport { EXTENSION_ASSET_URL } from '../common/container-hooks';\nimport { catchError } from 'rxjs/operators';\n\n@Injectable()\nexport class TranslationLoader {\n private static PREFIX = '/i18n/';\n private static SUFFIX = '.json';\n\n constructor(private http: HttpClient, @Inject(EXTENSION_ASSET_URL) private assetUrl: string) { }\n\n public getTranslation(language: string): Observable<any> {\n return this.http.get(`${this.assetUrl}${TranslationLoader.PREFIX}${language}${TranslationLoader.SUFFIX}`);\n }\n\n public getCombinedTranslation(): Observable<any> {\n return this.http.get(`${this.assetUrl}/../i18n${TranslationLoader.SUFFIX}`);\n }\n}\n","// tslint:disable: variable-name\nimport { TranslationLoader } from './translation.loader';\nimport { Observable, Observer, of } from 'rxjs';\nimport { share, take } from 'rxjs/operators';\nimport { Inject, LOCALE_ID, Injectable } from '@angular/core';\n\n@Injectable()\nexport class TranslateService {\n private translation$: Observable<any>;\n private pending = false;\n public translations: any = {};\n\n private _combinedTranslations = true;\n public get combinedTranslations(): boolean {\n return this._combinedTranslations;\n }\n public set combinedTranslations(_combinedTranslations: boolean) {\n this._combinedTranslations = _combinedTranslations;\n }\n\n private _selectedLanguage: string;\n\n private _supportedLanguages: string[] = [];\n public get supportedLanguages(): string[] {\n return this._supportedLanguages;\n }\n public set supportedLanguages(_supportedLanguages: string[]) {\n this._supportedLanguages = _supportedLanguages;\n }\n\n private _defaultLanguage = '';\n public get defaultLanguage(): string {\n return this._defaultLanguage;\n }\n public set defaultLanguage(_defaultLanguage: string) {\n this._defaultLanguage = _defaultLanguage;\n }\n\n constructor(private loader: TranslationLoader) {}\n\n public prepareTranslations(supportedLanguages: string[], defaultLanguage: string): void {\n this._supportedLanguages = supportedLanguages;\n this._defaultLanguage = defaultLanguage;\n\n this._selectedLanguage = this.getBestMatchSupportedLanguage(navigator.language);\n this.getTranslation(this._selectedLanguage);\n }\n\n private getBestMatchSupportedLanguage(requestedLanguage: string): string {\n if (this._supportedLanguages.indexOf(requestedLanguage) > -1) {\n return requestedLanguage;\n }\n\n const altLanguage: string = requestedLanguage.split('-')[0];\n if (altLanguage === requestedLanguage) {\n return this._defaultLanguage;\n }\n\n return (this._supportedLanguages.indexOf(altLanguage) > -1) ? altLanguage : this._defaultLanguage;\n }\n\n public getTranslation(language: string): Observable<any> {\n this.pending = true;\n this.translation$ = this._combinedTranslations ?\n this.loader.getCombinedTranslation() : this.loader.getTranslation(language).pipe(share());\n\n this.translation$.pipe(take(1)).subscribe(result => {\n this.translations = result;\n this.pending = false;\n }, error => {\n this.pending = false;\n });\n\n return this.translation$;\n }\n\n private getParsedResult(key: string, ...args: any[]): string {\n let result = (this._combinedTranslations && this.translations[this._selectedLanguage]) ?\n this.translations[this._selectedLanguage][key] : this.translations[key];\n if (Array.isArray(result)) {\n result = result.join('');\n }\n\n return !result ? `#${key}#` : result.replace(/{([0-9]+)}/g, (_, ...n) => {\n // tslint:disable-next-line: radix\n const idx = parseInt(n[0]);\n if (args && typeof args[idx] !== 'undefined') {\n return args[idx];\n }\n\n return '';\n });\n }\n\n public get(key: string, ...args: any[]): Observable<string | any> {\n if (!this.pending) {\n return of(this.getParsedResult(key, ...args));\n }\n\n // tslint:disable-next-line: deprecation\n return Observable.create((observer: Observer<string>) => {\n const onComplete = (result: string) => {\n observer.next(result);\n observer.complete();\n };\n const onError = (error: any) => {\n observer.error(error);\n };\n this.translation$.subscribe(result => {\n result = this.getParsedResult(key, ...args);\n onComplete(result);\n }, onError);\n });\n }\n}\n","import { Injectable, PipeTransform, Pipe, ChangeDetectorRef } from '@angular/core';\nimport { TranslateService } from './translate.service';\n\n@Injectable()\n@Pipe({\n name: 'translate',\n pure: false\n})\nexport class TranslatePipe implements PipeTransform {\n private value = '';\n private lastKey = '';\n private lastArgs: any[] = [];\n\n constructor(private translate: TranslateService, private changeDetector: ChangeDetectorRef) { }\n\n transform(key: string, ...args: any[]): any {\n if (!key || key.length === 0) {\n return key;\n }\n\n if (key === this.lastKey && args === this.lastArgs) {\n return this.value;\n }\n\n this.lastKey = key;\n this.lastArgs = args;\n this.updateValue(key, args);\n\n return this.value;\n }\n\n private updateValue(key: string, args: any[]): void {\n this.translate.get(key, ...args).subscribe(result => {\n this.value = result;\n this.changeDetector.markForCheck();\n });\n }\n}\n","import {HttpClientModule} from '@angular/common/http';\nimport {NgModule } from '@angular/core';\nimport {CommonModule } from '@angular/common';\n\nimport * as client from '@vcd/angular-client';\nimport * as common from './common';\nimport * as core from './core';\nimport * as i18n from './i18n';\n\nexport {\n common,\n core,\n i18n,\n};\n\n/**\n * Extensions should import this module. They can then wire in SDK components as desired.\n */\n@NgModule({\n imports: [\n HttpClientModule,\n CommonModule,\n ],\n declarations: [i18n.TranslatePipe],\n exports: [i18n.TranslatePipe],\n providers: [\n i18n.TranslateService,\n i18n.TranslationLoader,\n client.RequestHeadersInterceptor,\n client.LoggingInterceptor,\n client.ResponseNormalizationInterceptor,\n client.VcdHttpClient,\n client.VcdApiClient,\n ]\n})\nexport class VcdSdkModule {\n}\n"],"names":["tslib_1.__extends","i18n.TranslatePipe","i18n.TranslateService","i18n.TranslationLoader","client.RequestHeadersInterceptor","client.LoggingInterceptor","client.ResponseNormalizationInterceptor","client.VcdHttpClient","client.VcdApiClient"],"mappings":";;;;;;;;;;;;;;AAOA,IAAI,CAAC,oBAAC,MAAM,IAAS,MAAM,IAAI,CAAC,oBAAC,MAAM,IAAS,MAAM,CAAC,QAAQ,IAAI,CAAC,oBAAC,MAAM,IAAS,MAAM,CAAC,QAAQ,CAAC,GAAG,E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;;;;;;;;;ACHA;;;AAkBA;IAAA;KAkBC;;gBAlBA,QAAQ,SAAC;oBACR,OAAO,EAAE;wBACP,gBAAgB;wBAChB,YAAY;qBACb;oBACD,YAAY,EAAE,CAACC,aAAkB,CAAC;oBAClC,OAAO,EAAE,CAACA,aAAkB,CAAC;oBAC7B,SAAS,EAAE;wBACTC,gBAAqB;wBACrBC,iBAAsB;wBACtBC,yBAAgC;wBAChCC,kBAAyB;wBACzBC,gCAAuC;wBACvCC,aAAoB;wBACpBC,YAAmB;qBACpB;iBACF;;IAED,mBAAC;CAlBD;;;;"}
|
package/i18n/index.d.ts
DELETED
package/i18n/translate.pipe.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { PipeTransform, ChangeDetectorRef } from '@angular/core';
|
|
2
|
-
import { TranslateService } from './translate.service';
|
|
3
|
-
export declare class TranslatePipe implements PipeTransform {
|
|
4
|
-
private translate;
|
|
5
|
-
private changeDetector;
|
|
6
|
-
private value;
|
|
7
|
-
private lastKey;
|
|
8
|
-
private lastArgs;
|
|
9
|
-
constructor(translate: TranslateService, changeDetector: ChangeDetectorRef);
|
|
10
|
-
transform(key: string, ...args: any[]): any;
|
|
11
|
-
private updateValue;
|
|
12
|
-
}
|