jitsu-cli 1.9.3 → 1.9.4

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,10 +1,10 @@
1
- jitsu-cli:build: cache hit, replaying output 12b71f43cc5d747f
1
+ jitsu-cli:build: cache hit, replaying output b750bc04f6e3885e
2
2
  jitsu-cli:build: 
3
- jitsu-cli:build: > jitsu-cli@0.0.0 build /Users/vklmn/dev2/newjitsu/cli/jitsu-cli
3
+ jitsu-cli:build: > jitsu-cli@0.0.0 build /Users/ildarnurislamov/Projects/newjitsu/cli/jitsu-cli
4
4
  jitsu-cli:build: > pnpm compile && webpack
5
5
  jitsu-cli:build: 
6
6
  jitsu-cli:build: 
7
- jitsu-cli:build: > jitsu-cli@0.0.0 compile /Users/vklmn/dev2/newjitsu/cli/jitsu-cli
7
+ jitsu-cli:build: > jitsu-cli@0.0.0 compile /Users/ildarnurislamov/Projects/newjitsu/cli/jitsu-cli
8
8
  jitsu-cli:build: > tsc -p .
9
9
  jitsu-cli:build: 
10
10
  jitsu-cli:build: asset main.js 12.4 MiB [emitted] (name: main) 1 related asset
@@ -41,4 +41,4 @@ jitsu-cli:build: cache hit, replaying output 12b71f43cc5d747f
41
41
  jitsu-cli:build: 2 warnings have detailed information that is not shown.
42
42
  jitsu-cli:build: Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
43
43
  jitsu-cli:build: 
44
- jitsu-cli:build: webpack 5.88.2 compiled with 2 warnings in 5084 ms
44
+ jitsu-cli:build: webpack 5.88.2 compiled with 2 warnings in 6330 ms
@@ -1,5 +1,5 @@
1
- jitsu-cli:clean: cache hit, replaying output 9b00fa1b0bf2986e
1
+ jitsu-cli:clean: cache hit, replaying output 51795610ff16e83e
2
2
  jitsu-cli:clean: 
3
- jitsu-cli:clean: > jitsu-cli@0.0.0 clean /Users/vklmn/dev2/newjitsu/cli/jitsu-cli
3
+ jitsu-cli:clean: > jitsu-cli@0.0.0 clean /Users/ildarnurislamov/Projects/newjitsu/cli/jitsu-cli
4
4
  jitsu-cli:clean: > rm -rf ./dist
