Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next release #913

Merged
merged 59 commits into from
Jan 16, 2025
Merged
Changes from 4 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
dcbd3f9
gmail initial
Nov 22, 2024
5ffd81b
added eslintrc
Nov 22, 2024
210aa63
Condensed declarations of "desired content" type.
Jan 4, 2025
269db4d
gmail: update readme for clarity
josephjclark Jan 4, 2025
a889870
gmail: restructure to move util functions out
josephjclark Jan 4, 2025
160a49d
Merge pull request #871 from OpenFn/nhgh/gmail-readme
decarteret Jan 7, 2025
3418920
Merge pull request #872 from OpenFn/nhgh/gmail-structure
decarteret Jan 7, 2025
593e119
Adding pnpm-lock.yaml
Jan 7, 2025
bca5ef3
Merge branch 'main' into nhgh/gmail
Jan 7, 2025
2d709ff
common: fix an issue where RegExp objects were serialised by expandRe…
josephjclark Jan 7, 2025
ecc69d2
common: fix regex identity issue
josephjclark Jan 8, 2025
198e86b
gmail: declare isTesting variable in utils
josephjclark Jan 8, 2025
aa654ab
Merge pull request #875 from OpenFn/expand-regex
decarteret Jan 9, 2025
9e5c891
Modify desiredContent to use psuedo-regex as a workaround.
Jan 8, 2025
16d147d
Moved message retrieval earlier to prevent multiple loads.
Jan 9, 2025
b4d378b
chore: added optional Personal Access Token field in the configuratio…
PiusKariuki Jan 10, 2025
b3b9e43
chore: added the logic to that uses the PAT if provided, but defaults…
PiusKariuki Jan 10, 2025
dd59026
Reorganized, restructured, refactored in preparation for release.
Jan 11, 2025
b1756cd
Added more consistent object naming.
Jan 11, 2025
57e5785
Added an assert function to common
PiusKariuki Jan 11, 2025
15a6a3b
Added unit tests for the assert function
PiusKariuki Jan 11, 2025
2a1d9de
edited ast.json
PiusKariuki Jan 12, 2025
fbb7cb4
refactor
PiusKariuki Jan 12, 2025
11bd33d
Updated the docs
PiusKariuki Jan 12, 2025
33f796c
(fix) employed the util version of "expandReferences" that has a clea…
PiusKariuki Jan 12, 2025
c12c99d
(fix) edited the unit tests to expect "state" to be returned instead …
PiusKariuki Jan 12, 2025
dd65208
(fix) assert function should return state
PiusKariuki Jan 12, 2025
9412aed
A test to check if the function falls back to the generic error message
PiusKariuki Jan 12, 2025
4144174
Added a generic error message to fall back on in case one is not passed
PiusKariuki Jan 12, 2025
0e5a364
Swapped a cleaner key for the token: `pat`
PiusKariuki Jan 12, 2025
ab1150f
changed the named argument `personalAccessToken` to a cleaner one `pat`
PiusKariuki Jan 12, 2025
c19d561
changeset markdown file
PiusKariuki Jan 12, 2025
41e8cc3
changeset markdown file
PiusKariuki Jan 12, 2025
5f407d4
Added a unit test to encode a javascript object
PiusKariuki Jan 13, 2025
60f3279
Added the logic to encode Javascript objects by stringifying them first
PiusKariuki Jan 13, 2025
4d77f48
Added a unit test to decode a javascript object
PiusKariuki Jan 13, 2025
d7cd95c
Added a logic to decode a JSON object and parse it back to a standard…
PiusKariuki Jan 13, 2025
46860a9
common: add assert() function
josephjclark Jan 14, 2025
2da52d7
common: expand error message on assert, fix docs and update tests
josephjclark Jan 14, 2025
1bee83e
Merge pull request #897 from PiusKariuki/support-PAT-for-DHIS2
josephjclark Jan 14, 2025
ef6108f
changeset: make dhis2 change a minor release
josephjclark Jan 14, 2025
9f908c0
(refactor) Stringify any object parsed that is not a string
PiusKariuki Jan 14, 2025
8109acd
(refactor) remove this since we are stringifying anything that isn't …
PiusKariuki Jan 14, 2025
8166c2e
Updated the docs to make it clear that we can pass any string ot JSON…
PiusKariuki Jan 14, 2025
35bf1b9
Update the test suite to expect any non-string values to be stringifi…
PiusKariuki Jan 14, 2025
90dba91
Log and error in case there's a problem in the stringification step
PiusKariuki Jan 14, 2025
07a4dec
Updated the docs of the decode function to include JSON objects too
PiusKariuki Jan 14, 2025
557a7f5
Changed the signatures of the decode and encode functions to include …
PiusKariuki Jan 14, 2025
0b31a9f
Expanded the tests to cater for the extra complexity added to the enc…
PiusKariuki Jan 14, 2025
415580b
Enhanced options parameters to be an optional object to simply future…
Jan 14, 2025
3d7e7ff
Moved prior processedIds into the options object.
Jan 15, 2025
b3d7f59
Changeset markdown file
PiusKariuki Jan 15, 2025
0078389
(refactor) renamed the `decodedObject` to `decodedValue`
PiusKariuki Jan 15, 2025
18b6aaa
Merge pull request #904 from PiusKariuki/common-util-encode-should-ta…
josephjclark Jan 16, 2025
bc495ae
merge main
josephjclark Jan 16, 2025
eb2c5c8
Merge pull request #870 from OpenFn/nhgh/gmail
josephjclark Jan 16, 2025
920d9a4
Merge branch 'main' into release/next
josephjclark Jan 16, 2025
bc060c7
versions
josephjclark Jan 16, 2025
667aacf
ast
josephjclark Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nasty-pumpkins-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/language-common': patch
---

Ensure that RegExp objects can be safely passed as references
6 changes: 5 additions & 1 deletion packages/common/src/util/references.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,11 @@ const isStream = value => {
};

function expandReference(state, value) {
if (Buffer.isBuffer(value)) {
if (
Buffer.isBuffer(value) ||
// Note: there is a weird identity thing in the VM where typeof RegExp will be false ¯\_(ツ)_/¯
value?.constructor?.name === 'RegExp'
) {
return value;
}

25 changes: 24 additions & 1 deletion packages/common/test/util/references.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { expect } from 'chai';
import { expandReferences, normalizeOauthConfig } from '../../src/util/index.js';
import {
expandReferences,
normalizeOauthConfig,
} from '../../src/util/index.js';

describe('util expandReferences', () => {
it('should not modify string references', () => {
@@ -11,6 +14,26 @@ describe('util expandReferences', () => {
expect(resolvedName).to.equal('mulder');
});

it('should ignore regex literals', () => {
const regex = /scully/;
const state = {};

const [resolvedRegex] = expandReferences(state, regex);

expect(resolvedRegex instanceof RegExp).to.be.true;
expect(resolvedRegex.test('scully')).to.be.true;
});

it('should ignore regex instances', () => {
const regex = new RegExp('scully');
const state = {};

const [resolvedRegex] = expandReferences(state, regex);

expect(resolvedRegex instanceof RegExp).to.be.true;
expect(resolvedRegex.test('scully')).to.be.true;
});

it('should expand function references', () => {
const state = { name: 'mulder' };
const name = s => s.name;
3 changes: 2 additions & 1 deletion packages/gmail/src/Utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import unzipper from 'unzipper';
import { google } from 'googleapis';

let gmail = undefined;
let gmail;
let isTesting;

export async function fetchMessages(userId, query, lastPageToken) {
let messagesResponse = null;