@use-tusk/drift-node-sdk 0.1.35 → 0.1.36

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/dist/index.d.cts CHANGED
@@ -1,85 +1,3 @@
1
- import { NextConfig } from "next";
2
-
3
- //#region src/nextjs/types.d.ts
4
-
5
- /**
6
- * Options for configuring Tusk Drift's Next.js integration.
7
- */
8
- interface TuskDriftNextOptions {
9
- /**
10
- * Enable debug logging for Tusk Drift's Next.js integration.
11
- * When enabled, logs information about configuration changes and version detection.
12
- *
13
- * @default false
14
- */
15
- debug?: boolean;
16
- /**
17
- * Disable automatic setting of `experimental.instrumentationHook`.
18
- * Use this if you want to manually control the instrumentation hook setting.
19
- *
20
- * @default false
21
- */
22
- disableInstrumentationHook?: boolean;
23
- /**
24
- * Suppress all warnings from Tusk Drift's Next.js integration.
25
- * Not recommended unless you know what you're doing.
26
- *
27
- * @default false
28
- */
29
- suppressWarnings?: boolean;
30
- }
31
- //#endregion
32
- //#region src/nextjs/withTuskDrift.d.ts
33
- /**
34
- * Wraps your Next.js configuration with Tusk Drift instrumentation setup.
35
- *
36
- * This function automatically configures Next.js to work with Tusk Drift by:
37
- * - Enabling the Next.js instrumentation hook (for Next.js < 15.0.0-rc.1)
38
- * - Configuring server external packages to prevent bundling of core instrumentation packages
39
- * - Supporting both webpack and Turbopack bundlers
40
- * - Preserving your existing Next.js configuration and webpack customizations
41
- *
42
- * @param nextConfig - Your existing Next.js configuration object (optional)
43
- * @param options - Additional options to configure Tusk Drift's behavior (optional)
44
- * @returns The wrapped Next.js configuration with Tusk Drift instrumentation enabled
45
- *
46
- * @example
47
- * Basic usage:
48
- * ```javascript
49
- * // next.config.js
50
- * const { withTuskDrift } = require('@use-tusk/drift-node-sdk');
51
- *
52
- * module.exports = withTuskDrift({
53
- * // Your Next.js config
54
- * });
55
- * ```
56
- *
57
- * @example
58
- * With debug logging:
59
- * ```javascript
60
- * // next.config.js
61
- * const { withTuskDrift } = require('@use-tusk/drift-node-sdk');
62
- *
63
- * module.exports = withTuskDrift(
64
- * {
65
- * // Your Next.js config
66
- * },
67
- * {
68
- * debug: true,
69
- * }
70
- * );
71
- * ```
72
- *
73
- * @remarks
74
- * The following packages are added as server externals for both webpack and Turbopack:
75
- * - `require-in-the-middle` - Required for CommonJS module interception
76
- * - `jsonpath` - Required for schema manipulation
77
- * - Additional packages when TUSK_DRIFT_MODE is RECORD or REPLAY (e.g., database clients, etc.)
78
- *
79
- * Works with both webpack (default) and Turbopack (`next dev --turbo`).
80
- */
81
- declare function withTuskDrift(nextConfig?: NextConfig, options?: TuskDriftNextOptions): NextConfig;
82
- //#endregion
83
1
  //#region src/core/types.d.ts
84
2
 
85
3
  type OneOf<T extends object> = { [K in keyof T]: Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, null>> }[keyof T];
@@ -251,5 +169,5 @@ interface TuskDriftPublicAPI {
251
169
  }
252
170
  declare const TuskDrift: TuskDriftPublicAPI;
253
171
  //#endregion