5
5
  jitsu-cli:clean: 
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extensionProjectTemplate = exports.packageJsonTemplate = void 0;
4
+ const version_1 = require("../lib/version");
5
+ const index_1 = require("../index");
6
+ const packageJsonTemplate = ({ packageName, type, jitsuVersion = undefined }) => {
7
+ const res = {
8
+ name: `${packageName}`,
9
+ version: "0.0.1",
10
+ description: `Jitsu ${type} - ${packageName}`,
11
+ keywords: ["jitsu", "extension", `jitsu-${type}-extension`],
12
+ main: `dist/${packageName}.js`,
13
+ scripts: {
14
+ clean: "rm -rf ./dist",
15
+ build: `${index_1.binName} extension build`,
16
+ test: `${index_1.binName} extension test`,
17
+ execute: `${index_1.binName} extension exec`,
18
+ },
19
+ devDependencies: {
20
+ "@jitsu/types": `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
21
+ "@jitsu/jlib": `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
22
+ "ts-jest": "^27.0.7",
23
+ [index_1.binName]: `${jitsuVersion || "^" + version_1.jitsuCliVersion}`,
24
+ tslib: "^2.3.1",
25
+ typescript: "^4.5.2",
26
+ },
27
+ dependencies: {},
28
+ };
29
+ if (type === "destination" || type === "source") {
30
+ res.scripts["validate-config"] = `${index_1.binName} extension validate-config`;
31
+ }
32
+ return res;
33
+ };
34
+ exports.packageJsonTemplate = packageJsonTemplate;
35
+ let destinationTest = ({ type = "destination" }) => {
36
+ if (type !== "destination") {
37
+ return undefined;
38
+ }
39
+ return `
40
+ import { JitsuDestinationContext } from "@jitsu/types/extension"
41
+ import { testDestination } from "${index_1.binName}/lib/tests"
42
+ import { destination } from "../src"
43
+
44
+ testDestination({
45
+ name: "basic",
46
+ context: {
47
+ destinationId: "test",
48
+ destinationType: "mydest",
49
+ config: {}
50
+ },
51
+ destination: destination,
52
+ event: {
53
+ event_type: 'test',
54
+ a: 1
55
+ },
56
+ expectedResult: {
57
+ method: "POST",
58
+ url: "https://test.com",
59
+ body: { a: 2 },
60
+ },
61
+ })
62
+ `;
63
+ };
64
+ let destinationCode = () => {
65
+ return `
66
+ import { DestinationFunction, DestinationMessage, JitsuDestinationContext, ConfigValidator} from "@jitsu/types/extension";
67
+ import { DefaultJitsuEvent } from "@jitsu/types/event";
68
+
69
+ export type DestinationConfig = {
70
+ exampleParam: string
71
+ }
72
+
73
+ export const validator: ConfigValidator<DestinationConfig> = async (config: DestinationConfig) => {
74
+ if (config.exampleParam !== 'valid-config') {
75
+ return \`Invalid config: exampleParam expected to be 'valid-config', but actual value is: \${config.exampleParam}\`;
76
+ }
77
+ return true;
78
+ }
79
+
80
+ export const destination: DestinationFunction = (event: DefaultJitsuEvent, dstContext: JitsuDestinationContext<DestinationConfig>) => {
81
+ return { url: "https://test.com", method: "POST", body: { a: (event.a || 0) + 1 } };
82
+ };
83
+ `;
84
+ };
85
+ let sourceCode = () => {
86
+ return `
87
+ import { SourceCatalog, StateService, StreamReader, StreamSink, StreamConfiguration } from "@jitsu/types/sources";
88
+ import { ConfigValidationResult, ExtensionDescriptor } from "@jitsu/types/extension";
89
+
90
+ export interface SourceConfig {
91
+ user_id: string
92
+ my_source_param: string;
93
+ }
94
+
95
+ export interface StreamConfig {
96
+ my_stream_param: string;
97
+ }
98
+
99
+ async function validator(config: SourceConfig): Promise<ConfigValidationResult> {
100
+ //TODO: Check that provided config data allows to connect to third party API
101
+ console.log("validator is not yet implemented");
102
+ return true;
103
+ }
104
+
105
+ const descriptor: ExtensionDescriptor<SourceConfig> = {
106
+ id: "my_source",
107
+ displayName: "Source Example",
108
+ description:
109
+ "Example source that produces row with run number and source/stream configuration.",
110
+ configurationParameters: [
111
+ {
112
+ displayName: "User ID",
113
+ id: "user_id",
114
+ type: "string",
115
+ required: true,
116
+ documentation: "User Id",
117
+ },
118
+ {
119
+ displayName: "Example Parameter",
120
+ id: "my_source_param",
121
+ required: true,
122
+ type: "string",
123
+ documentation: \`
124
+ <div>
125
+ Example Parameter
126
+ </div>
127
+ \`,
128
+ }
129
+ ],
130
+ };
131
+
132
+ const sourceCatalog: SourceCatalog<SourceConfig, StreamConfig> = async config => {
133
+ return [
134
+ {
135
+ type: "my_source_runs",
136
+ supportedModes: ["incremental"],
137
+ params: [
138
+ {
139
+ id: "my_stream_param",
140
+ displayName: "Stream Parameter",
141
+ type: "string",
142
+ documentation: \`
143
+ <div>
144
+ Stream Parameter example.
145
+ </div>
146
+ \`,
147
+ required: true,
148
+ },
149
+ ]
150
+ }
151
+ ];
152
+ };
153
+
154
+ const streamReader: StreamReader<SourceConfig, StreamConfig> = async (
155
+ sourceConfig: SourceConfig,
156
+ streamType: string,
157
+ streamConfiguration: StreamConfiguration<StreamConfig>,
158
+ streamSink: StreamSink,
159
+ services: { state: StateService }
160
+ ) => {
161
+ //Example of saved state usage. Read previous run number:
162
+ let runNumber = services.state.get("run_number") || 0;
163
+ runNumber++
164
+ streamSink.log("INFO", "Run number: " + runNumber);
165
+ streamSink.addRecord({
166
+ $id: runNumber,
167
+ $recordTimestamp: new Date(),
168
+ type: streamType,
169
+ ...sourceConfig,
170
+ ...streamConfiguration.parameters
171
+ });
172
+ //Save last run number to state
173
+ services.state.set("run_number", runNumber);
174
+ };
175
+
176
+ export { streamReader, sourceCatalog, descriptor, validator };
177
+ `;
178
+ };
179
+ let transformCode = () => {
180
+ return `
181
+ import {TransformationFunction} from "@jitsu/types/extension";
182
+ import {DefaultJitsuEvent} from "@jitsu/types/event";
183
+
184
+ //duplicate events
185
+ const transform: TransformationFunction = (event: DefaultJitsuEvent) => {
186
+ return [event, {...event, eventn_ctx_event_id: event.eventn_ctx_event_id + "_2"}]
187
+ }
188
+
189
+ export default transform;
190
+ `;
191
+ };
192
+ let descriptor = {};
193
+ descriptor["destination"] = (vars) => `
194
+ import {ExtensionDescriptor} from "@jitsu/types/extension";
195
+ import {destination, validator, DestinationConfig} from "./destination";
196
+
197
+ const descriptor: ExtensionDescriptor = {
198
+ id: "${vars.packageName}",
199
+ displayName: "${vars.packageName}",
200
+ icon: "",
201
+ description: "Jitsu destination - ${vars.packageName} (generated by \`${index_1.binName} extension create\`)",
202
+ configurationParameters: [
203
+ {id: "exampleParam", type: "string", required: true, displayName: "Example param", documentation: "Documentation"}
204
+ ],
205
+ };
206
+
207
+ export { descriptor, destination, validator };
208
+ `;
209
+ descriptor["transform"] = (vars) => `
210
+ import {ExtensionDescriptor} from "@jitsu/types/extension";
211
+ import transform from "./transform";
212
+
213
+ const descriptor: ExtensionDescriptor = {
214
+ id: "${vars.packageName}",
215
+ displayName: "${vars.packageName}",
216
+ icon: "",
217
+ description: "Jitsu ${vars.type} - ${vars.packageName} (generated by \`${index_1.binName} extension create)\`"
218
+ }
219
+
220
+ export {descriptor, transform}
221
+ `;
222
+ exports.extensionProjectTemplate = {
223
+ "__test__/destination.test.ts": destinationTest,
224
+ "src/destination.ts": vars => vars.type == "destination" && destinationCode(),
225
+ "src/transform.ts": vars => vars.type == "transform" && transformCode(),
226
+ "src/index.ts": vars => (vars.type == "source" ? sourceCode() : descriptor[vars.type](vars)),
227
+ "package.json": exports.packageJsonTemplate,
228
+ "tsconfig.json": {
229
+ compilerOptions: {
230
+ module: "ES2020",
231
+ target: "ES2021",
232
+ moduleResolution: "Node",
233
+ esModuleInterop: true,
234
+ outDir: "./dist",
235
+ rootDir: "./",
236
+ },
237
+ include: ["./src", "__test__"],
238
+ },
239
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appendError = void 0;
4
+ function appendError(msg, cause) {
5
+ if (cause && cause.message) {
6
+ return `${msg}: ${cause.message}`;
7
+ }
8
+ else if (cause && typeof cause === "string") {
9
+ return `${msg}: ${cause}`;
10
+ }
11
+ else if (cause) {
12
+ return `${msg}: ${cause.toString()}`;
13
+ }
14
+ else {
15
+ return msg;
16
+ }
17
+ }
18
+ exports.appendError = appendError;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ function log0(delegate, styling, msg, args) {
6
+ if (!msg) {
7
+ delegate("");
8
+ return;
9
+ }
10
+ let consoleMsg = chalk_1.default[styling.color](`[${styling.prefix}]`) + " - " + msg;
11
+ if (args.length > 0) {
12
+ delegate(consoleMsg, args);
13
+ }
14
+ else {
15
+ delegate(consoleMsg);
16
+ }
17
+ }
18
+ function getLog() {
19
+ return {
20
+ error(msg, ...args) {
21
+ log0(console.error, { prefix: "error", color: "red" }, msg, args);
22
+ },
23
+ warn(msg, ...args) {
24
+ log0(console.warn, { prefix: "warn ", color: "yellow" }, msg, args);
25
+ },
26
+ spinInfo(args) { },
27
+ info(msg, ...args) {
28
+ log0(console.info, { prefix: "info ", color: "cyan" }, msg, args);
29
+ },
30
+ debug(msg, ...args) {
31
+ log0(console.debug, { prefix: "debug", color: "gray" }, msg, args);
32
+ },
33
+ };
34
+ }
35
+ const log = getLog();
36
+ exports.default = log;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RetryError = void 0;
4
+ const core_functions_1 = require("@jitsu/core-functions");
5
+ class RetryError extends Error {
6
+ constructor(message, options) {
7
+ super(message);
8
+ this.name = options?.drop ? `${core_functions_1.DropRetryErrorName}` : `${core_functions_1.RetryErrorName}`;
9
+ }
10
+ }
11
+ exports.RetryError = RetryError;
package/dist/main.js CHANGED
@@ -726,21 +726,23 @@ function getLog(_opts) {
726
726
  var level = opts.level,
727
727
  _opts$component = opts.component,
728
728
  component = _opts$component === void 0 ? getComponent() : _opts$component;
729
+ var minSeverity = levelSeverities[level || globalLogLevel || "info"];
729
730
  return {
730
731
  atDebug: function atDebug() {
731
- var minSeverity = levelSeverities[level || globalLogLevel || "info"];
732
732
  return minSeverity <= levelSeverities.debug ? logMessageBuilder(component, "debug") : noopLogMessageBuilder;
733
733
  },
734
+ inDebug: function inDebug(cb) {
735
+ if (minSeverity <= levelSeverities.debug) {
736
+ cb(logMessageBuilder(component, "debug"));
737
+ }
738
+ },
734
739
  atError: function atError() {
735
- var minSeverity = levelSeverities[level || globalLogLevel || "info"];
736
740
  return minSeverity <= levelSeverities.error ? logMessageBuilder(component, "error") : noopLogMessageBuilder;
737
741
  },
738
742
  atInfo: function atInfo() {
739
- var minSeverity = levelSeverities[level || globalLogLevel || "info"];
740
743
  return minSeverity <= levelSeverities.info ? logMessageBuilder(component, "info") : noopLogMessageBuilder;
741
744
  },
742
745
  atWarn: function atWarn() {
743
- var minSeverity = levelSeverities[level || globalLogLevel || "info"];
744
746
  return minSeverity <= levelSeverities.warn ? logMessageBuilder(component, "warn") : noopLogMessageBuilder;
745
747
  },
746
748
  at: function at(level) {
@@ -1215,7 +1217,6 @@ function getSingleton(globalName, factory) {
1215
1217
  };
1216
1218
  return result;
1217
1219
  } else if (cachedValue && !cachedValue.success) {
1218
- cachedValue.debounceCleanup();
1219
1220
  throw newError("".concat(globalName, " failed during initialization: ").concat(getErrorMessage(cachedValue.error)), cachedValue.error);
1220
1221
  }
1221
1222
  log.atDebug().log("Creating ".concat(globalName, " connection..."));