jitsu-cli 1.9.2 → 1.9.3
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/.turbo/turbo-build.log +44 -44
- package/.turbo/turbo-clean.log +5 -5
- package/dist/main.js +2 -1
- package/dist/main.js.map +1 -1
- package/package.json +4 -4
- package/compiled/src/commands/template.js +0 -239
- package/compiled/src/lib/errors.js +0 -18
- package/compiled/src/lib/log.js +0 -36
- package/compiled/src/public.js +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jitsu-cli",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Jitsu Dev Team <dev@jitsu.com>",
|
|
6
6
|
"publishConfig": {
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"typescript": "^5.3.3",
|
|
54
54
|
"webpack": "^5.88.2",
|
|
55
55
|
"webpack-cli": "^5.1.4",
|
|
56
|
-
"@jitsu/protocols": "1.9.
|
|
57
|
-
"@jitsu/functions-lib": "1.9.
|
|
58
|
-
"juava": "1.9.
|
|
56
|
+
"@jitsu/protocols": "1.9.3",
|
|
57
|
+
"@jitsu/functions-lib": "1.9.3",
|
|
58
|
+
"juava": "1.9.3"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"clean": "rm -rf ./dist",
|
|
@@ -1,239 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
package/compiled/src/lib/log.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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;
|
package/compiled/src/public.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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;
|