254
- export { TuskDrift, type TuskDriftNextOptions, withTuskDrift };
172
+ export { TuskDrift };
255
173
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,85 +1,3 @@
1
- import { NextConfig } from "next";
2
-
3
- //#region src/nextjs/types.d.ts
4
-
5
- /**
6
- * Options for configuring Tusk Drift's Next.js integration.
7
- */
8
- interface TuskDriftNextOptions {
9
- /**
10
- * Enable debug logging for Tusk Drift's Next.js integration.
11
- * When enabled, logs information about configuration changes and version detection.
12
- *
13
- * @default false
14
- */
15
- debug?: boolean;
16
- /**
17
- * Disable automatic setting of `experimental.instrumentationHook`.
18
- * Use this if you want to manually control the instrumentation hook setting.
19
- *
20
- * @default false
21
- */
22
- disableInstrumentationHook?: boolean;
23
- /**
24
- * Suppress all warnings from Tusk Drift's Next.js integration.
25
- * Not recommended unless you know what you're doing.
26
- *
27
- * @default false
28
- */
29
- suppressWarnings?: boolean;
30
- }
31
- //#endregion
32
- //#region src/nextjs/withTuskDrift.d.ts
33
- /**
34
- * Wraps your Next.js configuration with Tusk Drift instrumentation setup.
35
- *
36
- * This function automatically configures Next.js to work with Tusk Drift by:
37
- * - Enabling the Next.js instrumentation hook (for Next.js < 15.0.0-rc.1)
38
- * - Configuring server external packages to prevent bundling of core instrumentation packages
39
- * - Supporting both webpack and Turbopack bundlers
40
- * - Preserving your existing Next.js configuration and webpack customizations
41
- *
42
- * @param nextConfig - Your existing Next.js configuration object (optional)
43
- * @param options - Additional options to configure Tusk Drift's behavior (optional)
44
- * @returns The wrapped Next.js configuration with Tusk Drift instrumentation enabled
45
- *
46
- * @example
47
- * Basic usage:
48
- * ```javascript
49
- * // next.config.js
50
- * const { withTuskDrift } = require('@use-tusk/drift-node-sdk');
51
- *
52
- * module.exports = withTuskDrift({
53
- * // Your Next.js config
54
- * });
55
- * ```
56
- *
57
- * @example
58
- * With debug logging:
59
- * ```javascript
60
- * // next.config.js
61
- * const { withTuskDrift } = require('@use-tusk/drift-node-sdk');
62
- *
63
- * module.exports = withTuskDrift(
64
- * {
65
- * // Your Next.js config
66
- * },
67
- * {
68
- * debug: true,
69
- * }
70
- * );
71
- * ```
72
- *
73
- * @remarks
74
- * The following packages are added as server externals for both webpack and Turbopack:
75
- * - `require-in-the-middle` - Required for CommonJS module interception
76
- * - `jsonpath` - Required for schema manipulation
77
- * - Additional packages when TUSK_DRIFT_MODE is RECORD or REPLAY (e.g., database clients, etc.)
78
- *
79
- * Works with both webpack (default) and Turbopack (`next dev --turbo`).
80
- */
81
- declare function withTuskDrift(nextConfig?: NextConfig, options?: TuskDriftNextOptions): NextConfig;
82
- //#endregion
83
1
  //#region src/core/types.d.ts
84
2
 
85
3
  type OneOf<T extends object> = { [K in keyof T]: Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, null>> }[keyof T];
@@ -251,5 +169,5 @@ interface TuskDriftPublicAPI {
251
169
  }
252
170
  declare const TuskDrift: TuskDriftPublicAPI;
253
171
  //#endregion
254
- export { TuskDrift, type TuskDriftNextOptions, withTuskDrift };
172
+ export { TuskDrift };
255
173
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from "node:module";
2
2
  import * as fs$1 from "fs";
3
3
  import fs from "fs";
4
+ import os from "os";
4
5
  import * as path$1 from "path";
5
6
  import path, { normalize } from "path";
6
- import { parse, satisfies } from "semver";
7
- import os from "os";
7
+ import { satisfies } from "semver";
8
8
  import { Hook } from "require-in-the-middle";
9
9
  import { Hook as Hook$1 } from "import-in-the-middle";
10
10
  import yaml from "js-yaml";
@@ -55,207 +55,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
55
55
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
56
56
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
57
57
 
