From 16abc32610d641b00fa5c8369e93d75680cfea92 Mon Sep 17 00:00:00 2001 From: rocketchat-github-ci Date: Fri, 22 Mar 2024 20:37:33 +0000 Subject: [PATCH 1/3] Bump 6.6.6 --- .changeset/bump-patch-1711139853086.md | 5 +++++ yarn.lock | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changeset/bump-patch-1711139853086.md diff --git a/.changeset/bump-patch-1711139853086.md b/.changeset/bump-patch-1711139853086.md new file mode 100644 index 000000000000..e1eaa7980afb --- /dev/null +++ b/.changeset/bump-patch-1711139853086.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Bump @rocket.chat/meteor version. diff --git a/yarn.lock b/yarn.lock index ad4b44b6d3d5..1c93b8bf990c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9348,9 +9348,9 @@ __metadata: "@rocket.chat/icons": "*" "@rocket.chat/prettier-config": "*" "@rocket.chat/styled": "*" - "@rocket.chat/ui-contexts": 4.0.4 + "@rocket.chat/ui-contexts": 4.0.5 "@rocket.chat/ui-kit": 0.33.0 - "@rocket.chat/ui-video-conf": 4.0.4 + "@rocket.chat/ui-video-conf": 4.0.5 "@tanstack/react-query": "*" react: "*" react-dom: "*" @@ -9432,14 +9432,14 @@ __metadata: ts-jest: ~29.1.1 typescript: ~5.3.2 peerDependencies: - "@rocket.chat/core-typings": 6.6.4 + "@rocket.chat/core-typings": 6.6.5 "@rocket.chat/css-in-js": "*" "@rocket.chat/fuselage": "*" "@rocket.chat/fuselage-tokens": "*" "@rocket.chat/message-parser": "*" "@rocket.chat/styled": "*" - "@rocket.chat/ui-client": 4.0.4 - "@rocket.chat/ui-contexts": 4.0.4 + "@rocket.chat/ui-client": 4.0.5 + "@rocket.chat/ui-contexts": 4.0.5 katex: "*" react: "*" languageName: unknown @@ -10621,7 +10621,7 @@ __metadata: "@rocket.chat/fuselage": "*" "@rocket.chat/fuselage-hooks": "*" "@rocket.chat/icons": "*" - "@rocket.chat/ui-contexts": 4.0.4 + "@rocket.chat/ui-contexts": 4.0.5 react: ~17.0.2 languageName: unknown linkType: soft @@ -10796,7 +10796,7 @@ __metadata: "@rocket.chat/fuselage-hooks": "*" "@rocket.chat/icons": "*" "@rocket.chat/styled": "*" - "@rocket.chat/ui-contexts": 4.0.4 + "@rocket.chat/ui-contexts": 4.0.5 react: ^17.0.2 react-dom: ^17.0.2 languageName: unknown @@ -10885,7 +10885,7 @@ __metadata: peerDependencies: "@rocket.chat/layout": "*" "@rocket.chat/tools": 0.2.1 - "@rocket.chat/ui-contexts": 4.0.4 + "@rocket.chat/ui-contexts": 4.0.5 "@tanstack/react-query": "*" react: "*" react-hook-form: "*" From ada096901ad8f007b78f7f9f4a39d52edd13708a Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 22 Mar 2024 18:49:04 -0300 Subject: [PATCH 2/3] fix: proxified model props were missing context before attribution (#32056) --- .changeset/thirty-ducks-smell.md | 5 ++ .changeset/twenty-dolls-obey.md | 5 ++ .vscode/settings.json | 1 + packages/models/jest.config.ts | 14 +++++ packages/models/package.json | 6 +- packages/models/src/proxify.spec.ts | 91 +++++++++++++++++++++++++++++ packages/models/src/proxify.ts | 18 +++++- yarn.lock | 2 + 8 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 .changeset/thirty-ducks-smell.md create mode 100644 .changeset/twenty-dolls-obey.md create mode 100644 packages/models/jest.config.ts create mode 100644 packages/models/src/proxify.spec.ts diff --git a/.changeset/thirty-ducks-smell.md b/.changeset/thirty-ducks-smell.md new file mode 100644 index 000000000000..e6f482d5fcea --- /dev/null +++ b/.changeset/thirty-ducks-smell.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/models": patch +--- + +Fix proxified model props were missing context before attribution diff --git a/.changeset/twenty-dolls-obey.md b/.changeset/twenty-dolls-obey.md new file mode 100644 index 000000000000..c886cf9cbc83 --- /dev/null +++ b/.changeset/twenty-dolls-obey.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fix error during migration 304. Throwing `Cannot read property 'finally' of undefined` error. diff --git a/.vscode/settings.json b/.vscode/settings.json index c9d889142050..4eaf1836d1fd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,6 +29,7 @@ "oauthapps", "omnichannel", "photoswipe", + "proxify", "searchbox", "tmid", "tshow" diff --git a/packages/models/jest.config.ts b/packages/models/jest.config.ts new file mode 100644 index 000000000000..eb3f38119a73 --- /dev/null +++ b/packages/models/jest.config.ts @@ -0,0 +1,14 @@ +export default { + preset: 'ts-jest', + errorOnDeprecated: true, + testEnvironment: 'jsdom', + modulePathIgnorePatterns: ['/dist/'], + testMatch: ['**/**.spec.ts'], + transform: { + '^.+\\.(t|j)sx?$': '@swc/jest', + }, + moduleNameMapper: { + '\\.css$': 'identity-obj-proxy', + }, + collectCoverage: true, +}; diff --git a/packages/models/package.json b/packages/models/package.json index 730765cd6778..8e7a13c6b45a 100644 --- a/packages/models/package.json +++ b/packages/models/package.json @@ -3,6 +3,8 @@ "version": "0.0.33", "private": true, "devDependencies": { + "@swc/core": "^1.3.95", + "@swc/jest": "^0.2.29", "@types/jest": "~29.5.7", "eslint": "~8.45.0", "jest": "~29.6.4", @@ -17,7 +19,9 @@ "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", "test": "jest", "dev": "tsc --watch --preserveWatchOutput -p tsconfig.json", - "build": "rm -rf dist && tsc -p tsconfig.json" + "build": "rm -rf dist && tsc -p tsconfig.json", + "unit": "jest", + "testunit": "jest" }, "main": "./dist/index.js", "typings": "./dist/index.d.ts", diff --git a/packages/models/src/proxify.spec.ts b/packages/models/src/proxify.spec.ts new file mode 100644 index 000000000000..b75d53d1651a --- /dev/null +++ b/packages/models/src/proxify.spec.ts @@ -0,0 +1,91 @@ +import { proxify, registerModel } from './proxify'; + +type MockedModel = { + method: () => MockedModel; +}; + +describe('non lazy proxify', () => { + it('should keep this inside functions', () => { + const collectionMocked = proxify('collection') as MockedModel; + const collection = { + method() { + return this; + }, + }; + registerModel('collection', collection); + + expect(collectionMocked.method()).toBe(collection); + }); + it('should throw an error if the model is not found', () => { + const collectionMocked = proxify('collection-not-found') as MockedModel; + expect(() => collectionMocked.method()).toThrowError('Model collection-not-found not found'); + }); + + it('should return a proxified property', () => { + const collectionMocked = proxify('collection-prop') as { + prop: string; + }; + const collection = { + prop: 'value', + }; + registerModel('collection-prop', collection); + expect(collectionMocked.prop).toBe('value'); + }); + + it('should throw an error if trying to set a property from the proxified object', () => { + const collectionMocked = proxify('collection-prop') as { + prop: string; + }; + const collection = { + prop: 'value', + }; + registerModel('collection-prop', collection); + expect(() => { + collectionMocked.prop = 'new value'; + }).toThrowError('Models accessed via proxify are read-only, use the model instance directly to modify it.'); + }); +}); + +describe('lazy proxify', () => { + it('should keep this inside functions', () => { + const collectionMocked = proxify('collection-lazy') as MockedModel; + const collection = { + method() { + return this; + }, + }; + + registerModel('collection-lazy', () => collection); + + expect(collectionMocked.method()).toBe(collection); + }); + + it('should throw an error if the model is not found', () => { + const collectionMocked = proxify('collection-not-found') as MockedModel; + expect(() => collectionMocked.method()).toThrowError('Model collection-not-found not found'); + }); + + it('should return a proxified property', () => { + const collectionMocked = proxify('collection-prop') as { + prop: string; + }; + const collection = { + prop: 'value', + }; + registerModel('collection-prop', () => collection); + expect(collectionMocked.prop).toBe('value'); + }); + + it('should throw an error if trying to set a property from the proxified object', () => { + const collectionMocked = proxify('collection-prop') as { + prop: string; + }; + const collection = { + prop: 'value', + }; + registerModel('collection-prop', () => collection); + expect(() => { + collectionMocked.prop = 'new value'; + }).toThrowError('Models accessed via proxify are read-only, use the model instance directly to modify it.'); + }); +}); diff --git a/packages/models/src/proxify.ts b/packages/models/src/proxify.ts index 3c75897b38fd..54ff914f23f6 100644 --- a/packages/models/src/proxify.ts +++ b/packages/models/src/proxify.ts @@ -5,7 +5,7 @@ const models = new Map>(); function handler(namespace: string): ProxyHandler { return { - get: (_target: T, prop: keyof IBaseModel): any => { + get: (_target: T, nameProp: keyof IBaseModel): any => { if (!models.has(namespace) && lazyModels.has(namespace)) { const getModel = lazyModels.get(namespace); if (getModel) { @@ -19,7 +19,21 @@ function handler(namespace: string): ProxyHandler { throw new Error(`Model ${namespace} not found`); } - return model[prop]; + const prop = model[nameProp]; + + if (typeof prop === 'function') { + return prop.bind(model); + } + + return prop; + }, + + set() { + if (process.env.NODE_ENV !== 'production') { + throw new Error('Models accessed via proxify are read-only, use the model instance directly to modify it.'); + } + /* istanbul ignore next */ + return true; }, }; } diff --git a/yarn.lock b/yarn.lock index 1c93b8bf990c..841921d1be51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10103,6 +10103,8 @@ __metadata: resolution: "@rocket.chat/models@workspace:packages/models" dependencies: "@rocket.chat/model-typings": "workspace:^" + "@swc/core": ^1.3.95 + "@swc/jest": ^0.2.29 "@types/jest": ~29.5.7 eslint: ~8.45.0 jest: ~29.6.4 From 5f5b3381040a60547553afc30ee3f24ec471da8e Mon Sep 17 00:00:00 2001 From: Allan RIbeiro <35040806+AllanPazRibeiro@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:21:36 -0300 Subject: [PATCH 3/3] chore: bump apps engine version (#32064) --- .changeset/chatty-suits-dance.md | 5 +++++ apps/meteor/ee/server/services/package.json | 2 +- apps/meteor/package.json | 2 +- ee/apps/ddp-streamer/package.json | 2 +- ee/packages/presence/package.json | 2 +- packages/core-services/package.json | 2 +- packages/core-typings/package.json | 2 +- packages/fuselage-ui-kit/package.json | 2 +- packages/rest-typings/package.json | 2 +- yarn.lock | 24 ++++++++++----------- 10 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 .changeset/chatty-suits-dance.md diff --git a/.changeset/chatty-suits-dance.md b/.changeset/chatty-suits-dance.md new file mode 100644 index 000000000000..da66d205e57f --- /dev/null +++ b/.changeset/chatty-suits-dance.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fix an issue affecting Rocket.Chat Apps utilizing the OAuth 2 library from Apps Engine, ensuring that apps like Google Drive and Google Calendar are operational once more. diff --git a/apps/meteor/ee/server/services/package.json b/apps/meteor/ee/server/services/package.json index cd0d4845c562..760304b16dad 100644 --- a/apps/meteor/ee/server/services/package.json +++ b/apps/meteor/ee/server/services/package.json @@ -18,7 +18,7 @@ "author": "Rocket.Chat", "license": "MIT", "dependencies": { - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/core-services": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/emitter": "~0.31.25", diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 3f8003573ee7..f4fa17b0b3c0 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -229,7 +229,7 @@ "@rocket.chat/account-utils": "workspace:^", "@rocket.chat/agenda": "workspace:^", "@rocket.chat/api-client": "workspace:^", - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/base64": "workspace:^", "@rocket.chat/cas-validate": "workspace:^", "@rocket.chat/core-services": "workspace:^", diff --git a/ee/apps/ddp-streamer/package.json b/ee/apps/ddp-streamer/package.json index 3665ba917b95..0eea899ee128 100644 --- a/ee/apps/ddp-streamer/package.json +++ b/ee/apps/ddp-streamer/package.json @@ -15,7 +15,7 @@ ], "author": "Rocket.Chat", "dependencies": { - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/core-services": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/emitter": "~0.31.25", diff --git a/ee/packages/presence/package.json b/ee/packages/presence/package.json index 4341948053b2..a064b02e5e2c 100644 --- a/ee/packages/presence/package.json +++ b/ee/packages/presence/package.json @@ -6,7 +6,7 @@ "@babel/core": "~7.22.20", "@babel/preset-env": "~7.22.20", "@babel/preset-typescript": "~7.22.15", - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/eslint-config": "workspace:^", "@rocket.chat/rest-typings": "workspace:^", "@types/node": "^14.18.63", diff --git a/packages/core-services/package.json b/packages/core-services/package.json index a30be0955f98..e59e7848133a 100644 --- a/packages/core-services/package.json +++ b/packages/core-services/package.json @@ -34,7 +34,7 @@ "extends": "../../package.json" }, "dependencies": { - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/icons": "^0.33.0", "@rocket.chat/message-parser": "~0.31.28", diff --git a/packages/core-typings/package.json b/packages/core-typings/package.json index 49240250fd8e..c3ffda80dbb7 100644 --- a/packages/core-typings/package.json +++ b/packages/core-typings/package.json @@ -23,7 +23,7 @@ "/dist" ], "dependencies": { - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/icons": "^0.33.0", "@rocket.chat/message-parser": "~0.31.28", "@rocket.chat/ui-kit": "workspace:~" diff --git a/packages/fuselage-ui-kit/package.json b/packages/fuselage-ui-kit/package.json index 697af4205e1d..836e6d4c23d7 100644 --- a/packages/fuselage-ui-kit/package.json +++ b/packages/fuselage-ui-kit/package.json @@ -60,7 +60,7 @@ "@babel/preset-env": "~7.22.20", "@babel/preset-react": "~7.22.15", "@babel/preset-typescript": "~7.22.15", - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/eslint-config": "workspace:^", "@rocket.chat/fuselage": "^0.45.0", "@rocket.chat/fuselage-hooks": "^0.33.0", diff --git a/packages/rest-typings/package.json b/packages/rest-typings/package.json index b677af5d2ffa..46a513925690 100644 --- a/packages/rest-typings/package.json +++ b/packages/rest-typings/package.json @@ -25,7 +25,7 @@ "/dist" ], "dependencies": { - "@rocket.chat/apps-engine": "1.41.0", + "@rocket.chat/apps-engine": "^1.41.1", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/message-parser": "~0.31.28", "@rocket.chat/ui-kit": "workspace:~", diff --git a/yarn.lock b/yarn.lock index 841921d1be51..e182adf898df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8919,9 +8919,9 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/apps-engine@npm:1.41.0": - version: 1.41.0 - resolution: "@rocket.chat/apps-engine@npm:1.41.0" +"@rocket.chat/apps-engine@npm:^1.41.1": + version: 1.41.1 + resolution: "@rocket.chat/apps-engine@npm:1.41.1" dependencies: adm-zip: ^0.5.9 cryptiles: ^4.1.3 @@ -8933,7 +8933,7 @@ __metadata: vm2: ^3.9.19 peerDependencies: "@rocket.chat/ui-kit": "*" - checksum: 2e7fa2856bdbdc6b0dd2456e9aa5e5804a4198f8df0306a002c5e71681466d3fc2cb0a1253668d5e24fa21345a7dd7eed3458a257e1e4cc59a4e8a3876579aa5 + checksum: 3134570898516f5d40ae66be3841d5987daeceb3a8f04ee85b0bf2bf079a24198ec9026863cb1ba4ed3d171ac67c4feda17948b1357315fe5ec427f342a70ec1 languageName: node linkType: hard @@ -9005,7 +9005,7 @@ __metadata: "@babel/core": ~7.22.20 "@babel/preset-env": ~7.22.20 "@babel/preset-typescript": ~7.22.15 - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/icons": ^0.33.0 @@ -9031,7 +9031,7 @@ __metadata: version: 0.0.0-use.local resolution: "@rocket.chat/core-typings@workspace:packages/core-typings" dependencies: - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/icons": ^0.33.0 "@rocket.chat/message-parser": ~0.31.28 @@ -9107,7 +9107,7 @@ __metadata: version: 0.0.0-use.local resolution: "@rocket.chat/ddp-streamer@workspace:ee/apps/ddp-streamer" dependencies: - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/core-services": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/emitter": ~0.31.25 @@ -9302,7 +9302,7 @@ __metadata: "@babel/preset-env": ~7.22.20 "@babel/preset-react": ~7.22.15 "@babel/preset-typescript": ~7.22.15 - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/fuselage": ^0.45.0 "@rocket.chat/fuselage-hooks": ^0.33.0 @@ -9709,7 +9709,7 @@ __metadata: "@rocket.chat/account-utils": "workspace:^" "@rocket.chat/agenda": "workspace:^" "@rocket.chat/api-client": "workspace:^" - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/base64": "workspace:^" "@rocket.chat/cas-validate": "workspace:^" "@rocket.chat/core-services": "workspace:^" @@ -10310,7 +10310,7 @@ __metadata: "@babel/core": ~7.22.20 "@babel/preset-env": ~7.22.20 "@babel/preset-typescript": ~7.22.15 - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/core-services": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" @@ -10425,7 +10425,7 @@ __metadata: version: 0.0.0-use.local resolution: "@rocket.chat/rest-typings@workspace:packages/rest-typings" dependencies: - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/message-parser": ~0.31.28 @@ -36570,7 +36570,7 @@ __metadata: version: 0.0.0-use.local resolution: "rocketchat-services@workspace:apps/meteor/ee/server/services" dependencies: - "@rocket.chat/apps-engine": 1.41.0 + "@rocket.chat/apps-engine": ^1.41.1 "@rocket.chat/core-services": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/emitter": ~0.31.25