Skip to content

Commit dc9e803

Browse files
authored
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
1 parent be3351f commit dc9e803

File tree

755 files changed

+42258
-4484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

755 files changed

+42258
-4484
lines changed

.sync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
251d34c1aac96cffe15c70a87f4cc547dcd83420
1+
e8bf8f74050d43715af4216e79e297525396f39b

.travis.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
- stage: Integration test
1818
node_js: "10"
1919
script: yarn workspace ringcentral-integration test
20-
- stage: Widgets test
21-
node_js: "10"
22-
script: yarn workspace ringcentral-widgets-test test:coverage
20+
# - stage: Widgets test
21+
# node_js: "10"
22+
# script: yarn workspace ringcentral-widgets-test test:coverage
2323
- stage: core npm release
2424
if: tag =~ ^[0-9]+.[0-9]+.[0-9]+
2525
node_js: "10"
@@ -146,3 +146,29 @@ jobs:
146146
provider: script
147147
skip_cleanup: true
148148
script: yarn core:start-release
149+
- stage: engage voice widgets script release
150+
node_js: "10"
151+
if: branch = master AND type = push
152+
script: yarn engage-voice-widgets:prepare-release
153+
deploy:
154+
provider: script
155+
skip_cleanup: true
156+
script: yarn engage-voice-widgets:start-release
157+
- stage: engage voice widgets npm release
158+
if: tag =~ ^[0-9]+.[0-9]+.[0-9]+
159+
node_js: "10"
160+
script: yarn engage-voice-widgets:prepare-release
161+
before_deploy:
162+
- cd release/engage-voice-widgets
163+
after_deploy:
164+
- cd ../../
165+
deploy:
166+
provider: npm
167+
168+
skip_cleanup: true
169+
api_key:
170+
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=
171+
on:
172+
node: '10'
173+
tags: true
174+
condition: "$TRAVIS_TAG =~ ^[0-9]+.[0-9]+.[0-9]+"

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"glip-widgets:start-release": "babel-node scripts/startRelease.js @ringcentral-integration/glip-widgets glip-widgets-release",
3232
"core:prepare-release": "babel-node scripts/prepareRelease.js @ringcentral-integration/core core-release",
3333
"core:start-release": "babel-node scripts/startRelease.js @ringcentral-integration/core core-release",
34+
"engage-voice-widgets:prepare-release": "babel-node scripts/prepareRelease.js @ringcentral-integration/engage-voice-widgets engage-voice-widgets-release",
35+
"engage-voice-widgets:start-release": "babel-node scripts/startRelease.js @ringcentral-integration/engage-voice-widgets engage-voice-widgets-release",
3436
"commit": "yarn git-cz"
3537
},
3638
"devDependencies": {

packages/babel-settings/package.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"name": "@ringcentral-integration/babel-settings",
3-
"version": "1.0.0",
4-
"private": true,
3+
"version": "0.0.1",
54
"main": "index.js",
6-
"description": "Shared babel settings",
5+
"description": "RingCentral Integration shared babel settings",
76
"repository": {
87
"type": "git",
98
"url": "https://github.com/ringcentral/ringcentral-js-widget.git"
@@ -13,22 +12,22 @@
1312
},
1413
"scripts": {},
1514
"dependencies": {
16-
"@babel/core": "^7.6.0",
17-
"@babel/node": "^7.6.0",
18-
"@babel/plugin-proposal-class-properties": "^7.5.5",
19-
"@babel/plugin-proposal-decorators": "^7.6.0",
20-
"@babel/plugin-proposal-export-default-from": "^7.5.2",
21-
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
22-
"@babel/plugin-proposal-function-bind": "^7.2.0",
23-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4",
24-
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
25-
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
26-
"@babel/preset-env": "^7.6.0",
27-
"@babel/preset-react": "^7.0.0",
28-
"@babel/preset-typescript": "^7.6.0",
29-
"@babel/register": "^7.6.0",
30-
"core-js": "^3.0.1",
31-
"typescript": "^3.7.3"
15+
"@babel/core": "^7.9.6",
16+
"@babel/node": "^7.8.7",
17+
"@babel/plugin-proposal-class-properties": "^7.8.3",
18+
"@babel/plugin-proposal-decorators": "^7.8.3",
19+
"@babel/plugin-proposal-export-default-from": "^7.8.3",
20+
"@babel/plugin-proposal-export-namespace-from": "^7.8.3",
21+
"@babel/plugin-proposal-function-bind": "^7.8.3",
22+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
23+
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
24+
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
25+
"@babel/preset-env": "^7.9.6",
26+
"@babel/preset-react": "^7.9.4",
27+
"@babel/preset-typescript": "^7.9.0",
28+
"@babel/register": "^7.9.0",
29+
"core-js": "^2.6.11",
30+
"typescript": "^3.9.2"
3231
},
3332
"peerDependencies": {
3433
"@babel/polyfill": "^7.6.0",
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import { find } from 'ramda';
2+
3+
const sDefinition = Symbol('definition');
4+
const RUNTIME = {
5+
usingFactory: false,
6+
};
7+
8+
function factory<T>(
9+
prototype: T,
10+
property: string,
11+
descriptor: PropertyDescriptor,
12+
) {
13+
const baseFunction = descriptor.value;
14+
return {
15+
...descriptor,
16+
value(this: ThisType<T>, ...args) {
17+
RUNTIME.usingFactory = true;
18+
const result = baseFunction.call(this, ...args);
19+
RUNTIME.usingFactory = false;
20+
return result;
21+
},
22+
};
23+
}
24+
25+
export type ObjectMapKey<D> = D extends ObjectMap<infer K, infer V, infer T> &
26+
infer T
27+
? K
28+
: never;
29+
30+
export type ObjectMapValue<D> = D extends ObjectMap<infer K, infer V, infer T> &
31+
infer T
32+
? V
33+
: never;
34+
35+
export function prefixString(str: string, prefix: string = ''): string {
36+
return prefix === '' ? str : `${prefix}-${str}`;
37+
}
38+
39+
export class ObjectMap<
40+
K extends keyof T,
41+
V extends T[K],
42+
T extends Record<string | number, any>
43+
> {
44+
private readonly [sDefinition] = new Map();
45+
46+
constructor(definition: T) {
47+
if (!RUNTIME.usingFactory) {
48+
throw TypeError(
49+
'Instantiating ObjectMap with `new ObjectMap(definition)` is not recommended. ' +
50+
'Please use one of the ObjectMap factory functions.',
51+
);
52+
}
53+
if (definition) {
54+
for (const key in definition) {
55+
if (Object.prototype.hasOwnProperty.call(definition, key)) {
56+
this[sDefinition].set(key, definition[key]);
57+
Object.defineProperty(this, key, {
58+
get() {
59+
return this[sDefinition].get(key);
60+
},
61+
enumerable: true,
62+
});
63+
}
64+
}
65+
}
66+
}
67+
68+
@factory
69+
static fromObject<
70+
K extends keyof T,
71+
V extends T[K],
72+
T extends Record<string | number, any>
73+
>(definition: T) {
74+
return new ObjectMap(definition) as ObjectMap<K, V, T> & T;
75+
}
76+
77+
@factory
78+
static fromKeys<T extends string>(keys: T[]) {
79+
const definition = {} as Record<T, T>;
80+
for (const key of keys) {
81+
definition[key] = key;
82+
}
83+
return new ObjectMap(definition) as ObjectMap<T, T, { [K in T]: K }> &
84+
{ [K in T]: K };
85+
}
86+
87+
@factory
88+
static prefixKeys<T extends string, K extends T>(
89+
keys: K[],
90+
prefix: string = '',
91+
) {
92+
const definition = {} as Record<K, string>;
93+
for (const key of keys) {
94+
definition[key] = prefixString(key, prefix);
95+
}
96+
return new ObjectMap(definition) as ObjectMap<
97+
K,
98+
string,
99+
{ [V in K]: string }
100+
> &
101+
{ [V in K]: string };
102+
}
103+
104+
static getKey<K extends keyof T, V extends T[K], T>(
105+
instance: ObjectMap<K, V, T> & T,
106+
value: V,
107+
): K {
108+
const [key = null] =
109+
find<[K, V]>(([, v]) => v === value, [...ObjectMap.entries(instance)]) ||
110+
[];
111+
return key;
112+
}
113+
114+
static entries<K extends keyof T, V extends T[K], T>(
115+
instance: ObjectMap<K, V, T> & T,
116+
): IterableIterator<[K, V]> {
117+
return instance[sDefinition].entries();
118+
}
119+
120+
static size<K extends keyof T, V extends T[K], T>(
121+
instance: ObjectMap<K, V, T> & T,
122+
): number {
123+
return instance[sDefinition].size;
124+
}
125+
126+
static has<K extends keyof T, V extends T[K], T>(
127+
instance: ObjectMap<K, V, T> & T,
128+
key: K,
129+
): boolean {
130+
return instance[sDefinition].has(key);
131+
}
132+
133+
static hasValue<K extends keyof T, V extends T[K], T>(
134+
instance: ObjectMap<K, V, T> & T,
135+
value: V,
136+
): boolean {
137+
return !!ObjectMap.getKey(instance, value);
138+
}
139+
140+
static keys<K extends keyof T, V extends T[K], T>(
141+
instance: ObjectMap<K, V, T> & T,
142+
): IterableIterator<K> {
143+
return instance[sDefinition].keys();
144+
}
145+
146+
static values<K extends keyof T, V extends T[K], T>(
147+
instance: ObjectMap<K, V, T> & T,
148+
): IterableIterator<V> {
149+
return instance[sDefinition].values();
150+
}
151+
152+
static forEach<K extends keyof T, V extends T[K], T>(
153+
fn: (value: V, key: K, map: ObjectMap<K, V, T> & T) => void,
154+
instance: ObjectMap<K, V, T> & T,
155+
): void {
156+
return instance[sDefinition].forEach((v, k) => fn(v, k, instance));
157+
}
158+
}

packages/core/lib/ObjectMap/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './ObjectMap';

0 commit comments

Comments
 (0)