Skip to content

Commit

Permalink
Merge branch 'main' into PDE-5395
Browse files Browse the repository at this point in the history
  • Loading branch information
rnegron committed Nov 22, 2024
2 parents 33d907c + 787317f commit c51c563
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 39 deletions.
12 changes: 9 additions & 3 deletions packages/core/src/tools/create-dehydrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ const wrapHydrate = require('./wrap-hydrate');
const createDehydrator = (input, type = 'method') => {
const app = _.get(input, '_zapier.app');

return (func, inputData) => {
return (func, inputData, cacheExpiration) => {
inputData = inputData || {};
if (inputData.inputData) {
throw new DehydrateError(
'Oops! You passed a full `bundle` - really you should pass what you want under `inputData`!'
);
}
return wrapHydrate({
const payload = {
type,
method: resolveMethodPath(app, func),
// inputData vs. bundle is a legacy oddity
bundle: _.omit(inputData, 'environment'), // don't leak the environment
});
};

if (cacheExpiration) {
payload.cacheExpiration = cacheExpiration;
}

return wrapHydrate(payload);
};
};

Expand Down
15 changes: 15 additions & 0 deletions packages/core/test/hydration.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ describe('hydration', () => {
);
});

it('should allow passing of cache expiration argument along in the dehydrated data', () => {
const result = dehydrate(funcToFind, {}, 60);
result.should.eql(
'hydrate|||{"type":"method","method":"some.path.to","bundle":{},"cacheExpiration":60}|||hydrate'
);
});

