zapier-platform-core
Advanced tools
Comparing version 15.17.0 to 15.18.0
@@ -1,3 +0,1 @@ | ||
Read docs: https://zapier.github.io/zapier-platform/. | ||
Changelog: https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md | ||
See [CHANGELOG.md](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md). |
{ | ||
"name": "zapier-platform-core", | ||
"version": "15.17.0", | ||
"version": "15.18.0", | ||
"description": "The core SDK for CLI apps in the Zapier Developer Platform.", | ||
@@ -56,3 +56,3 @@ "repository": "zapier/zapier-platform", | ||
"semver": "7.5.2", | ||
"zapier-platform-schema": "15.17.0" | ||
"zapier-platform-schema": "15.18.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "devDependencies": { |
@@ -1,7 +0,11 @@ | ||
# Core for Zapier CLI Platform [![Travis](https://img.shields.io/travis/zapier/zapier-platform-core.svg)](https://travis-ci.org/zapier/zapier-platform-core) | ||
# Zapier Platform Core | ||
This is the code that powers our [Zapier Platform CLI](https://zapier.github.io/zapier-platform-cli). You'll want to head to that repo to see how it's used. | ||
This is the SDK used in Zapier integrations. | ||
## Development | ||
See [CONTRIBUTING.md](https://github.com/zapier/zapier-platform/blob/main/CONTRIBUTING.md) and [ARCHITECTURE.md](https://github.com/zapier/zapier-platform/blob/main/packages/core/ARCHITECTURE.md) of this package in particular. | ||
Useful commands: | ||
* `npm install` for getting started | ||
@@ -19,4 +23,6 @@ * `npm test` for running unit tests | ||
## Publishing (after merging) | ||
## Publishing | ||
Only do this after merging your PR to `main`. | ||
* `npm version [patch|minor|major]` will pull, test, update schema version in dependencies for this package, update docs, increment version in package.json, and push tags, which then will tell Travis to publish to npm |
@@ -15,3 +15,4 @@ 'use strict'; | ||
ttl = null, | ||
scope = null | ||
scope = null, | ||
nx = null | ||
) => { | ||
@@ -40,2 +41,6 @@ if (!rpc) { | ||
if (nx !== null && !_.isBoolean(nx)) { | ||
throw new TypeError('nx must be a boolean'); | ||
} | ||
ensureJSONEncodable(value); | ||
@@ -51,6 +56,6 @@ }; | ||
}, | ||
set: async (key, value, ttl = null, scope = null) => { | ||
runValidationChecks(rpc, key, value, ttl, scope); | ||
set: async (key, value, ttl = null, scope = null, nx = null) => { | ||
runValidationChecks(rpc, key, value, ttl, scope, nx); | ||
return await rpc('zcache_set', key, JSON.stringify(value), ttl, scope); | ||
return await rpc('zcache_set', key, JSON.stringify(value), ttl, scope, nx); | ||
}, | ||
@@ -57,0 +62,0 @@ delete: async (key, scope = null) => { |
@@ -199,3 +199,4 @@ 'use strict'; | ||
// If we're running out of memory, exit the process. Backend will try again. | ||
// If we're running out of memory or file descriptors, force exit the process. | ||
// The backend will try again via @retry(ProcessExitedException). | ||
checkMemory(event); | ||
@@ -202,0 +203,0 @@ |
@@ -11,13 +11,22 @@ 'use strict'; | ||
let memUsage; | ||
try { | ||
memUsage = process.memoryUsage(); | ||
} catch (err) { | ||
if (err.code === 'EMFILE') { | ||
console.error( | ||
'Force killing process by Zapier for too many open file descriptors' | ||
); | ||
/* eslint no-process-exit: 0 */ | ||
process.exit(1); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
zrun += 1; | ||
if (!constants.IS_TESTING && !event.calledFromCli) { | ||
console.log( | ||
'ZID:', | ||
zid, | ||
'pid', | ||
'ZRUN:', | ||
zrun, | ||
'RSSMEM:', | ||
process.memoryUsage() | ||
); | ||
console.log('ZID:', zid, 'pid', 'ZRUN:', zrun, 'RSSMEM:', memUsage); | ||
} | ||
@@ -27,3 +36,3 @@ | ||
zrun > constants.KILL_MIN_LIMIT && | ||
process.memoryUsage().rss > constants.KILL_MAX_LIMIT | ||
memUsage.rss > constants.KILL_MAX_LIMIT | ||
) { | ||
@@ -30,0 +39,0 @@ // should throw "Process exited before completing request" |
@@ -21,3 +21,3 @@ import type { | ||
import { expectType } from 'tsd'; | ||
import { expectType, expectDeprecated } from 'tsd'; | ||
@@ -170,1 +170,35 @@ const basicDisplay: BasicDisplay = { | ||
expectType<App>(app); | ||
// Return types from z.request | ||
async (z: ZObject) => { | ||
const resp = await z.request<{ id: number; name: string }>( | ||
'https://example.com' | ||
); | ||
expectType<{ id: number; name: string }>(resp.data); | ||
expectDeprecated(resp.json); | ||
}; | ||
async (z: ZObject) => { | ||
const resp = await z.request<{ id: number; name: string }>({ | ||
url: 'https://example.com', | ||
}); | ||
expectType<{ id: number; name: string }>(resp.data); | ||
}; | ||
// Return types from z.request (raw) | ||
async (z: ZObject) => { | ||
const resp = await z.request<{ id: number; name: string }>( | ||
'https://example.com', | ||
{ raw: true } | ||
); | ||
const result = await resp.json(); | ||
expectType<{ id: number; name: string }>(result); | ||
}; | ||
async (z: ZObject) => { | ||
const resp = await z.request<{ id: number; name: string }>({ | ||
raw: true, | ||
url: 'https://example.com', | ||
}); | ||
const result = await resp.json(); | ||
expectType<{ id: number; name: string }>(result); | ||
}; |
@@ -120,12 +120,13 @@ // Type definitions for zapier-platform-core | ||
export interface HttpResponse extends BaseHttpResponse { | ||
export interface HttpResponse<T = any> extends BaseHttpResponse { | ||
content: string; | ||
data?: any; | ||
json?: any; | ||
data: T; | ||
/** @deprecated Since v10.0.0. Use `data` instead. */ | ||
json?: T; | ||
} | ||
export interface RawHttpResponse extends BaseHttpResponse { | ||
export interface RawHttpResponse<T = any> extends BaseHttpResponse { | ||
body: NodeJS.ReadableStream; | ||
buffer(): Promise<Buffer>; | ||
json(): Promise<object>; | ||
json(): Promise<T>; | ||
text(): Promise<string>; | ||
@@ -142,12 +143,16 @@ } | ||
// most specific overloads go first | ||
( | ||
<T = any>( | ||
url: string, | ||
options: HttpRequestOptions & { raw: true } | ||
): Promise<RawHttpResponse>; | ||
( | ||
): Promise<RawHttpResponse<T>>; | ||
<T = any>( | ||
options: HttpRequestOptions & { raw: true; url: string } | ||
): Promise<RawHttpResponse>; | ||
): Promise<RawHttpResponse<T>>; | ||
(url: string, options?: HttpRequestOptions): Promise<HttpResponse>; | ||
(options: HttpRequestOptions & { url: string }): Promise<HttpResponse>; | ||
<T = any>(url: string, options?: HttpRequestOptions): Promise< | ||
HttpResponse<T> | ||
>; | ||
<T = any>(options: HttpRequestOptions & { url: string }): Promise< | ||
HttpResponse<T> | ||
>; | ||
}; | ||
@@ -231,4 +236,4 @@ | ||
request: HttpRequestOptions, | ||
z?: ZObject, | ||
bundle?: Bundle | ||
z: ZObject, | ||
bundle: Bundle | ||
) => HttpRequestOptions | Promise<HttpRequestOptions>; | ||
@@ -239,3 +244,3 @@ | ||
z: ZObject, | ||
bundle?: Bundle | ||
bundle: Bundle | ||
) => HttpResponse | Promise<HttpResponse>; | ||
@@ -242,0 +247,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235965
6773
28
+ Addedzapier-platform-schema@15.18.0(transitive)
- Removedzapier-platform-schema@15.17.0(transitive)