Skip to content

Commit

Permalink
sync features and bugfixs from e8bf8f7 (#1630)
Browse files Browse the repository at this point in the history
* 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
embbnux authored Jun 3, 2020
1 parent be3351f commit dc9e803
Show file tree
Hide file tree
Showing 755 changed files with 42,258 additions and 4,484 deletions.
2 changes: 1 addition & 1 deletion .sync
Original file line number Diff line number Diff line change
@@ -1 +1 @@
251d34c1aac96cffe15c70a87f4cc547dcd83420
e8bf8f74050d43715af4216e79e297525396f39b
32 changes: 29 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]+"
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"glip-widgets:start-release": "babel-node scripts/startRelease.js @ringcentral-integration/glip-widgets glip-widgets-release",
"core:prepare-release": "babel-node scripts/prepareRelease.js @ringcentral-integration/core core-release",
"core:start-release": "babel-node scripts/startRelease.js @ringcentral-integration/core core-release",
"engage-voice-widgets:prepare-release": "babel-node scripts/prepareRelease.js @ringcentral-integration/engage-voice-widgets engage-voice-widgets-release",
"engage-voice-widgets:start-release": "babel-node scripts/startRelease.js @ringcentral-integration/engage-voice-widgets engage-voice-widgets-release",
"commit": "yarn git-cz"
},
"devDependencies": {
Expand Down
37 changes: 18 additions & 19 deletions packages/babel-settings/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "@ringcentral-integration/babel-settings",
"version": "1.0.0",
"private": true,
"version": "0.0.1",
"main": "index.js",
"description": "Shared babel settings",
"description": "RingCentral Integration shared babel settings",
"repository": {
"type": "git",
"url": "https://github.com/ringcentral/ringcentral-js-widget.git"
Expand All @@ -13,22 +12,22 @@
},
"scripts": {},
"dependencies": {
"@babel/core": "^7.6.0",
"@babel/node": "^7.6.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.6.0",
"@babel/plugin-proposal-export-default-from": "^7.5.2",
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
"@babel/plugin-proposal-function-bind": "^7.2.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
"@babel/plugin-proposal-optional-chaining": "^7.7.5",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.6.0",
"@babel/register": "^7.6.0",
"core-js": "^3.0.1",
"typescript": "^3.7.3"
"@babel/core": "^7.9.6",
"@babel/node": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-proposal-export-default-from": "^7.8.3",
"@babel/plugin-proposal-export-namespace-from": "^7.8.3",
"@babel/plugin-proposal-function-bind": "^7.8.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.9.0",
"@babel/register": "^7.9.0",
"core-js": "^2.6.11",
"typescript": "^3.9.2"
},
"peerDependencies": {
"@babel/polyfill": "^7.6.0",
Expand Down
158 changes: 158 additions & 0 deletions packages/core/lib/ObjectMap/ObjectMap.ts
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));
}
}
1 change: 1 addition & 0 deletions packages/core/lib/ObjectMap/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ObjectMap';
Loading

0 comments on commit dc9e803

Please sign in to comment.