it('should not accept payload size bigger than 12000 bytes.', () => {
const inputData = { key: 'a'.repeat(12001) };
(() => {
Expand Down Expand Up @@ -91,6 +98,14 @@ describe('hydration', () => {
);
});

it('should allow passing of cache expiration argument along in the dehydrated data', () => {
const inputData = { key: 'value' };
const result = dehydrateFile(funcToFind, inputData, 60);
result.should.eql(
'hydrate|||{"type":"file","method":"some.path.to","bundle":{"key":"value"},"cacheExpiration":60}|||hydrate'
);
});

it('should not accept payload size bigger than 12000 bytes.', () => {
const inputData = { key: 'a'.repeat(12001) };
(() => {
Expand Down
73 changes: 69 additions & 4 deletions packages/core/types/zapier.custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,78 @@ export interface Bundle<InputData = { [x: string]: any }> {
inputDataRaw: { [x: string]: string };
meta: {
isBulkRead: boolean;

/**
* If true, this poll is being used to populate a dynamic dropdown.
* You only need to return the fields you specified (such as id and
* name), though returning everything is fine too.
*/
isFillingDynamicDropdown: boolean;

/**
* If true, this run was initiated manually via the Zap Editor.
*/
isLoadingSample: boolean;

/**
* If true, the results of this poll will be used to initialize the
* deduplication list rather than trigger a zap. You should grab as
* many items as possible.
*/
isPopulatingDedupe: boolean;

/**
* (legacy property) If true, the poll was triggered by a user
* testing their account (via clicking “test” or during setup). We
* use this data to populate the auth label, but it’s mostly used to
* verify we made a successful authenticated request
*
* @deprecated
*/
isTestingAuth: boolean;

/**
* The number of items you should fetch. -1 indicates there’s no
* limit. Build this into your calls insofar as you are able.
*/
limit: number;

/**
* Used in paging to uniquely identify which page of results should
* be returned.
*/
page: number;
zap?: { id: string };
inputFields?: { [x: string]: string | number | boolean };

/**
* When a create is called as part of a search-or-create step,
* this will be the key of the search.
*/
withSearch?: string;

/**
* The timezone the user has configured for their account or
* specific automation. Received as TZ identifier, such as
* “America/New_York”.
*/
timezone: string | null;

/** @deprecated */
zap?: {
/** @deprecated */
id: string;
/** @deprecated */
user: {
/** @deprecated use meta.timezone instead. */
timezone: string;
};
};

/**
* Contains metadata about the input fields, optionally provided
* by the inputField.meta property. Useful for storing extra data
* in dynamically created input fields.
*/
inputFields: { [fieldKey: string]: { [metaKey: string]: string | number | boolean } };
};
rawRequest?: Partial<{
method: HttpMethod;
Expand Down Expand Up @@ -134,7 +198,8 @@ export interface RawHttpResponse<T = any> extends BaseHttpResponse {

type DehydrateFunc = <T>(
func: (z: ZObject, bundle: Bundle<T>) => any,
inputData: T
inputData?: T,
cacheExpiration?: number
) => string;

export interface ZObject {
Expand Down Expand Up @@ -214,7 +279,7 @@ export interface ZObject {

cache: {
get: (key: string) => Promise<any>;
set: (key: string, value: any, ttl?: number) => Promise<boolean>;
set: (key: string, value: any, ttl?: number, scope?: string[], nx?: boolean) => Promise<boolean|null>;
delete: (key: string) => Promise<boolean>;
};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/legacy-scripting-runner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.8.14

- :bug: Revert `aws-sdk v2` bundling change from 3.8.13 ([#916](https://github.com/zapier/zapier-platform/pull/916)). This release is essentially the same as 3.8.12.

## 3.8.13

- :hammer: Add `aws-sdk v2` to dependency list ([#912](https://github.com/zapier/zapier-platform/pull/912))
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy-scripting-runner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zapier-platform-legacy-scripting-runner",
"version": "3.8.13",
"version": "3.8.14",
"description": "Zapier's Legacy Scripting Runner, used by Web Builder apps converted to CLI.",
"repository": "zapier/zapier-platform",
"homepage": "https://platform.zapier.com/",
Expand All @@ -25,7 +25,6 @@
},
"dependencies": {
"async": "2.6.4",
"aws-sdk": "2.1691.0",
"flat": "5.0.2",
"jquery": "3.5.0",
"jsdom": "7.0.0",
Expand All @@ -38,6 +37,7 @@
"xmldom": "0.3.0"
},
"devDependencies": {
"aws-sdk": "^2.1397.0",
"nock": "13.3.1",
"zapier-platform-core": ">=7.6.0"
}
Expand Down
6 changes: 3 additions & 3 deletions schema-to-ts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ confbox@^0.1.7:
integrity sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==

cross-spawn@^7.0.0, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
version "7.0.6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
Expand Down
55 changes: 28 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2775,22 +2775,6 @@ available-typed-arrays@^1.0.5:
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"
integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==

[email protected]:
version "2.1691.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1691.0.tgz#9d6ccdcbae03c806fc62667b76eb3e33e5294dcc"
integrity sha512-/F2YC+DlsY3UBM2Bdnh5RLHOPNibS/+IcjUuhP8XuctyrN+MlL+fWDAiela32LTDk7hMy4rx8MTgvbJ+0blO5g==
dependencies:
buffer "4.9.2"
events "1.1.1"
ieee754 "1.1.13"
jmespath "0.16.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
util "^0.12.4"
uuid "8.0.0"
xml2js "0.6.2"

aws-sdk@^2.1397.0:
version "2.1397.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1397.0.tgz#fdecbc04dcd8f33c2868e1b0691ce93a506704f5"
Expand Down Expand Up @@ -10725,7 +10709,7 @@ [email protected]:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -10743,6 +10727,15 @@ string-width@^1.0.1:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
Expand Down Expand Up @@ -10844,7 +10837,7 @@ [email protected]:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -10879,6 +10872,13 @@ strip-ansi@^6.0.0:
dependencies:
ansi-regex "^5.0.0"

strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -11914,7 +11914,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -11941,6 +11941,15 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down Expand Up @@ -12063,14 +12072,6 @@ [email protected]:
sax ">=0.6.0"
xmlbuilder "~11.0.0"

[email protected]:
version "0.6.2"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499"
integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==
dependencies:
sax ">=0.6.0"
xmlbuilder "~11.0.0"

xmlbuilder@~11.0.0:
version "11.0.1"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"
Expand Down

0 comments on commit c51c563

Please sign in to comment.