zapier-platform-cli 15.16.0 → 15.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,6 @@
1
- import { Bundle, ZObject } from 'zapier-platform-core';
1
+ import { Create, PerformFunction } from 'zapier-platform-core';
2
2
 
3
- // You can optionally add add the shape of the inputData in bundle, which will pass that
4
- // info down into the function and tests
5
- const perform = async (
6
- z: ZObject,
7
- bundle: Bundle<{ title: string; year: number }>
8
- ) => {
3
+ const perform: PerformFunction = async (z, bundle) => {
9
4
  const response = await z.request({
10
5
  method: 'POST',
11
6
  url: 'https://auth-json-server.zapier-staging.com/movies',
@@ -37,4 +32,4 @@ export default {
37
32
  title: 'example',
38
33
  },
39
34
  },
40
- };
35
+ } satisfies Create;
@@ -1,16 +1,12 @@
1
- import { Bundle, HttpRequestOptions, ZObject } from 'zapier-platform-core';
1
+ import type { App, BeforeRequestMiddleware } from 'zapier-platform-core';
2
2
 
3
3
  import MovieCreate from './creates/movie';
4
4
  import MovieTrigger from './triggers/movie';
5
5
  import { version as platformVersion } from 'zapier-platform-core';
6
6
 
7
- const { version } = require('../package.json');
7
+ import packageJson from '../package.json';
8
8
 
9
- const addApiKeyHeader = (
10
- req: HttpRequestOptions,
11
- z: ZObject,
12
- bundle: Bundle
13
- ) => {
9
+ const addApiKeyHeader: BeforeRequestMiddleware = (req, z, bundle) => {
14
10
  // Hard-coded api key just to demo. DON'T do auth like this for your production app!
15
11
  req.headers = req.headers || {};
16
12
  req.headers['X-Api-Key'] = 'secret';
@@ -18,7 +14,7 @@ const addApiKeyHeader = (
18
14
  };
19
15
 
20
16
  export default {
21
- version,
17
+ version: packageJson.version,
22
18
  platformVersion,
23
19
 
24
20
  beforeRequest: [addApiKeyHeader],
@@ -30,4 +26,4 @@ export default {
30
26
  creates: {
31
27
  [MovieCreate.key]: MovieCreate,
32
28
  },
33
- };
29
+ } satisfies App;
@@ -1,6 +1,5 @@
1
- /* globals describe, expect, test */
2
-
3
1
  import { createAppTester, tools } from 'zapier-platform-core';
2
+ import { describe, test, expect } from 'vitest';
4
3
 
5
4
  import App from '../index';
6
5
 
@@ -1,6 +1,5 @@
1
- /* globals describe, expect, test */
2
-
3
- import { Bundle, createAppTester, tools } from 'zapier-platform-core';
1
+ import { createAppTester, tools } from 'zapier-platform-core';
2
+ import { describe, test, expect } from 'vitest';
4
3
 
5
4
  import App from '../index';
6
5
 
@@ -1,6 +1,6 @@
1
- import { Bundle, ZObject } from 'zapier-platform-core';
1
+ import { PerformFunction, Trigger } from 'zapier-platform-core';
2
2
 
3
- const perform = async (z: ZObject, bundle: Bundle) => {
3
+ const perform: PerformFunction = async (z, bundle) => {
4
4
  const response = await z.request(
5
5
  'https://auth-json-server.zapier-staging.com/movies'
6
6
  );
@@ -17,10 +17,11 @@ export default {
17
17
  },
18
18
 
19
19
  operation: {
20
+ type: 'polling',
20
21
  perform,
21
22
  sample: {
22
23
  id: '1',
23
24
  title: 'example',
24
25
  },
25
26
  },
26
- };
27
+ } satisfies Trigger;
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es2019",
4
- "module": "commonjs",
5
- "moduleResolution": "node",
6
- "lib": ["esnext"],
7
- "outDir": "./lib",
3
+ "target": "ESNext",
4
+ "module": "CommonJS",
5
+ "moduleResolution": "Node",
6
+ "resolveJsonModule": true,
7
+ "esModuleInterop": true,
8
+ "isolatedModules": true,
9
+ "skipLibCheck": true,
10
+ "outDir": "./dist",
8
11
  "rootDir": "./src",
9
12
  "strict": true
10
- }
13
+ },
14
+ "include": ["./src/**/*.ts"],
15
+ "exclude": ["./**/*.test.ts"]
11
16
  }
@@ -15,6 +15,7 @@ const DATA_FORMATS = ['json', 'raw'];
15
15
 
16
16
  class ZapierBaseCommand extends Command {
17
17
  run() {
18
+ this._initPromptModules();
18
19
  this._parseFlags();
19
20
 
20
21
  if (this.flags.debug) {
@@ -59,6 +60,13 @@ class ZapierBaseCommand extends Command {
59
60
  return Object.getPrototypeOf(this).constructor;
60
61
  }
61
62
 
63
+ _initPromptModules() {
64
+ this._stdoutPrompt = inquirer.prompt;
65
+ this._stderrPrompt = inquirer.createPromptModule({
66
+ output: process.stderr,
67
+ });
68
+ }
69
+
62
70
  _parseFlags() {
63
71
  const { flags, args } = this.parse(this._staticClassReference);
64
72
 
@@ -205,7 +213,8 @@ class ZapierBaseCommand extends Command {
205
213
  if (Object.keys(opts).length) {
206
214
  opts.validate = this._getCustomValidatation(opts);
207
215
  }
208
- const { ans } = await inquirer.prompt({
216
+ const prompt = opts.useStderr ? this._stderrPrompt : this._stdoutPrompt;
217
+ const { ans } = await prompt({
209
218
  type: 'string',
210
219
  ...opts,
211
220
  name: 'ans',
@@ -214,18 +223,23 @@ class ZapierBaseCommand extends Command {
214
223
  return ans;
215
224
  }
216
225
 
217
- promptHidden(question) {
226
+ promptHidden(question, useStderr = false) {
218
227
  return this.prompt(question, {
219
228
  type: 'password',
220
229
  mask: true,
230
+ useStderr,
221
231
  });
222
232
  }
223
233
 
224
- confirm(message, defaultAns = false, showCtrlC = false) {
234
+ confirm(message, defaultAns = false, showCtrlC = false, useStderr = false) {
225
235
  if (showCtrlC) {
226
236
  message += ' (Ctrl-C to cancel)';
227
237
  }
228
- return this.prompt(message, { default: defaultAns, type: 'confirm' });
238
+ return this.prompt(message, {
239
+ default: defaultAns,
240
+ type: 'confirm',
241
+ useStderr,
242
+ });
229
243
  }
230
244
 
231
245
  // see here for options for choices: https://github.com/SBoudrias/Inquirer.js/#question
@@ -290,7 +304,7 @@ class ZapierBaseCommand extends Command {
290
304
  )
291
305
  .filter(Boolean);
292
306
 
293
- const descriptionParts = this.description.split('\n').filter(Boolean);
307
+ const descriptionParts = this.description.split('\n\n').filter(Boolean);
294
308
  const blurb = descriptionParts[0];
295
309
  const lengthyDescription = colors.stripColors(
296
310
  descriptionParts.length > 1 ? descriptionParts.slice(1).join('\n\n') : ''