-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync features and bugfixs from e8bf8f7 (#1630)
* sync features and bugfixs from 6e7ccc1 * feat: add engage voice widgets package * skip widgets test as fail after deps upgrading * fix wrong path name
- Loading branch information
Showing
755 changed files
with
42,258 additions
and
4,484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
251d34c1aac96cffe15c70a87f4cc547dcd83420 | ||
e8bf8f74050d43715af4216e79e297525396f39b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ jobs: | |
- stage: Integration test | ||
node_js: "10" | ||
script: yarn workspace ringcentral-integration test | ||
- stage: Widgets test | ||
node_js: "10" | ||
script: yarn workspace ringcentral-widgets-test test:coverage | ||
# - stage: Widgets test | ||
# node_js: "10" | ||
# script: yarn workspace ringcentral-widgets-test test:coverage | ||
- stage: core npm release | ||
if: tag =~ ^[0-9]+.[0-9]+.[0-9]+ | ||
node_js: "10" | ||
|
@@ -146,3 +146,29 @@ jobs: | |
provider: script | ||
skip_cleanup: true | ||
script: yarn core:start-release | ||
- stage: engage voice widgets script release | ||
node_js: "10" | ||
if: branch = master AND type = push | ||
script: yarn engage-voice-widgets:prepare-release | ||
deploy: | ||
provider: script | ||
skip_cleanup: true | ||
script: yarn engage-voice-widgets:start-release | ||
- stage: engage voice widgets npm release | ||
if: tag =~ ^[0-9]+.[0-9]+.[0-9]+ | ||
node_js: "10" | ||
script: yarn engage-voice-widgets:prepare-release | ||
before_deploy: | ||
- cd release/engage-voice-widgets | ||
after_deploy: | ||
- cd ../../ | ||
deploy: | ||
provider: npm | ||
email: [email protected] | ||
skip_cleanup: true | ||
api_key: | ||
secure: Cpjded9XcB31vU0VXGlqkJX8jT/xX5diLbxZ7/dMT3g7zpEt5dgxVaWdGXEIN/klxQHrjgE/K2fMUEqtgFb7lbrk8EKgOSU3vy52h/NIgbC4tHE+8A6hoSk8DgbNNjiCZY4DjLS4EiUjbhyYUHog5ri/TPWfmfQW+XiVcWOu61WIzlm0ia0EVI+RcqbRvzf8YKFkVaVvqPu2cvfDPYBfzmn1u32hZtEzZR6VAtJBI0hhpeIj+97BxhgmNt5MmGf+q3ex0YnE0/9Qv74JT5KSUhjOQjGNEUW15GwTpWn083KKVG8RXGHvrtjvOwMVKRE3VVB64urNkOEODFcz1Yy0C0Nsv+EVYgR2F+yUXcwFOYPGPPC/a/7X8l+sxCBtDgZ3LomWSES1pBJvhtNNZt3/mhGaFB5pqBZeDAXCwlm3ysLOri0lcp25oNKdIbAMAl9PQOc5MmTtDX1dQ4XRCxq+GyHqAo3YcK/VX4sGNcCU/4a6fPi4VDyijzT5VQ709PJ4Zva5jc1qX/GFS9gmMgdr2hb5rhM9/M76WoRIaEe8YaxaaElrl5lBQsWY6e6ipGJRVXGh9ESRz5cYev7YqW/4ihzChZRad+VO7dzalWU8Xea56LmDjFuWSKzJTDNNKrNoGDHgMSm6fOlDhxgSFTVSRX6Pnqaf5UGqu2hQcjnK8So= | ||
on: | ||
node: '10' | ||
tags: true | ||
condition: "$TRAVIS_TAG =~ ^[0-9]+.[0-9]+.[0-9]+" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { find } from 'ramda'; | ||
|
||
const sDefinition = Symbol('definition'); | ||
const RUNTIME = { | ||
usingFactory: false, | ||
}; | ||
|
||
function factory<T>( | ||
prototype: T, | ||
property: string, | ||
descriptor: PropertyDescriptor, | ||
) { | ||
const baseFunction = descriptor.value; | ||
return { | ||
...descriptor, | ||
value(this: ThisType<T>, ...args) { | ||
RUNTIME.usingFactory = true; | ||
const result = baseFunction.call(this, ...args); | ||
RUNTIME.usingFactory = false; | ||
return result; | ||
}, | ||
}; | ||
} | ||
|
||
export type ObjectMapKey<D> = D extends ObjectMap<infer K, infer V, infer T> & | ||
infer T | ||
? K | ||
: never; | ||
|
||
export type ObjectMapValue<D> = D extends ObjectMap<infer K, infer V, infer T> & | ||
infer T | ||
? V | ||
: never; | ||
|
||
export function prefixString(str: string, prefix: string = ''): string { | ||
return prefix === '' ? str : `${prefix}-${str}`; | ||
} | ||
|
||
export class ObjectMap< | ||
K extends keyof T, | ||
V extends T[K], | ||
T extends Record<string | number, any> | ||
> { | ||
private readonly [sDefinition] = new Map(); | ||
|
||
constructor(definition: T) { | ||
if (!RUNTIME.usingFactory) { | ||
throw TypeError( | ||
'Instantiating ObjectMap with `new ObjectMap(definition)` is not recommended. ' + | ||
'Please use one of the ObjectMap factory functions.', | ||
); | ||
} | ||
if (definition) { | ||
for (const key in definition) { | ||
if (Object.prototype.hasOwnProperty.call(definition, key)) { | ||
this[sDefinition].set(key, definition[key]); | ||
Object.defineProperty(this, key, { | ||
get() { | ||
return this[sDefinition].get(key); | ||
}, | ||
enumerable: true, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@factory | ||
static fromObject< | ||
K extends keyof T, | ||
V extends T[K], | ||
T extends Record<string | number, any> | ||
>(definition: T) { | ||
return new ObjectMap(definition) as ObjectMap<K, V, T> & T; | ||
} | ||
|
||
@factory | ||
static fromKeys<T extends string>(keys: T[]) { | ||
const definition = {} as Record<T, T>; | ||
for (const key of keys) { | ||
definition[key] = key; | ||
} | ||
return new ObjectMap(definition) as ObjectMap<T, T, { [K in T]: K }> & | ||
{ [K in T]: K }; | ||
} | ||
|
||
@factory | ||
static prefixKeys<T extends string, K extends T>( | ||
keys: K[], | ||
prefix: string = '', | ||
) { | ||
const definition = {} as Record<K, string>; | ||
for (const key of keys) { | ||
definition[key] = prefixString(key, prefix); | ||
} | ||
return new ObjectMap(definition) as ObjectMap< | ||
K, | ||
string, | ||
{ [V in K]: string } | ||
> & | ||
{ [V in K]: string }; | ||
} | ||
|
||
static getKey<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
value: V, | ||
): K { | ||
const [key = null] = | ||
find<[K, V]>(([, v]) => v === value, [...ObjectMap.entries(instance)]) || | ||
[]; | ||
return key; | ||
} | ||
|
||
static entries<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
): IterableIterator<[K, V]> { | ||
return instance[sDefinition].entries(); | ||
} | ||
|
||
static size<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
): number { | ||
return instance[sDefinition].size; | ||
} | ||
|
||
static has<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
key: K, | ||
): boolean { | ||
return instance[sDefinition].has(key); | ||
} | ||
|
||
static hasValue<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
value: V, | ||
): boolean { | ||
return !!ObjectMap.getKey(instance, value); | ||
} | ||
|
||
static keys<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
): IterableIterator<K> { | ||
return instance[sDefinition].keys(); | ||
} | ||
|
||
static values<K extends keyof T, V extends T[K], T>( | ||
instance: ObjectMap<K, V, T> & T, | ||
): IterableIterator<V> { | ||
return instance[sDefinition].values(); | ||
} | ||
|
||
static forEach<K extends keyof T, V extends T[K], T>( | ||
fn: (value: V, key: K, map: ObjectMap<K, V, T> & T) => void, | ||
instance: ObjectMap<K, V, T> & T, | ||
): void { | ||
return instance[sDefinition].forEach((v, k) => fn(v, k, instance)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ObjectMap'; |
Oops, something went wrong.