58
- //#endregion
59
- //#region src/nextjs/utils.ts
60
- /**
61
- * Get the installed Next.js version by reading package.json from node_modules.
62
- *
63
- * @returns The Next.js version string, or undefined if not found
64
- */
65
- function getNextjsVersion() {
66
- try {
67
- const nextPackageJsonPath = path$1.join(process.cwd(), "node_modules", "next", "package.json");
68
- if (fs$1.existsSync(nextPackageJsonPath)) return JSON.parse(fs$1.readFileSync(nextPackageJsonPath, "utf-8")).version;
69
- } catch (error) {}
70
- }
71
- /**
72
- * Parse a semantic version string into its components.
73
- *
74
- * @param version - The version string to parse (e.g., "15.0.0-canary.124")
75
- * @returns Parsed version object with major, minor, patch, and prerelease
76
- */
77
- function parseVersion(version$1) {
78
- try {
79
- const parsed = parse(version$1);
80
- if (!parsed) return {
81
- major: void 0,
82
- minor: void 0,
83
- patch: void 0,
84
- prerelease: void 0
85
- };
86
- return {
87
- major: parsed.major,
88
- minor: parsed.minor,
89
- patch: parsed.patch,
90
- prerelease: parsed.prerelease.length > 0 ? parsed.prerelease.join(".") : void 0
91
- };
92
- } catch {
93
- return {
94
- major: void 0,
95
- minor: void 0,
96
- patch: void 0,
97
- prerelease: void 0
98
- };
99
- }
100
- }
101
- /**
102
- * Check if the Next.js version requires the instrumentationHook to be set.
103
- * From Next.js 15.0.0-rc.1 onwards, the instrumentationHook is no longer needed
104
- * and Next.js will warn if it's set.
105
- *
106
- * @param version - The Next.js version string
107
- * @returns true if instrumentationHook should be set, false otherwise
108
- */
109
- function shouldSetInstrumentationHook(version$1) {
110
- if (!version$1) return true;
111
- const { major: major$1, minor, patch, prerelease } = parseVersion(version$1);
112
- if (major$1 === void 0 || minor === void 0 || patch === void 0) return true;
113
- if (major$1 >= 16) return false;
114
- if (major$1 < 15) return true;
115
- if (major$1 === 15) {
116
- if (minor > 0 || patch > 0) return false;
117
- if (minor === 0 && patch === 0 && prerelease === void 0) return false;
118
- if (prerelease?.startsWith("rc.")) {
119
- if (parseInt(prerelease.split(".")[1] || "0", 10) >= 1) return false;
120
- }
121
- if (prerelease?.startsWith("canary.")) {
122
- if (parseInt(prerelease.split(".")[1] || "0", 10) >= 124) return false;
123
- }
124
- return true;
125
- }
126
- return true;
127
- }
128
- /**
129
- * Log a message if debug mode is enabled.
130
- *
131
- * @param debug - Whether debug mode is enabled
132
- * @param message - The message to log
133
- */
134
- function debugLog(debug, message) {
135
- if (debug) console.log(`[Tusk Drift] ${message}`);
136
- }
137
- /**
138
- * Log a warning message if warnings are not suppressed.
139
- *
140
- * @param suppress - Whether to suppress the warning
141
- * @param message - The warning message to log
142
- */
143
- function warn(suppress, message) {
144
- if (!suppress) console.warn(`[Tusk Drift] ${message}`);
145
- }
146
-
147
- //#endregion
148
- //#region src/nextjs/withTuskDrift.ts
149
- /**
150
- * Wraps your Next.js configuration with Tusk Drift instrumentation setup.
151
- *
152
- * This function automatically configures Next.js to work with Tusk Drift by:
153
- * - Enabling the Next.js instrumentation hook (for Next.js < 15.0.0-rc.1)
154
- * - Configuring server external packages to prevent bundling of core instrumentation packages
155
- * - Supporting both webpack and Turbopack bundlers
156
- * - Preserving your existing Next.js configuration and webpack customizations
157
- *
158
- * @param nextConfig - Your existing Next.js configuration object (optional)
159
- * @param options - Additional options to configure Tusk Drift's behavior (optional)
160
- * @returns The wrapped Next.js configuration with Tusk Drift instrumentation enabled
161
- *
162
- * @example
163
- * Basic usage:
164
- * ```javascript
165
- * // next.config.js
166
- * const { withTuskDrift } = require('@use-tusk/drift-node-sdk');
167
- *
168
- * module.exports = withTuskDrift({
169
- * // Your Next.js config
170
- * });
171
- * ```
172
- *
173
- * @example
174
- * With debug logging:
175
- * ```javascript
176
- * // next.config.js
177
- * const { withTuskDrift } = require('@use-tusk/drift-node-sdk');
178
- *
179
- * module.exports = withTuskDrift(
180
- * {
181
- * // Your Next.js config
182
- * },
183
- * {
184
- * debug: true,
185
- * }
186
- * );
187
- * ```
188
- *
189
- * @remarks
190
- * The following packages are added as server externals for both webpack and Turbopack:
191
- * - `require-in-the-middle` - Required for CommonJS module interception
192
- * - `jsonpath` - Required for schema manipulation
193
- * - Additional packages when TUSK_DRIFT_MODE is RECORD or REPLAY (e.g., database clients, etc.)
194
- *
195
- * Works with both webpack (default) and Turbopack (`next dev --turbo`).
196
- */
197
- function withTuskDrift(nextConfig = {}, options = {}) {
198
- const config = nextConfig;
199
- const debug = options.debug || false;
200
- const suppressAllWarnings = options.suppressWarnings || false;
201
- const nextjsVersion = getNextjsVersion();
202
- if (nextjsVersion) debugLog(debug, `Detected Next.js version: ${nextjsVersion}`);
203
- else warn(suppressAllWarnings || false, "Could not detect Next.js version. Some features may not work correctly. If you encounter issues, please ensure Next.js is properly installed.");
204
- const needsInstrumentationHook = !options.disableInstrumentationHook && shouldSetInstrumentationHook(nextjsVersion);
205
- const mode = process.env.TUSK_DRIFT_MODE?.toUpperCase();
206
- const coreExternals = [
207
- "require-in-the-middle",
208
- "jsonpath",
209
- ...mode === "RECORD" || mode === "REPLAY" ? [
210
- "@upstash/redis",
211
- "ioredis",
212
- "pg",
213
- "postgres",
214
- "mysql2",
215
- "@prisma/client",
216
- "@google-cloud/firestore",
217
- "@grpc/grpc-js",
218
- "graphql",
219
- "jsonwebtoken",
220
- "jwks-rsa"
221
- ] : []
222
- ];
223
- const wrappedConfig = {
224
- ...config,
225
- ...needsInstrumentationHook ? { experimental: {
226
- ...config.experimental,
227
- instrumentationHook: true
228
- } } : { experimental: config.experimental },
229
- serverExternalPackages: [...config.serverExternalPackages || [], ...coreExternals],
230
- webpack: (webpackConfig, webpackOptions) => {
231
- if (webpackOptions.isServer) {
232
- const originalExternals = webpackConfig.externals;
233
- const externalsMapping = {};
234
- for (const pkg of coreExternals) {
235
- externalsMapping[pkg] = `commonjs ${pkg}`;
236
- debugLog(debug, `Mapped external ${pkg} -> commonjs ${pkg}`);
237
- }
238
- if (!originalExternals) {
239
- webpackConfig.externals = [externalsMapping];
240
- debugLog(debug, "Created new externals with SDK paths");
241
- } else if (Array.isArray(originalExternals)) {
242
- originalExternals.push(externalsMapping);
243
- debugLog(debug, "Added SDK paths to existing externals array");
244
- } else {
245
- webpackConfig.externals = [originalExternals, externalsMapping];
246
- debugLog(debug, "Wrapped existing externals with SDK paths");
247
- }
248
- }
249
- if (typeof config.webpack === "function") return config.webpack(webpackConfig, webpackOptions);
250
- return webpackConfig;
251
- }
252
- };
253
- if (needsInstrumentationHook) debugLog(debug, "Set experimental.instrumentationHook to true");
254
- else debugLog(debug, "Skipped setting experimental.instrumentationHook (not needed for Next.js 15.0.0-rc.1+)");
255
- if (options.disableInstrumentationHook && nextjsVersion && shouldSetInstrumentationHook(nextjsVersion)) warn(suppressAllWarnings || false, "You disabled instrumentationHook, but your Next.js version requires it. Tusk Drift may not initialize properly. Please remove the disableInstrumentationHook option.");
256
- return wrappedConfig;
257
- }
258
-
259
58
  //#endregion
260
59
  //#region src/instrumentation/core/baseClasses/TdInstrumentationAbstract.ts
261
60
  var TdInstrumentationAbstract = class {
@@ -41362,7 +41161,7 @@ var require_src = /* @__PURE__ */ __commonJS({ "node_modules/@opentelemetry/sdk-
41362
41161
  //#endregion
41363
41162
  //#region package.json
41364
41163
  var import_src$1 = /* @__PURE__ */ __toESM(require_src(), 1);
41365
- var version = "0.1.35";
41164
+ var version = "0.1.36";
41366
41165
 
41367
41166
  //#endregion
41368
41167
  //#region src/version.ts
@@ -43653,5 +43452,5 @@ var TuskDriftSDK = class {
43653
43452
  const TuskDrift = new TuskDriftSDK();
43654
43453
 
43655
43454
  //#endregion
43656
- export { TuskDrift, withTuskDrift };
43455
+ export { TuskDrift };
43657
43456
  //# sourceMappingURL=index.js.map