@constructor-io/constructorio-node 4.14.3 → 4.14.5-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-node",
3
- "version": "4.14.3",
3
+ "version": "4.14.5-beta.0",
4
4
  "description": "Constructor.io Node.js client",
5
5
  "main": "src/constructorio.js",
6
6
  "types": "src/types/constructorio.d.ts",
@@ -1,18 +1,26 @@
1
+ /* eslint-disable global-require */
1
2
  /* eslint-disable camelcase, no-unneeded-ternary, max-len */
2
- const nodeFetch = require('./nodeFetch');
3
3
 
4
4
  // Modules
5
5
  const Search = require('./modules/search');
6
6
  const Browse = require('./modules/browse');
7
7
  const Autocomplete = require('./modules/autocomplete');
8
8
  const Recommendations = require('./modules/recommendations');
9
- const Tracker = require('./modules/tracker');
10
- const Catalog = require('./modules/catalog');
11
9
  const Tasks = require('./modules/tasks');
12
10
  const Quizzes = require('./modules/quizzes');
13
11
  const { version: packageVersion } = require('../package.json');
14
12
  const utils = require('./utils/helpers');
15
13
 
14
+ let nodeFetch;
15
+ let Catalog;
16
+ let Tracker;
17
+
18
+ if (typeof process !== 'undefined' && process.env && process.env.NEXT_RUNTIME !== 'edge') {
19
+ nodeFetch = require('./nodeFetch');
20
+ Catalog = require('./modules/catalog');
21
+ Tracker = require('./modules/tracker');
22
+ }
23
+
16
24
  /**
17
25
  * Class to instantiate the ConstructorIO client.
18
26
  */
@@ -59,17 +67,20 @@ class ConstructorIO {
59
67
  securityToken: securityToken || '',
60
68
  version: version || global.CLIENT_VERSION || `cio-node-${packageVersion}`,
61
69
  serviceUrl: utils.addHTTPSToString(normalizedServiceUrl) || 'https://ac.cnstrc.com',
62
- fetch: fetch || nodeFetch,
70
+ fetch: fetch || nodeFetch || global.fetch,
63
71
  networkParameters: networkParameters || {},
64
72
  };
65
73
 
74
+ if (typeof process !== 'undefined' && process.env && process.env.NEXT_RUNTIME !== 'edge') {
75
+ this.tracker = new Tracker(this.options);
76
+ this.catalog = new Catalog(this.options);
77
+ }
78
+
66
79
  // Expose global modules
67
80
  this.search = new Search(this.options);
68
81
  this.browse = new Browse(this.options);
69
82
  this.autocomplete = new Autocomplete(this.options);
70
83
  this.recommendations = new Recommendations(this.options);
71
- this.tracker = new Tracker(this.options);
72
- this.catalog = new Catalog(this.options);
73
84
  this.tasks = new Tasks(this.options);
74
85
  this.quizzes = new Quizzes(this.options);
75
86
  }
@@ -1,3 +1,6 @@
1
+ import type fs from 'fs';
2
+ import type { Duplex } from 'stream';
3
+
1
4
  import {
2
5
  ConstructorClientOptions,
3
6
  Item,
@@ -167,9 +170,9 @@ export interface ReplaceCatalogParameters {
167
170
  section: string;
168
171
  notificationEmail?: string;
169
172
  force?: boolean;
170
- items?: File;
171
- variations?: File;
172
- itemGroups?: File;
173
+ items?: File | fs.ReadStream | Duplex
174
+ variations?: File | fs.ReadStream | Duplex;
175
+ itemGroups?: File | fs.ReadStream | Duplex;
173
176
  }
174
177
 
175
178
  export interface UpdateCatalogParameters extends ReplaceCatalogParameters {}
@@ -179,16 +182,16 @@ export interface PatchCatalogParameters {
179
182
  notificationEmail?: string;
180
183
  force?: boolean;
181
184
  onMissing?: 'IGNORE' | 'CREATE' | 'FAIL';
182
- items?: File;
183
- variations?: File;
184
- itemGroups?: File;
185
+ items?: File | fs.ReadStream | Duplex
186
+ variations?: File | fs.ReadStream | Duplex;
187
+ itemGroups?: File | fs.ReadStream | Duplex;
185
188
  }
186
189
 
187
190
  export interface ReplaceCatalogUsingTarArchiveParameters {
188
191
  section: string;
189
192
  notificationEmail?: string;
190
193
  force?: boolean;
191
- tarArchive?: File;
194
+ tarArchive?: File | fs.ReadStream | Duplex;
192
195
  }
193
196
 
194
197
  export interface UpdateCatalogUsingTarArchiveParameters