Skip to content

Commit

Permalink
Merge pull request #32057 from RocketChat/release-6.6.6
Browse files Browse the repository at this point in the history
Release 6.6.6
  • Loading branch information
sampaiodiego authored Mar 25, 2024
2 parents 68f0a91 + 5f5b338 commit d8eb371
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/bump-patch-1711139853086.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Bump @rocket.chat/meteor version.
5 changes: 5 additions & 0 deletions .changeset/chatty-suits-dance.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions .changeset/thirty-ducks-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/models": patch
---

Fix proxified model props were missing context before attribution
5 changes: 5 additions & 0 deletions .changeset/twenty-dolls-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fix error during migration 304. Throwing `Cannot read property 'finally' of undefined` error.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"oauthapps",
"omnichannel",
"photoswipe",
"proxify",
"searchbox",
"tmid",
"tshow"
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:^",
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/ddp-streamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ee/packages/presence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:~"
Expand Down
2 changes: 1 addition & 1 deletion packages/fuselage-ui-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions packages/models/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
preset: 'ts-jest',
errorOnDeprecated: true,
testEnvironment: 'jsdom',
modulePathIgnorePatterns: ['<rootDir>/dist/'],
testMatch: ['**/**.spec.ts'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
moduleNameMapper: {
'\\.css$': 'identity-obj-proxy',
},
collectCoverage: true,
};
6 changes: 5 additions & 1 deletion packages/models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
91 changes: 91 additions & 0 deletions packages/models/src/proxify.spec.ts
Original file line number Diff line number Diff line change
@@ -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<any>('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<any>('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<any>('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<any>('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<any>('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<any>('collection-prop', () => collection);
expect(() => {
collectionMocked.prop = 'new value';
}).toThrowError('Models accessed via proxify are read-only, use the model instance directly to modify it.');
});
});
18 changes: 16 additions & 2 deletions packages/models/src/proxify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const models = new Map<string, IBaseModel<any>>();

function handler<T extends object>(namespace: string): ProxyHandler<T> {
return {
get: (_target: T, prop: keyof IBaseModel<any>): any => {
get: (_target: T, nameProp: keyof IBaseModel<any>): any => {
if (!models.has(namespace) && lazyModels.has(namespace)) {
const getModel = lazyModels.get(namespace);
if (getModel) {
Expand All @@ -19,7 +19,21 @@ function handler<T extends object>(namespace: string): ProxyHandler<T> {
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;
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:~",
Expand Down
Loading

0 comments on commit d8eb371

Please sign in to comment.