@asgardeo/javascript 0.9.1 → 0.10.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/dist/cjs/index.js +55 -23
- package/dist/cjs/index.js.map +3 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +51 -22
- package/dist/index.js.map +3 -3
- package/dist/models/v2/embedded-flow-v2.d.ts +64 -1
- package/dist/models/v2/vars.d.ts +2 -2
- package/dist/utils/v2/containsMetaFlowTemplateLiteral.d.ts +56 -0
- package/dist/utils/v2/extractEmojiFromUri.d.ts +31 -0
- package/dist/utils/v2/isEmojiUri.d.ts +33 -0
- package/dist/utils/v2/isMetaFlowTemplateLiteral.d.ts +44 -0
- package/dist/utils/v2/isTranslationFlowTemplateLiteral.d.ts +44 -0
- package/dist/utils/v2/parseFlowTemplateLiteral.d.ts +95 -0
- package/dist/utils/v2/{resolveVars.d.ts → resolveFlowTemplateLiterals.d.ts} +6 -6
- package/package.json +2 -2
|
@@ -40,6 +40,8 @@ export declare enum EmbeddedFlowComponentType {
|
|
|
40
40
|
Action = "ACTION",
|
|
41
41
|
/** Container block component that groups other components */
|
|
42
42
|
Block = "BLOCK",
|
|
43
|
+
/** Consent component for displaying consent purposes and attributes */
|
|
44
|
+
Consent = "CONSENT",
|
|
43
45
|
/** Divider component for visual separation of content */
|
|
44
46
|
Divider = "DIVIDER",
|
|
45
47
|
/** Email input field with validation for email addresses. */
|
|
@@ -63,7 +65,9 @@ export declare enum EmbeddedFlowComponentType {
|
|
|
63
65
|
/** Text display component for labels, headings, and messages */
|
|
64
66
|
Text = "TEXT",
|
|
65
67
|
/** Standard text input field for user data entry */
|
|
66
|
-
TextInput = "TEXT_INPUT"
|
|
68
|
+
TextInput = "TEXT_INPUT",
|
|
69
|
+
/** Timer component for displaying a countdown */
|
|
70
|
+
Timer = "TIMER"
|
|
67
71
|
}
|
|
68
72
|
/**
|
|
69
73
|
* Action variant types for buttons and interactive elements.
|
|
@@ -380,6 +384,65 @@ export interface EmbeddedFlowResponseData {
|
|
|
380
384
|
*/
|
|
381
385
|
redirectURL?: string;
|
|
382
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Individual consent attribute/element decision.
|
|
389
|
+
*
|
|
390
|
+
* @experimental This interface may change in future versions
|
|
391
|
+
*/
|
|
392
|
+
export interface ConsentAttributeElement {
|
|
393
|
+
/** Whether the user approved collection of this attribute */
|
|
394
|
+
approved: boolean;
|
|
395
|
+
/** The name of the attribute being consented */
|
|
396
|
+
name: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Consent decision for a single purpose.
|
|
400
|
+
*
|
|
401
|
+
* @experimental This interface may change in future versions
|
|
402
|
+
*/
|
|
403
|
+
export interface ConsentPurposeDecision {
|
|
404
|
+
/** Whether the user approved this purpose */
|
|
405
|
+
approved: boolean;
|
|
406
|
+
/** Per-attribute decisions for this purpose */
|
|
407
|
+
elements: ConsentAttributeElement[];
|
|
408
|
+
/** The name of the consent purpose */
|
|
409
|
+
purpose_name: string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Full consent decisions structure sent to the backend when user submits the consent form.
|
|
413
|
+
*
|
|
414
|
+
* @experimental This interface may change in future versions
|
|
415
|
+
*/
|
|
416
|
+
export interface ConsentDecisions {
|
|
417
|
+
/** Array of per-purpose decisions */
|
|
418
|
+
purposes: ConsentPurposeDecision[];
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Single consent purpose data returned by the backend in additionalData.consent_prompt.
|
|
422
|
+
*
|
|
423
|
+
* @experimental This interface may change in future versions
|
|
424
|
+
*/
|
|
425
|
+
export interface ConsentPurposeData {
|
|
426
|
+
/** Optional human-readable description of the purpose */
|
|
427
|
+
description?: string;
|
|
428
|
+
/** Attributes that are always required and cannot be declined */
|
|
429
|
+
essential: string[];
|
|
430
|
+
/** Attributes that the user can optionally decline */
|
|
431
|
+
optional: string[];
|
|
432
|
+
/** Unique identifier for the purpose */
|
|
433
|
+
purpose_id: string;
|
|
434
|
+
/** Human-readable purpose name */
|
|
435
|
+
purpose_name: string;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Consent prompt data structure stored in additionalData.consent_prompt.
|
|
439
|
+
*
|
|
440
|
+
* @experimental This interface may change in future versions
|
|
441
|
+
*/
|
|
442
|
+
export interface ConsentPromptData {
|
|
443
|
+
/** Array of consent purposes requiring user review */
|
|
444
|
+
purposes: ConsentPurposeData[];
|
|
445
|
+
}
|
|
383
446
|
/**
|
|
384
447
|
* Extended request configuration for Asgardeo V2 embedded flow operations.
|
|
385
448
|
*
|
package/dist/models/v2/vars.d.ts
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
import { FlowMetadataResponse } from './flow-meta-v2';
|
|
19
19
|
import { TranslationFn } from './translation';
|
|
20
20
|
/**
|
|
21
|
-
* Options for the
|
|
21
|
+
* Options for the resolveFlowTemplateLiterals function.
|
|
22
22
|
*
|
|
23
23
|
* @template TFn - The concrete translation function type.
|
|
24
24
|
* Defaults to the SDK-native {@link TranslationFn} signature.
|
|
25
25
|
*/
|
|
26
|
-
export interface
|
|
26
|
+
export interface ResolveFlowTemplateLiteralsOptions<TFn extends TranslationFn = TranslationFn> {
|
|
27
27
|
/**
|
|
28
28
|
* Optional flow metadata for resolving `{{ meta(path) }}` expressions.
|
|
29
29
|
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Check whether a string contains a `{{ meta(key) }}` flow template literal anywhere within it.
|
|
20
|
+
*
|
|
21
|
+
* Unlike {@link isMetaFlowTemplateLiteral}, which requires the **entire** string to be the
|
|
22
|
+
* template, this function detects the pattern embedded inside a larger string such as an
|
|
23
|
+
* HTML label or sentence.
|
|
24
|
+
*
|
|
25
|
+
* Whitespace around `{{` / `}}` is allowed, e.g. `{{ meta(application.signUpUrl) }}`.
|
|
26
|
+
*
|
|
27
|
+
* @param str - The string to search (may be a plain value or an HTML fragment).
|
|
28
|
+
* @param key - The meta path to look for, e.g. `"application.signUpUrl"`.
|
|
29
|
+
* @returns `true` if the pattern is found anywhere in `str`, `false` otherwise.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* containsMetaFlowTemplateLiteral('<a href="{{meta(application.signUpUrl)}}">Sign up</a>', 'application.signUpUrl')
|
|
34
|
+
* // true
|
|
35
|
+
*
|
|
36
|
+
* containsMetaFlowTemplateLiteral('<a href="https://example.com">Sign up</a>', 'application.signUpUrl')
|
|
37
|
+
* // false
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export default function containsMetaFlowTemplateLiteral(str: string, key: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Replace all occurrences of `{{ meta(key) }}` (with optional whitespace) in `str`
|
|
43
|
+
* with `replacement`.
|
|
44
|
+
*
|
|
45
|
+
* @param str - The source string.
|
|
46
|
+
* @param key - The meta path to replace, e.g. `"application.signUpUrl"`.
|
|
47
|
+
* @param replacement - The value to substitute for each match.
|
|
48
|
+
* @returns A new string with all occurrences replaced.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* replaceMetaFlowTemplateLiteral('Sign up at {{ meta(application.signUpUrl) }}', 'application.signUpUrl', 'https://example.com')
|
|
53
|
+
* // 'Sign up at https://example.com'
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function replaceMetaFlowTemplateLiteral(str: string, key: string, replacement: string): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Extracts the emoji character from an `emoji:` URI.
|
|
20
|
+
*
|
|
21
|
+
* @param uri - A URI string in the form `"emoji:<emoji>"`.
|
|
22
|
+
* @returns The emoji character, or an empty string if the URI is not a valid emoji URI.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* extractEmojiFromUri("emoji:🐯"); // "🐯"
|
|
27
|
+
* extractEmojiFromUri("https://example.com"); // ""
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare const extractEmojiFromUri: (uri: string) => string;
|
|
31
|
+
export default extractEmojiFromUri;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
export declare const EMOJI_URI_SCHEME: string;
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether a given URI uses the `emoji:` scheme (e.g. `"emoji:🐯"`).
|
|
21
|
+
*
|
|
22
|
+
* @param uri - The URI string to check.
|
|
23
|
+
* @returns `true` if the URI starts with `"emoji:"`, `false` otherwise.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* isEmojiUri("emoji:🐯"); // true
|
|
28
|
+
* isEmojiUri("https://example.com/logo.png"); // false
|
|
29
|
+
* isEmojiUri(""); // false
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare const isEmojiUri: (uri: string) => boolean;
|
|
33
|
+
export default isEmojiUri;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Regular expression to match a meta flow template literal `{{meta(key)}}` (exact, full-string match).
|
|
20
|
+
* Optional whitespace around `{{` / `}}` is allowed.
|
|
21
|
+
*/
|
|
22
|
+
export declare const META_FLOW_TEMPLATE_LITERAL_PATTERN: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* Regular expression to extract the path from a meta flow template literal `{{meta(path)}}`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const META_FLOW_TEMPLATE_LITERAL_KEY_PATTERN: RegExp;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a string is exactly a meta flow template literal (`{{ meta(path) }}`).
|
|
29
|
+
*
|
|
30
|
+
* This checks that the **entire** string is the template pattern. Use
|
|
31
|
+
* {@link FLOW_TEMPLATE_LITERAL_REGEX} from `parseFlowTemplateLiteral` to detect
|
|
32
|
+
* templates embedded inside a larger string.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The string to test.
|
|
35
|
+
* @returns `true` if the trimmed value matches the pattern, `false` otherwise.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* isMetaFlowTemplateLiteral('{{ meta(application.name) }}') // true
|
|
40
|
+
* isMetaFlowTemplateLiteral('hello world') // false
|
|
41
|
+
* isMetaFlowTemplateLiteral('Login to {{ meta(app.name) }}') // false — embedded, not exact
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export default function isMetaFlowTemplateLiteral(value: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Regular expression to match a translation flow template literal `{{t(key)}}` (exact, full-string match).
|
|
20
|
+
* Optional whitespace around `{{` / `}}` is allowed.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TRANSLATION_FLOW_TEMPLATE_LITERAL_PATTERN: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* Regular expression to extract the key from a translation flow template literal `{{t(key)}}`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const TRANSLATION_FLOW_TEMPLATE_LITERAL_KEY_PATTERN: RegExp;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a string is exactly a translation flow template literal (`{{ t(key) }}`).
|
|
29
|
+
*
|
|
30
|
+
* This checks that the **entire** string is the template pattern. Use
|
|
31
|
+
* {@link FLOW_TEMPLATE_LITERAL_REGEX} from `parseFlowTemplateLiteral` to detect
|
|
32
|
+
* templates embedded inside a larger string.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The string to test.
|
|
35
|
+
* @returns `true` if the trimmed value matches the pattern, `false` otherwise.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* isTranslationFlowTemplateLiteral('{{ t(signin:heading) }}') // true
|
|
40
|
+
* isTranslationFlowTemplateLiteral('hello world') // false
|
|
41
|
+
* isTranslationFlowTemplateLiteral('Login via {{ t(key) }}') // false — embedded, not exact
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export default function isTranslationFlowTemplateLiteral(value: string): boolean;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Regular expression to detect a flow template literal wrapped in double braces.
|
|
20
|
+
* Matches patterns like `{{ t(key) }}`, `{{ meta(key) }}`, etc.
|
|
21
|
+
*
|
|
22
|
+
* Note: this regex has no `g` flag — use `new RegExp(FLOW_TEMPLATE_LITERAL_REGEX.source, 'g')`
|
|
23
|
+
* when global replacement is needed (e.g. in resolveFlowTemplateLiterals).
|
|
24
|
+
*/
|
|
25
|
+
export declare const FLOW_TEMPLATE_LITERAL_REGEX: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Regular expression to parse a function-call expression inside flow template braces.
|
|
28
|
+
* Matches `funcName(arg)` and captures the function name and argument.
|
|
29
|
+
*/
|
|
30
|
+
export declare const FLOW_TEMPLATE_FUNCTION_REGEX: RegExp;
|
|
31
|
+
/**
|
|
32
|
+
* Flow template literal types supported by the SDK.
|
|
33
|
+
*
|
|
34
|
+
* Values correspond to the function name used in the template expression,
|
|
35
|
+
* so that a `{ t }` object from `useTranslation()` can be passed directly
|
|
36
|
+
* as a handler map.
|
|
37
|
+
*/
|
|
38
|
+
export declare enum FlowTemplateLiteralType {
|
|
39
|
+
/** Meta template literal — `{{ meta(path) }}` — resolves against flow/page metadata */
|
|
40
|
+
META = "meta",
|
|
41
|
+
/** Translation template literal — `{{ t(key) }}` */
|
|
42
|
+
TRANSLATION = "t",
|
|
43
|
+
/** Unknown or unsupported template literal format */
|
|
44
|
+
UNKNOWN = "unknown"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of parsing a flow template literal.
|
|
48
|
+
*/
|
|
49
|
+
export interface FlowTemplateLiteralResult {
|
|
50
|
+
/**
|
|
51
|
+
* The extracted key or path from the template literal.
|
|
52
|
+
* e.g. `"signin:heading"` from `"{{ t(signin:heading) }}"`.
|
|
53
|
+
*/
|
|
54
|
+
key?: string;
|
|
55
|
+
/** The original template literal content before parsing */
|
|
56
|
+
originalValue: string;
|
|
57
|
+
/** The type of flow template literal that was detected */
|
|
58
|
+
type: FlowTemplateLiteralType;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Map of handler functions keyed by {@link FlowTemplateLiteralType}.
|
|
62
|
+
*
|
|
63
|
+
* When provided to a resolver, the matching handler is called with the extracted key.
|
|
64
|
+
* Because `FlowTemplateLiteralType.TRANSLATION === 't'`, you can pass the `{ t }` object
|
|
65
|
+
* from `useTranslation()` directly.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const { t } = useTranslation();
|
|
70
|
+
* // handler map: { t: (key) => string }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export type FlowTemplateLiteralHandlers = Partial<Record<FlowTemplateLiteralType, (key: string) => string>>;
|
|
74
|
+
/**
|
|
75
|
+
* Parse a flow template literal content string and extract its type and key.
|
|
76
|
+
*
|
|
77
|
+
* Supports function-call expressions like:
|
|
78
|
+
* - `t(signin:heading)` → type `TRANSLATION`, key `"signin:heading"`
|
|
79
|
+
* - `meta(application.name)` → type `META`, key `"application.name"`
|
|
80
|
+
*
|
|
81
|
+
* Surrounding quotes on the key argument are stripped automatically.
|
|
82
|
+
*
|
|
83
|
+
* @param content - The content inside the template literal braces (without `{{ }}`).
|
|
84
|
+
* @returns Parsed flow template literal information.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* parseFlowTemplateLiteral('t(signin:heading)')
|
|
89
|
+
* // { type: FlowTemplateLiteralType.TRANSLATION, key: 'signin:heading', originalValue: 't(signin:heading)' }
|
|
90
|
+
*
|
|
91
|
+
* parseFlowTemplateLiteral('meta(application.name)')
|
|
92
|
+
* // { type: FlowTemplateLiteralType.META, key: 'application.name', originalValue: 'meta(application.name)' }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export default function parseFlowTemplateLiteral(content: string): FlowTemplateLiteralResult;
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { TranslationFn } from '../../models/v2/translation';
|
|
19
|
-
import {
|
|
19
|
+
import { ResolveFlowTemplateLiteralsOptions } from '../../models/v2/vars';
|
|
20
20
|
/**
|
|
21
|
-
* Resolves all template expressions in a string.
|
|
21
|
+
* Resolves all flow template literal expressions in a string.
|
|
22
22
|
*
|
|
23
23
|
* Supported patterns:
|
|
24
24
|
* - `{{ t(key) }}` — resolved via the i18n translation function.
|
|
@@ -27,15 +27,15 @@ import { ResolveVarsOptions } from '../../models/v2/vars';
|
|
|
27
27
|
* - `{{ meta(path) }}` — resolved via a dot-path lookup on FlowMetadataResponse.
|
|
28
28
|
* `{{ meta(application.name) }}` → `meta.application?.name`
|
|
29
29
|
*
|
|
30
|
-
*
|
|
30
|
+
* Flow template literals can be embedded inside larger strings:
|
|
31
31
|
* `"Login using {{ meta(application.name) }}"` → `"Login using My App"`
|
|
32
32
|
*
|
|
33
|
-
*
|
|
33
|
+
* Unrecognized expressions are left unchanged.
|
|
34
34
|
*
|
|
35
35
|
* @template TFn - The concrete translation function type.
|
|
36
36
|
*
|
|
37
|
-
* @param text - The string to resolve (may contain zero or more template
|
|
37
|
+
* @param text - The string to resolve (may contain zero or more flow template literals)
|
|
38
38
|
* @param options - Resolution context: translation function and optional flow metadata
|
|
39
39
|
* @returns The resolved string
|
|
40
40
|
*/
|
|
41
|
-
export default function
|
|
41
|
+
export default function resolveFlowTemplateLiterals<TFn extends TranslationFn = TranslationFn>(text: string | undefined, { t, meta }: ResolveFlowTemplateLiteralsOptions<TFn>): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/javascript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Framework agnostic JavaScript SDK for Asgardeo.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"asgardeo",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"tslib": "2.8.1",
|
|
49
49
|
"jose": "^5.2.0",
|
|
50
|
-
"@asgardeo/i18n": "0.4.
|
|
50
|
+
"@asgardeo/i18n": "0.4.4"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|