@interfere/next 0.1.0-alpha.9 → 0.2.0-alpha.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/README.md +70 -277
- package/dist/_virtual/_rolldown/runtime.mjs +13 -0
- package/dist/config.d.mts +11 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +107 -0
- package/dist/config.mjs.map +1 -0
- package/dist/instrument-client.d.mts +2 -0
- package/dist/instrument-client.mjs +2 -0
- package/dist/internal/build/configure-build.d.mts +22 -0
- package/dist/internal/build/configure-build.d.mts.map +1 -0
- package/dist/internal/build/configure-build.mjs +87 -0
- package/dist/internal/build/configure-build.mjs.map +1 -0
- package/dist/internal/build/injected.d.mts +12 -0
- package/dist/internal/build/injected.d.mts.map +1 -0
- package/dist/internal/build/injected.mjs +9 -0
- package/dist/internal/build/injected.mjs.map +1 -0
- package/dist/internal/build/release/destinations/vercel.d.mts +6 -0
- package/dist/internal/build/release/destinations/vercel.d.mts.map +1 -0
- package/dist/internal/build/release/destinations/vercel.mjs +25 -0
- package/dist/internal/build/release/destinations/vercel.mjs.map +1 -0
- package/dist/internal/build/release/git.d.mts +4 -0
- package/dist/internal/build/release/git.d.mts.map +1 -0
- package/dist/internal/build/release/git.mjs +21 -0
- package/dist/internal/build/release/git.mjs.map +1 -0
- package/dist/internal/build/release/index.d.mts +7 -0
- package/dist/internal/build/release/index.d.mts.map +1 -0
- package/dist/internal/build/release/index.mjs +24 -0
- package/dist/internal/build/release/index.mjs.map +1 -0
- package/dist/internal/build/release/sources/github.d.mts +6 -0
- package/dist/internal/build/release/sources/github.d.mts.map +1 -0
- package/dist/internal/build/release/sources/github.mjs +15 -0
- package/dist/internal/build/release/sources/github.mjs.map +1 -0
- package/dist/internal/build/release/types.d.mts +11 -0
- package/dist/internal/build/release/types.d.mts.map +1 -0
- package/dist/internal/build/release/types.mjs +1 -0
- package/dist/internal/build/source-maps/discover.d.mts +14 -0
- package/dist/internal/build/source-maps/discover.d.mts.map +1 -0
- package/dist/internal/build/source-maps/discover.mjs +61 -0
- package/dist/internal/build/source-maps/discover.mjs.map +1 -0
- package/dist/internal/build/source-maps/index.d.mts +23 -0
- package/dist/internal/build/source-maps/index.d.mts.map +1 -0
- package/dist/internal/build/source-maps/index.mjs +33 -0
- package/dist/internal/build/source-maps/index.mjs.map +1 -0
- package/dist/internal/build/value-injection-loader.d.mts +10 -0
- package/dist/internal/build/value-injection-loader.d.mts.map +1 -0
- package/dist/internal/build/value-injection-loader.mjs +24 -0
- package/dist/internal/build/value-injection-loader.mjs.map +1 -0
- package/dist/internal/env.d.mts +16 -0
- package/dist/internal/env.d.mts.map +1 -0
- package/dist/internal/env.mjs +19 -0
- package/dist/internal/env.mjs.map +1 -0
- package/dist/internal/logger.d.mts +8 -0
- package/dist/internal/logger.d.mts.map +1 -0
- package/dist/internal/logger.mjs +44 -0
- package/dist/internal/logger.mjs.map +1 -0
- package/dist/internal/route/cors.d.mts +4 -0
- package/dist/internal/route/cors.d.mts.map +1 -0
- package/dist/internal/route/cors.mjs +15 -0
- package/dist/internal/route/cors.mjs.map +1 -0
- package/dist/internal/route/handle-get.d.mts +4 -0
- package/dist/internal/route/handle-get.d.mts.map +1 -0
- package/dist/internal/route/handle-get.mjs +15 -0
- package/dist/internal/route/handle-get.mjs.map +1 -0
- package/dist/internal/route/handle-post.d.mts +4 -0
- package/dist/internal/route/handle-post.d.mts.map +1 -0
- package/dist/internal/route/handle-post.mjs +105 -0
- package/dist/internal/route/handle-post.mjs.map +1 -0
- package/dist/internal/route/sw-script.d.mts +4 -0
- package/dist/internal/route/sw-script.d.mts.map +1 -0
- package/dist/internal/route/sw-script.mjs +32 -0
- package/dist/internal/route/sw-script.mjs.map +1 -0
- package/dist/internal/server/capture.d.mts +9 -0
- package/dist/internal/server/capture.d.mts.map +1 -0
- package/dist/internal/server/capture.mjs +46 -0
- package/dist/internal/server/capture.mjs.map +1 -0
- package/dist/internal/server/dedupe.d.mts +5 -0
- package/dist/internal/server/dedupe.d.mts.map +1 -0
- package/dist/internal/server/dedupe.mjs +11 -0
- package/dist/internal/server/dedupe.mjs.map +1 -0
- package/dist/internal/server/envelope.d.mts +14 -0
- package/dist/internal/server/envelope.d.mts.map +1 -0
- package/dist/internal/server/envelope.mjs +41 -0
- package/dist/internal/server/envelope.mjs.map +1 -0
- package/dist/internal/server/mechanisms.d.mts +7 -0
- package/dist/internal/server/mechanisms.d.mts.map +1 -0
- package/dist/internal/server/mechanisms.mjs +12 -0
- package/dist/internal/server/mechanisms.mjs.map +1 -0
- package/dist/internal/server/normalize-request.d.mts +7 -0
- package/dist/internal/server/normalize-request.d.mts.map +1 -0
- package/dist/internal/server/normalize-request.mjs +50 -0
- package/dist/internal/server/normalize-request.mjs.map +1 -0
- package/dist/internal/server/runtime.d.mts +14 -0
- package/dist/internal/server/runtime.d.mts.map +1 -0
- package/dist/internal/server/runtime.mjs +18 -0
- package/dist/internal/server/runtime.mjs.map +1 -0
- package/dist/internal/server/session.d.mts +11 -0
- package/dist/internal/server/session.d.mts.map +1 -0
- package/dist/internal/server/session.mjs +15 -0
- package/dist/internal/server/session.mjs.map +1 -0
- package/dist/internal/server/transport.d.mts +14 -0
- package/dist/internal/server/transport.d.mts.map +1 -0
- package/dist/internal/server/transport.mjs +16 -0
- package/dist/internal/server/transport.mjs.map +1 -0
- package/dist/internal/server/types.d.mts +17 -0
- package/dist/internal/server/types.d.mts.map +1 -0
- package/dist/internal/server/types.mjs +1 -0
- package/dist/provider.d.mts +2 -0
- package/dist/provider.mjs +3 -0
- package/dist/route-handler.d.mts +7 -0
- package/dist/route-handler.d.mts.map +1 -0
- package/dist/route-handler.mjs +18 -0
- package/dist/route-handler.mjs.map +1 -0
- package/dist/server.d.mts +8 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +6 -0
- package/dist/server.mjs.map +1 -0
- package/package.json +60 -73
- package/LICENSE +0 -21
- package/dist/build/env-config.d.mts +0 -7
- package/dist/build/env-config.d.mts.map +0 -1
- package/dist/build/env-config.mjs +0 -17
- package/dist/build/env-config.mjs.map +0 -1
- package/dist/build/loaders/value-injection-loader.d.mts +0 -28
- package/dist/build/loaders/value-injection-loader.d.mts.map +0 -1
- package/dist/build/loaders/value-injection-loader.mjs +0 -44
- package/dist/build/loaders/value-injection-loader.mjs.map +0 -1
- package/dist/build/logger.d.mts +0 -11
- package/dist/build/logger.d.mts.map +0 -1
- package/dist/build/logger.mjs +0 -155
- package/dist/build/logger.mjs.map +0 -1
- package/dist/build/release-program.d.mts +0 -19
- package/dist/build/release-program.d.mts.map +0 -1
- package/dist/build/release-program.mjs +0 -92
- package/dist/build/release-program.mjs.map +0 -1
- package/dist/build/secret-key.d.mts +0 -10
- package/dist/build/secret-key.d.mts.map +0 -1
- package/dist/build/secret-key.mjs +0 -16
- package/dist/build/secret-key.mjs.map +0 -1
- package/dist/build/services/config.service.d.mts +0 -9
- package/dist/build/services/config.service.d.mts.map +0 -1
- package/dist/build/services/config.service.mjs +0 -8
- package/dist/build/services/config.service.mjs.map +0 -1
- package/dist/build/services/instrumentation-detection.service.d.mts +0 -22
- package/dist/build/services/instrumentation-detection.service.d.mts.map +0 -1
- package/dist/build/services/instrumentation-detection.service.mjs +0 -60
- package/dist/build/services/instrumentation-detection.service.mjs.map +0 -1
- package/dist/build/services/preflight.service.d.mts +0 -19
- package/dist/build/services/preflight.service.d.mts.map +0 -1
- package/dist/build/services/preflight.service.mjs +0 -76
- package/dist/build/services/preflight.service.mjs.map +0 -1
- package/dist/build/services/release-identity.service.d.mts +0 -22
- package/dist/build/services/release-identity.service.d.mts.map +0 -1
- package/dist/build/services/release-identity.service.mjs +0 -48
- package/dist/build/services/release-identity.service.mjs.map +0 -1
- package/dist/build/services/source-map.service.d.mts +0 -24
- package/dist/build/services/source-map.service.d.mts.map +0 -1
- package/dist/build/services/source-map.service.mjs +0 -58
- package/dist/build/services/source-map.service.mjs.map +0 -1
- package/dist/build/source-maps/api.d.mts +0 -35
- package/dist/build/source-maps/api.d.mts.map +0 -1
- package/dist/build/source-maps/api.mjs +0 -61
- package/dist/build/source-maps/api.mjs.map +0 -1
- package/dist/build/source-maps/client.d.mts +0 -73
- package/dist/build/source-maps/client.d.mts.map +0 -1
- package/dist/build/source-maps/client.mjs +0 -228
- package/dist/build/source-maps/client.mjs.map +0 -1
- package/dist/build/source-maps/errors.d.mts +0 -109
- package/dist/build/source-maps/errors.d.mts.map +0 -1
- package/dist/build/source-maps/errors.mjs +0 -22
- package/dist/build/source-maps/errors.mjs.map +0 -1
- package/dist/build/source-maps/files.d.mts +0 -35
- package/dist/build/source-maps/files.d.mts.map +0 -1
- package/dist/build/source-maps/files.mjs +0 -222
- package/dist/build/source-maps/files.mjs.map +0 -1
- package/dist/build/source-maps/providers/deployment/detector.d.mts +0 -26
- package/dist/build/source-maps/providers/deployment/detector.d.mts.map +0 -1
- package/dist/build/source-maps/providers/deployment/detector.mjs +0 -22
- package/dist/build/source-maps/providers/deployment/detector.mjs.map +0 -1
- package/dist/build/source-maps/providers/deployment/types.d.mts +0 -12
- package/dist/build/source-maps/providers/deployment/types.d.mts.map +0 -1
- package/dist/build/source-maps/providers/deployment/types.mjs +0 -3
- package/dist/build/source-maps/providers/deployment/vercel.d.mts +0 -6
- package/dist/build/source-maps/providers/deployment/vercel.d.mts.map +0 -1
- package/dist/build/source-maps/providers/deployment/vercel.mjs +0 -44
- package/dist/build/source-maps/providers/deployment/vercel.mjs.map +0 -1
- package/dist/build/source-maps/providers/source-control/detector.d.mts +0 -15
- package/dist/build/source-maps/providers/source-control/detector.d.mts.map +0 -1
- package/dist/build/source-maps/providers/source-control/detector.mjs +0 -22
- package/dist/build/source-maps/providers/source-control/detector.mjs.map +0 -1
- package/dist/build/source-maps/providers/source-control/git.d.mts +0 -6
- package/dist/build/source-maps/providers/source-control/git.d.mts.map +0 -1
- package/dist/build/source-maps/providers/source-control/git.mjs +0 -50
- package/dist/build/source-maps/providers/source-control/git.mjs.map +0 -1
- package/dist/build/source-maps/providers/source-control/types.d.mts +0 -12
- package/dist/build/source-maps/providers/source-control/types.d.mts.map +0 -1
- package/dist/build/source-maps/providers/source-control/types.mjs +0 -3
- package/dist/build/with-interfere.d.mts +0 -70
- package/dist/build/with-interfere.d.mts.map +0 -1
- package/dist/build/with-interfere.mjs +0 -154
- package/dist/build/with-interfere.mjs.map +0 -1
- package/dist/client/auto-init.d.mts +0 -92
- package/dist/client/auto-init.d.mts.map +0 -1
- package/dist/client/auto-init.mjs +0 -121
- package/dist/client/auto-init.mjs.map +0 -1
- package/dist/client/client.d.mts +0 -3
- package/dist/client/client.mjs +0 -5
- package/dist/client/provider.d.mts +0 -22
- package/dist/client/provider.d.mts.map +0 -1
- package/dist/client/provider.mjs +0 -50
- package/dist/client/provider.mjs.map +0 -1
- package/dist/lib/env.d.mts +0 -12
- package/dist/lib/env.d.mts.map +0 -1
- package/dist/lib/env.mjs +0 -17
- package/dist/lib/env.mjs.map +0 -1
- package/dist/lib/test-utils/make-next-request.d.mts +0 -6
- package/dist/lib/test-utils/make-next-request.d.mts.map +0 -1
- package/dist/lib/test-utils/make-next-request.mjs +0 -12
- package/dist/lib/test-utils/make-next-request.mjs.map +0 -1
- package/dist/lib/types.d.mts +0 -22
- package/dist/lib/types.d.mts.map +0 -1
- package/dist/lib/types.mjs +0 -7
- package/dist/lib/types.mjs.map +0 -1
- package/dist/server/middleware.d.mts +0 -11
- package/dist/server/middleware.d.mts.map +0 -1
- package/dist/server/middleware.mjs +0 -85
- package/dist/server/middleware.mjs.map +0 -1
- package/dist/server/proxy.d.mts +0 -6
- package/dist/server/proxy.d.mts.map +0 -1
- package/dist/server/proxy.mjs +0 -30
- package/dist/server/proxy.mjs.map +0 -1
- package/dist/server/route-handler.d.mts +0 -9
- package/dist/server/route-handler.d.mts.map +0 -1
- package/dist/server/route-handler.mjs +0 -172
- package/dist/server/route-handler.mjs.map +0 -1
- package/dist/server/services/config.service.d.mts +0 -21
- package/dist/server/services/config.service.d.mts.map +0 -1
- package/dist/server/services/config.service.mjs +0 -43
- package/dist/server/services/config.service.mjs.map +0 -1
- package/dist/server/services/error-tracking.service.d.mts +0 -19
- package/dist/server/services/error-tracking.service.d.mts.map +0 -1
- package/dist/server/services/error-tracking.service.mjs +0 -31
- package/dist/server/services/error-tracking.service.mjs.map +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { resolveApiUrl } from "./env-config.mjs";
|
|
2
|
-
import { logBuildResult, withBufferedBuildLog } from "./logger.mjs";
|
|
3
|
-
import { ConfigService, ConfigServiceLive } from "./services/config.service.mjs";
|
|
4
|
-
import { ReleaseIdentityService, ReleaseIdentityServiceLive } from "./services/release-identity.service.mjs";
|
|
5
|
-
import { createRelease } from "./source-maps/api.mjs";
|
|
6
|
-
import { maybeCleanupAfterFailure } from "./source-maps/files.mjs";
|
|
7
|
-
import { SourceMapService, SourceMapServiceLive } from "./services/source-map.service.mjs";
|
|
8
|
-
import { Effect, Layer } from "effect";
|
|
9
|
-
|
|
10
|
-
//#region src/build/release-program.ts
|
|
11
|
-
/**
|
|
12
|
-
* The main release upload program.
|
|
13
|
-
* This is a single Effect that orchestrates the entire release process.
|
|
14
|
-
*/
|
|
15
|
-
const releaseProgram = Effect.gen(function* () {
|
|
16
|
-
const config = yield* ConfigService;
|
|
17
|
-
if (process.env.NODE_ENV === "development") {
|
|
18
|
-
yield* logBuildResult("Info", "Skipping Release", ["Development build detected"]);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!config.enabled) {
|
|
22
|
-
yield* logBuildResult("Warning", "Skipping Release", ["Interfere is disabled. (`interfere.enabled` is `false` in your `next.config.(js|ts)`)"]);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const sourceMapService = yield* SourceMapService;
|
|
26
|
-
if (!config.secretKey) {
|
|
27
|
-
yield* logBuildResult("Warning", "Skipping Release", ["Missing secret key. Please set the `INTERFERE_SECRET_KEY` environment variable."]);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
yield* Effect.logDebug("Getting release identity");
|
|
31
|
-
const identityStart = Date.now();
|
|
32
|
-
const identity = yield* yield* ReleaseIdentityService;
|
|
33
|
-
yield* Effect.logDebug(`Release identity resolved in ${Date.now() - identityStart}ms`);
|
|
34
|
-
if (!identity.sourceControl) {
|
|
35
|
-
yield* logBuildResult("Warning", "Skipping Release", ["Could not determine source control metadata (no supported VCS provider detected).", "Ensure your CI checks out the git repository and that a supported provider is configured."]);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!identity.deployment) {
|
|
39
|
-
yield* logBuildResult("Warning", "Skipping Release", ["Could not determine deployment metadata (no supported deployment provider detected).", "If this is a local build you can ignore this. Otherwise, expose your platform's system env vars (e.g. VERCEL_*)."]);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
yield* Effect.logDebug("Finding source maps");
|
|
43
|
-
const findStart = Date.now();
|
|
44
|
-
const sourceMapFiles = yield* sourceMapService.find;
|
|
45
|
-
yield* Effect.logDebug(`Found ${sourceMapFiles.length} source maps in ${Date.now() - findStart}ms`);
|
|
46
|
-
if (sourceMapFiles.length === 0) {
|
|
47
|
-
yield* logBuildResult("Warning", "Skipping Release", ["No source maps found. Is `productionBrowserSourceMaps` set to `false` in your `next.config.js`?"]);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
yield* Effect.logDebug("Creating release");
|
|
51
|
-
const createStart = Date.now();
|
|
52
|
-
const releaseResponse = yield* createRelease(config, {
|
|
53
|
-
environment: config.environment,
|
|
54
|
-
sourceId: identity.buildId,
|
|
55
|
-
sourceType: identity.sourceControl.type,
|
|
56
|
-
sourceMetadata: identity.sourceControl.metadata,
|
|
57
|
-
destinationType: identity.deployment.type,
|
|
58
|
-
destinationMetadata: identity.deployment.metadata
|
|
59
|
-
});
|
|
60
|
-
yield* Effect.logDebug(`Release created in ${Date.now() - createStart}ms`);
|
|
61
|
-
yield* Effect.logDebug("Reading source maps");
|
|
62
|
-
const readStart = Date.now();
|
|
63
|
-
const sourceMaps = yield* sourceMapService.read(sourceMapFiles);
|
|
64
|
-
yield* Effect.logDebug(`Read ${sourceMaps.length} source maps in ${Date.now() - readStart}ms`);
|
|
65
|
-
yield* Effect.logDebug("Uploading source maps");
|
|
66
|
-
const uploadStart = Date.now();
|
|
67
|
-
yield* sourceMapService.upload(sourceMaps, {
|
|
68
|
-
...releaseResponse,
|
|
69
|
-
apiUrl: resolveApiUrl()
|
|
70
|
-
});
|
|
71
|
-
yield* Effect.logDebug(`Source maps uploaded in ${Date.now() - uploadStart}ms`);
|
|
72
|
-
yield* Effect.logDebug("Cleaning up source maps");
|
|
73
|
-
const cleanupStart = Date.now();
|
|
74
|
-
yield* sourceMapService.cleanup(sourceMapFiles, !!config.debug);
|
|
75
|
-
yield* Effect.logDebug(`Cleanup completed in ${Date.now() - cleanupStart}ms`);
|
|
76
|
-
}).pipe(Effect.catchIf((error) => error._tag !== "MissingBuildIdError" && error._tag !== "MissingReleaseIdError", (error) => withBufferedBuildLog("Error", "Failed to upload source maps", (log) => Effect.gen(function* () {
|
|
77
|
-
const config = yield* ConfigService;
|
|
78
|
-
yield* log(String(error));
|
|
79
|
-
if (config.environment === "production" && config.cleanupSourceMaps !== false) yield* maybeCleanupAfterFailure(!!config.debug);
|
|
80
|
-
}))), Effect.withSpan("interfere.release"));
|
|
81
|
-
/**
|
|
82
|
-
* Create the layer stack for the release program
|
|
83
|
-
*/
|
|
84
|
-
const createReleaseLayers = (config) => {
|
|
85
|
-
const configLayer = ConfigServiceLive(config);
|
|
86
|
-
const identityLayer = ReleaseIdentityServiceLive;
|
|
87
|
-
const sourceMapLayer = SourceMapServiceLive.pipe(Layer.provide(configLayer));
|
|
88
|
-
return Layer.mergeAll(configLayer, identityLayer, sourceMapLayer);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
//#endregion
|
|
92
|
-
export { createReleaseLayers, releaseProgram };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release-program.mjs","names":[],"sources":["../../src/build/release-program.ts"],"sourcesContent":["import { Effect, Layer } from \"effect\";\nimport type { PreflightConfig } from \"../lib/types.js\";\nimport { resolveApiUrl } from \"./env-config.js\";\nimport {\n logBuildResult,\n withBufferedBuildLog,\n} from \"./logger.js\";\nimport {\n ConfigService,\n ConfigServiceLive,\n} from \"./services/config.service.js\";\nimport {\n ReleaseIdentityService,\n ReleaseIdentityServiceLive,\n} from \"./services/release-identity.service.js\";\nimport { SourceMapService, SourceMapServiceLive } from \"./services/source-map.service.js\";\nimport { createRelease } from \"./source-maps/api.js\";\nimport { maybeCleanupAfterFailure } from \"./source-maps/files.js\";\n\n/**\n * The main release upload program.\n * This is a single Effect that orchestrates the entire release process.\n */\nexport const releaseProgram = Effect.gen(function* () {\n const config = yield* ConfigService;\n\n // Early exits\n if (process.env.NODE_ENV === \"development\") {\n yield* logBuildResult(\"Info\", \"Skipping Release\", [\"Development build detected\"]);\n return;\n }\n\n if (!config.enabled) {\n yield* logBuildResult(\n \"Warning\",\n \"Skipping Release\",\n [\"Interfere is disabled. (`interfere.enabled` is `false` in your `next.config.(js|ts)`)\"]\n );\n return;\n }\n\n const sourceMapService = yield* SourceMapService;\n\n if (!config.secretKey) {\n yield* logBuildResult(\n \"Warning\",\n \"Skipping Release\",\n [\"Missing secret key. Please set the `INTERFERE_SECRET_KEY` environment variable.\"]\n );\n return;\n }\n\n // Get release identity (will fail if can't determine)\n yield* Effect.logDebug(\"Getting release identity\");\n const identityStart = Date.now();\n const identityEffect = yield* ReleaseIdentityService;\n const identity = yield* identityEffect;\n yield* Effect.logDebug(`Release identity resolved in ${Date.now() - identityStart}ms`);\n\n // Check for required metadata\n if (!identity.sourceControl) {\n yield* logBuildResult(\n \"Warning\",\n \"Skipping Release\",\n [\n \"Could not determine source control metadata (no supported VCS provider detected).\",\n \"Ensure your CI checks out the git repository and that a supported provider is configured.\",\n ]\n );\n return;\n }\n\n if (!identity.deployment) {\n yield* logBuildResult(\n \"Warning\",\n \"Skipping Release\",\n [\n \"Could not determine deployment metadata (no supported deployment provider detected).\",\n \"If this is a local build you can ignore this. Otherwise, expose your platform's system env vars (e.g. VERCEL_*).\",\n ]\n );\n return;\n }\n\n // Find source maps\n yield* Effect.logDebug(\"Finding source maps\");\n const findStart = Date.now();\n const sourceMapFiles = yield* sourceMapService.find;\n yield* Effect.logDebug(`Found ${sourceMapFiles.length} source maps in ${Date.now() - findStart}ms`);\n\n if (sourceMapFiles.length === 0) {\n yield* logBuildResult(\n \"Warning\",\n \"Skipping Release\",\n [\"No source maps found. Is `productionBrowserSourceMaps` set to `false` in your `next.config.js`?\"]\n );\n return;\n }\n\n // Create release\n yield* Effect.logDebug(\"Creating release\");\n const createStart = Date.now();\n const releaseResponse = yield* createRelease(config, {\n environment: config.environment,\n sourceId: identity.buildId,\n sourceType: identity.sourceControl.type,\n sourceMetadata: identity.sourceControl.metadata,\n destinationType: identity.deployment.type,\n destinationMetadata: identity.deployment.metadata,\n });\n yield* Effect.logDebug(`Release created in ${Date.now() - createStart}ms`);\n\n // Read and upload source maps\n yield* Effect.logDebug(\"Reading source maps\");\n const readStart = Date.now();\n const sourceMaps = yield* sourceMapService.read(sourceMapFiles);\n yield* Effect.logDebug(`Read ${sourceMaps.length} source maps in ${Date.now() - readStart}ms`);\n \n yield* Effect.logDebug(\"Uploading source maps\");\n const uploadStart = Date.now();\n yield* sourceMapService.upload(sourceMaps, {\n ...releaseResponse,\n apiUrl: resolveApiUrl(),\n });\n yield* Effect.logDebug(`Source maps uploaded in ${Date.now() - uploadStart}ms`);\n\n // Cleanup\n yield* Effect.logDebug(\"Cleaning up source maps\");\n const cleanupStart = Date.now();\n yield* sourceMapService.cleanup(sourceMapFiles, !!config.debug);\n yield* Effect.logDebug(`Cleanup completed in ${Date.now() - cleanupStart}ms`);\n}).pipe(\n Effect.catchIf(\n // Only catch upload-related errors, let identity errors propagate\n (error) =>\n error._tag !== \"MissingBuildIdError\" &&\n error._tag !== \"MissingReleaseIdError\",\n (error) =>\n withBufferedBuildLog(\"Error\", \"Failed to upload source maps\", (log) =>\n Effect.gen(function* () {\n const config = yield* ConfigService;\n\n // Queue up build log lines so they appear in a single structured block\n yield* log(String(error));\n\n // Cleanup on failure\n if (\n config.environment === \"production\" &&\n config.cleanupSourceMaps !== false\n ) {\n yield* maybeCleanupAfterFailure(!!config.debug);\n }\n\n // Swallow the error so we don't surface a noisy FiberFailure stack trace\n return;\n })\n )\n ),\n Effect.withSpan(\"interfere.release\")\n);\n\n/**\n * Create the layer stack for the release program\n */\nexport const createReleaseLayers = (config: PreflightConfig) => {\n const configLayer = ConfigServiceLive(config);\n\n const identityLayer = ReleaseIdentityServiceLive;\n \n const sourceMapLayer = SourceMapServiceLive.pipe(\n Layer.provide(configLayer)\n );\n \n return Layer.mergeAll(\n configLayer,\n identityLayer,\n sourceMapLayer\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAa,iBAAiB,OAAO,IAAI,aAAa;CACpD,MAAM,SAAS,OAAO;AAGtB,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,SAAO,eAAe,QAAQ,oBAAoB,CAAC,6BAA6B,CAAC;AACjF;;AAGF,KAAI,CAAC,OAAO,SAAS;AACnB,SAAO,eACL,WACA,oBACA,CAAC,wFAAwF,CAC1F;AACD;;CAGF,MAAM,mBAAmB,OAAO;AAEhC,KAAI,CAAC,OAAO,WAAW;AACrB,SAAO,eACL,WACA,oBACA,CAAC,kFAAkF,CACpF;AACD;;AAIF,QAAO,OAAO,SAAS,2BAA2B;CAClD,MAAM,gBAAgB,KAAK,KAAK;CAEhC,MAAM,WAAW,OADM,OAAO;AAE9B,QAAO,OAAO,SAAS,gCAAgC,KAAK,KAAK,GAAG,cAAc,IAAI;AAGtF,KAAI,CAAC,SAAS,eAAe;AAC3B,SAAO,eACL,WACA,oBACA,CACE,qFACA,4FACD,CACF;AACD;;AAGF,KAAI,CAAC,SAAS,YAAY;AACxB,SAAO,eACL,WACA,oBAC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,UACC,MAAM,SAAS,yBACf,MAAM,SAAS,0BAChB,UACC,qBAAqB,SAAS,iCAAiC,QAC7D,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO;AAGtB,QAAO,IAAI,OAAO,MAAM,CAAC;AAGzB,KACE,OAAO,gBAAgB,gBACvB,OAAO,sBAAsB,MAE7B,QAAO,yBAAyB,CAAC,CAAC,OAAO,MAAM;EAKjD,CACH,CACJ,EACD,OAAO,SAAS,oBAAoB,CACrC;;;;AAKD,MAAa,uBAAuB,WAA4B;CAC9D,MAAM,cAAc,kBAAkB,OAAO;CAE7C,MAAM,gBAAgB;CAEtB,MAAM,iBAAiB,qBAAqB,KAC1C,MAAM,QAAQ,YAAY,CAC3B;AAED,QAAO,MAAM,SACX,aACA,eACA,eACD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/build/secret-key.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Parse surface slug from secret key
|
|
4
|
-
* Format: int_sk_{surfaceSlug}_{random}
|
|
5
|
-
* Note: This is for display/validation purposes only.
|
|
6
|
-
* The actual surface lookup should use the key hash via Redis/DB.
|
|
7
|
-
*/
|
|
8
|
-
declare function parseSurfaceSlugFromSecretKey(secretKey: string): string | undefined;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { parseSurfaceSlugFromSecretKey };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secret-key.d.mts","names":[],"sources":["../../src/build/secret-key.ts"],"sourcesContent":[],"mappings":";;AAQA;;;;;iBAAgB,6BAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SECRET_KEY_REGEX } from "@interfere/types/auth/secret-key";
|
|
2
|
-
|
|
3
|
-
//#region src/build/secret-key.ts
|
|
4
|
-
/**
|
|
5
|
-
* Parse surface slug from secret key
|
|
6
|
-
* Format: int_sk_{surfaceSlug}_{random}
|
|
7
|
-
* Note: This is for display/validation purposes only.
|
|
8
|
-
* The actual surface lookup should use the key hash via Redis/DB.
|
|
9
|
-
*/
|
|
10
|
-
function parseSurfaceSlugFromSecretKey(secretKey) {
|
|
11
|
-
const match = secretKey.match(SECRET_KEY_REGEX);
|
|
12
|
-
if (match) return match[1];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { parseSurfaceSlugFromSecretKey };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secret-key.mjs","names":[],"sources":["../../src/build/secret-key.ts"],"sourcesContent":["import { SECRET_KEY_REGEX } from \"@interfere/types/auth/secret-key\";\n\n/**\n * Parse surface slug from secret key\n * Format: int_sk_{surfaceSlug}_{random}\n * Note: This is for display/validation purposes only.\n * The actual surface lookup should use the key hash via Redis/DB.\n */\nexport function parseSurfaceSlugFromSecretKey(\n secretKey: string\n): string | undefined {\n const match = secretKey.match(SECRET_KEY_REGEX);\n\n if (match) {\n return match[1];\n }\n\n return;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,8BACd,WACoB;CACpB,MAAM,QAAQ,UAAU,MAAM,iBAAiB;AAE/C,KAAI,MACF,QAAO,MAAM"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PreflightConfig } from "../../lib/types.mjs";
|
|
2
|
-
import { Context, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/build/services/config.service.d.ts
|
|
5
|
-
declare const ConfigService_base: Context.TagClass<ConfigService, "ConfigService", PreflightConfig>;
|
|
6
|
-
declare class ConfigService extends ConfigService_base {}
|
|
7
|
-
declare const ConfigServiceLive: (config: PreflightConfig) => Layer.Layer<ConfigService, never, never>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ConfigService, ConfigServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.service.d.mts","names":[],"sources":["../../../src/build/services/config.service.ts"],"sourcesContent":[],"mappings":";;;;cAC0E;cAE7D,aAAA,SAAsB,kBAAA;cAKtB,4BAA6B,oBAAe,KAAA,CAAA,MAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Context, Layer } from "effect";
|
|
2
|
-
|
|
3
|
-
//#region src/build/services/config.service.ts
|
|
4
|
-
var ConfigService = class extends Context.Tag("ConfigService")() {};
|
|
5
|
-
const ConfigServiceLive = (config) => Layer.succeed(ConfigService, config);
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
export { ConfigService, ConfigServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.service.mjs","names":[],"sources":["../../../src/build/services/config.service.ts"],"sourcesContent":["import { Context, Layer } from \"effect\";\nimport type { NonEmptyString, PreflightConfig } from \"../../lib/types.js\";\n\nexport class ConfigService extends Context.Tag(\"ConfigService\")<\n ConfigService,\n PreflightConfig\n>() {}\n\nexport const ConfigServiceLive = (config: PreflightConfig) =>\n Layer.succeed(ConfigService, config);\n"],"mappings":";;;AAGA,IAAa,gBAAb,cAAmC,QAAQ,IAAI,gBAAgB,EAG5D,CAAC;AAEJ,MAAa,qBAAqB,WAChC,MAAM,QAAQ,eAAe,OAAO"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/build/services/instrumentation-detection.service.d.ts
|
|
2
|
-
interface InstrumentationFiles {
|
|
3
|
-
readonly server: string | null;
|
|
4
|
-
readonly client: string | null;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Synchronously detect instrumentation files at build time.
|
|
8
|
-
*
|
|
9
|
-
* Searches for:
|
|
10
|
-
* - Server instrumentation: `instrumentation.{ts,js,mts,mjs}`
|
|
11
|
-
* - Client instrumentation: `instrumentation-client.{ts,js,mts,mjs}`
|
|
12
|
-
*
|
|
13
|
-
* In the following directories (in order):
|
|
14
|
-
* 1. Project root
|
|
15
|
-
* 2. `src/` directory
|
|
16
|
-
*
|
|
17
|
-
* @param cwd - The current working directory (defaults to process.cwd())
|
|
18
|
-
* @returns An object with paths to the detected instrumentation files, or null if not found
|
|
19
|
-
*/
|
|
20
|
-
declare function detectInstrumentationFilesSync(cwd?: string): InstrumentationFiles;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { InstrumentationFiles, detectInstrumentationFilesSync };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation-detection.service.d.mts","names":[],"sources":["../../../src/build/services/instrumentation-detection.service.ts"],"sourcesContent":[],"mappings":";UAGiB,oBAAA;EAAA,SAAA,MAAA,EAAA,MAAoB,GAAA,IAAA;EA6DrB,SAAA,MAAA,EAAA,MAAA,GAAA,IAAA;;;;;;;;;;;;;;;;iBAAA,8BAAA,gBAA8C"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import * as path$1 from "node:path";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
|
|
4
|
-
//#region src/build/services/instrumentation-detection.service.ts
|
|
5
|
-
const FILE_PATTERNS = {
|
|
6
|
-
server: [
|
|
7
|
-
"instrumentation.ts",
|
|
8
|
-
"instrumentation.js",
|
|
9
|
-
"instrumentation.mts",
|
|
10
|
-
"instrumentation.mjs"
|
|
11
|
-
],
|
|
12
|
-
client: [
|
|
13
|
-
"instrumentation-client.ts",
|
|
14
|
-
"instrumentation-client.js",
|
|
15
|
-
"instrumentation-client.mts",
|
|
16
|
-
"instrumentation-client.mjs"
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Get the standard Next.js locations to search for instrumentation files.
|
|
21
|
-
*/
|
|
22
|
-
function getSearchPaths(cwd) {
|
|
23
|
-
return [cwd, path$1.join(cwd, "src")];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Find the first matching file from a list of file names in the search paths.
|
|
27
|
-
*/
|
|
28
|
-
function findFirstMatchingFile(searchPaths, fileNames) {
|
|
29
|
-
for (const basePath of searchPaths) for (const fileName of fileNames) {
|
|
30
|
-
const filePath = path$1.join(basePath, fileName);
|
|
31
|
-
try {
|
|
32
|
-
if (fs.existsSync(filePath)) return filePath;
|
|
33
|
-
} catch {}
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Synchronously detect instrumentation files at build time.
|
|
39
|
-
*
|
|
40
|
-
* Searches for:
|
|
41
|
-
* - Server instrumentation: `instrumentation.{ts,js,mts,mjs}`
|
|
42
|
-
* - Client instrumentation: `instrumentation-client.{ts,js,mts,mjs}`
|
|
43
|
-
*
|
|
44
|
-
* In the following directories (in order):
|
|
45
|
-
* 1. Project root
|
|
46
|
-
* 2. `src/` directory
|
|
47
|
-
*
|
|
48
|
-
* @param cwd - The current working directory (defaults to process.cwd())
|
|
49
|
-
* @returns An object with paths to the detected instrumentation files, or null if not found
|
|
50
|
-
*/
|
|
51
|
-
function detectInstrumentationFilesSync(cwd) {
|
|
52
|
-
const searchPaths = getSearchPaths(cwd ?? process.cwd());
|
|
53
|
-
return {
|
|
54
|
-
server: findFirstMatchingFile(searchPaths, FILE_PATTERNS.server),
|
|
55
|
-
client: findFirstMatchingFile(searchPaths, FILE_PATTERNS.client)
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
export { detectInstrumentationFilesSync };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation-detection.service.mjs","names":["path"],"sources":["../../../src/build/services/instrumentation-detection.service.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nexport interface InstrumentationFiles {\n readonly server: string | null;\n readonly client: string | null;\n}\n\nconst FILE_PATTERNS = {\n server: [\"instrumentation.ts\", \"instrumentation.js\", \"instrumentation.mts\", \"instrumentation.mjs\"],\n client: [\n \"instrumentation-client.ts\",\n \"instrumentation-client.js\",\n \"instrumentation-client.mts\",\n \"instrumentation-client.mjs\",\n ],\n} as const;\n\n/**\n * Get the standard Next.js locations to search for instrumentation files.\n */\nfunction getSearchPaths(cwd: string): readonly string[] {\n return [\n cwd, // root\n path.join(cwd, \"src\"), // src/\n ];\n}\n\n/**\n * Find the first matching file from a list of file names in the search paths.\n */\nfunction findFirstMatchingFile(\n searchPaths: readonly string[],\n fileNames: readonly string[]\n): string | null {\n for (const basePath of searchPaths) {\n for (const fileName of fileNames) {\n const filePath = path.join(basePath, fileName);\n try {\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n } catch {\n // Ignore errors and continue searching\n }\n }\n }\n return null;\n}\n\n/**\n * Synchronously detect instrumentation files at build time.\n * \n * Searches for:\n * - Server instrumentation: `instrumentation.{ts,js,mts,mjs}`\n * - Client instrumentation: `instrumentation-client.{ts,js,mts,mjs}`\n * \n * In the following directories (in order):\n * 1. Project root\n * 2. `src/` directory\n * \n * @param cwd - The current working directory (defaults to process.cwd())\n * @returns An object with paths to the detected instrumentation files, or null if not found\n */\nexport function detectInstrumentationFilesSync(cwd?: string): InstrumentationFiles {\n const effectiveCwd = cwd ?? process.cwd();\n const searchPaths = getSearchPaths(effectiveCwd);\n\n return {\n server: findFirstMatchingFile(searchPaths, FILE_PATTERNS.server),\n client: findFirstMatchingFile(searchPaths, FILE_PATTERNS.client),\n };\n}\n"],"mappings":";;;;AAQA,MAAM,gBAAgB;CACpB,QAAQ;EAAC;EAAsB;EAAsB;EAAuB;EAAsB;CAClG,QAAQ;EACN;EACA;EACA;EACA;EACD;CACF;;;;AAKD,SAAS,eAAe,KAAgC;AACtD,QAAO,CACL,KACAA,OAAK,KAAK,KAAK,MAAM,CACtB;;;;;AAMH,SAAS,sBACP,aACA,WACe;AACf,MAAK,MAAM,YAAY,YACrB,MAAK,MAAM,YAAY,WAAW;EAChC,MAAM,WAAWA,OAAK,KAAK,UAAU,SAAS;AAC9C,MAAI;AACF,OAAI,GAAG,WAAW,SAAS,CACzB,QAAO;UAEH;;AAKZ,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,+BAA+B,KAAoC;CAEjF,MAAM,cAAc,eADC,OAAO,QAAQ,KAAK,CACO;AAEhD,QAAO;EACL,QAAQ,sBAAsB,aAAa,cAAc,OAAO;EAChE,QAAQ,sBAAsB,aAAa,cAAc,OAAO;EACjE"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { NonEmptyString, PreflightConfig } from "../../lib/types.mjs";
|
|
2
|
-
import { InvalidSecretKeyError, WithInterfereUsageError } from "../source-maps/errors.mjs";
|
|
3
|
-
import { Context, Effect, Layer } from "effect";
|
|
4
|
-
|
|
5
|
-
//#region src/build/services/preflight.service.d.ts
|
|
6
|
-
declare const PreflightService_base: Context.TagClass<PreflightService, "PreflightService", {
|
|
7
|
-
readonly validateEnvironment: () => Effect.Effect<void, WithInterfereUsageError>;
|
|
8
|
-
readonly validateSecretKey: (key: string | null) => Effect.Effect<NonEmptyString, InvalidSecretKeyError>;
|
|
9
|
-
readonly extractSurfaceSlug: (key: NonEmptyString) => Effect.Effect<NonEmptyString, InvalidSecretKeyError>;
|
|
10
|
-
readonly buildConfig: (options: {
|
|
11
|
-
environment?: string;
|
|
12
|
-
debug?: boolean;
|
|
13
|
-
cleanupSourceMaps?: boolean;
|
|
14
|
-
}) => Effect.Effect<PreflightConfig, WithInterfereUsageError>;
|
|
15
|
-
}>;
|
|
16
|
-
declare class PreflightService extends PreflightService_base {}
|
|
17
|
-
declare const PreflightServiceLive: Layer.Layer<PreflightService, never, never>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { PreflightService, PreflightServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.service.d.mts","names":[],"sources":["../../../src/build/services/preflight.service.ts"],"sourcesContent":[],"mappings":";;;;;cAWkC;sCAKM,MAAA,CAAO,aAAa;EAL1B,SAAA,iBAAA,EAAA,CAAA,GAAA,EAAA,MAAA,GAAA,IAAA,EAAA,GAMsB,MAAA,CAAO,MAN7B,CAMoC,cANpC,EAMoD,qBANpD,CAAA;qCAOK,mBAAmB,MAAA,CAAO,OAAO,gBAAgB;EAF5B,SAAA,WAAA,EAAA,CAAA,OAAA,EAAA;IAAb,WAAA,CAAA,EAAA,MAAA;IACuB,KAAA,CAAA,EAAA,OAAA;IAAgB,iBAAA,CAAA,EAAA,OAAA;EAA9B,CAAA,EAAA,GAM9C,MAAA,CAAO,MAN8C,CAMvC,eANuC,EAMtB,uBANsB,CAAA;CACxB,CAAA;AAAiC,cAL3D,gBAAA,SAAyB,qBAAA,CAKkC;AAAd,cAgF7C,oBAhFoD,EAgFhC,KAAA,CAAA,KAhFgC,CAgFhC,gBAhFgC,EAAA,KAAA,EAAA,KAAA,CAAA"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { toNonEmptyString } from "../../lib/types.mjs";
|
|
2
|
-
import { logBuildResult } from "../logger.mjs";
|
|
3
|
-
import { InvalidSecretKeyError, WithInterfereUsageError } from "../source-maps/errors.mjs";
|
|
4
|
-
import { parseSurfaceSlugFromSecretKey } from "../secret-key.mjs";
|
|
5
|
-
import { Context, Effect, Layer } from "effect";
|
|
6
|
-
|
|
7
|
-
//#region src/build/services/preflight.service.ts
|
|
8
|
-
var PreflightService = class extends Context.Tag("PreflightService")() {};
|
|
9
|
-
const validateEnvironment = () => Effect.gen(function* () {
|
|
10
|
-
if (typeof window !== "undefined") return yield* Effect.fail(new WithInterfereUsageError({ message: "Security Error: withInterfere must only be used in next.config.js (server-side). It should never be imported in client-side code." }));
|
|
11
|
-
if (typeof process === "undefined" || !process.versions?.node) return yield* Effect.fail(new WithInterfereUsageError({ message: "Security Error: withInterfere requires Node.js environment. It should only run during build time, not in the browser." }));
|
|
12
|
-
if (typeof process.env.INTERFERE_SECRET_KEY === "string" && process.env.INTERFERE_SECRET_KEY.startsWith("NEXT_PUBLIC_")) return yield* Effect.fail(new WithInterfereUsageError({ message: "Security Error: Secret key should NOT use NEXT_PUBLIC_ prefix. Use INTERFERE_SECRET_KEY instead to keep it server-side only." }));
|
|
13
|
-
});
|
|
14
|
-
const validateSecretKey = (raw) => Effect.gen(function* () {
|
|
15
|
-
if (typeof raw !== "string") return yield* Effect.fail(new InvalidSecretKeyError({ message: "Missing secret key. Set the INTERFERE_SECRET_KEY environment variable" }));
|
|
16
|
-
const result = toNonEmptyString(raw.trim().replace(/^['"]|['"]$/g, ""));
|
|
17
|
-
if (!result) return yield* Effect.fail(new InvalidSecretKeyError({ message: "Invalid secret key. Set the INTERFERE_SECRET_KEY environment variable" }));
|
|
18
|
-
return result;
|
|
19
|
-
});
|
|
20
|
-
const extractSurfaceSlug = (secretKey) => Effect.gen(function* () {
|
|
21
|
-
const parsed = parseSurfaceSlugFromSecretKey(secretKey);
|
|
22
|
-
const result = parsed ? toNonEmptyString(parsed) : void 0;
|
|
23
|
-
if (!result) return yield* Effect.fail(new InvalidSecretKeyError({ message: "Invalid secret key format. Please use the secret key provided in your Interfere dashboard." }));
|
|
24
|
-
return result;
|
|
25
|
-
});
|
|
26
|
-
const PreflightServiceLive = Layer.succeed(PreflightService, {
|
|
27
|
-
validateEnvironment,
|
|
28
|
-
validateSecretKey,
|
|
29
|
-
extractSurfaceSlug,
|
|
30
|
-
buildConfig: (options) => Effect.gen(function* () {
|
|
31
|
-
yield* validateEnvironment();
|
|
32
|
-
const secretKeyRaw = process.env.INTERFERE_SECRET_KEY;
|
|
33
|
-
const secretKeyResult = yield* validateSecretKey(secretKeyRaw ?? null).pipe(Effect.either);
|
|
34
|
-
if (secretKeyResult._tag === "Left") {
|
|
35
|
-
const message = secretKeyResult.left.message;
|
|
36
|
-
yield* logBuildResult("Warning", "Interfere disabled (invalid secret key)", [
|
|
37
|
-
message,
|
|
38
|
-
"Source maps will not be uploaded for this build.",
|
|
39
|
-
"Set a valid INTERFERE_SECRET_KEY in your environment to enable Interfere."
|
|
40
|
-
]);
|
|
41
|
-
return {
|
|
42
|
-
enabled: false,
|
|
43
|
-
environment: options.environment || process.env.NODE_ENV,
|
|
44
|
-
debug: options.debug ?? false,
|
|
45
|
-
cleanupSourceMaps: options.cleanupSourceMaps ?? true
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const secretKey = secretKeyResult.right;
|
|
49
|
-
const surfaceSlugResult = yield* extractSurfaceSlug(secretKey).pipe(Effect.either);
|
|
50
|
-
if (surfaceSlugResult._tag === "Left") {
|
|
51
|
-
const message = surfaceSlugResult.left.message;
|
|
52
|
-
yield* logBuildResult("Warning", "Interfere disabled (invalid secret key format)", [
|
|
53
|
-
message,
|
|
54
|
-
"Source maps will not be uploaded for this build.",
|
|
55
|
-
"Please use the secret key provided in your Interfere dashboard."
|
|
56
|
-
]);
|
|
57
|
-
return {
|
|
58
|
-
enabled: false,
|
|
59
|
-
environment: options.environment || process.env.NODE_ENV,
|
|
60
|
-
debug: options.debug ?? false,
|
|
61
|
-
cleanupSourceMaps: options.cleanupSourceMaps ?? true
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
enabled: true,
|
|
66
|
-
surface: surfaceSlugResult.right,
|
|
67
|
-
secretKey,
|
|
68
|
-
environment: options.environment || process.env.NODE_ENV,
|
|
69
|
-
debug: options.debug ?? false,
|
|
70
|
-
cleanupSourceMaps: options.cleanupSourceMaps ?? true
|
|
71
|
-
};
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
export { PreflightService, PreflightServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.service.mjs","names":[],"sources":["../../../src/build/services/preflight.service.ts"],"sourcesContent":["import { Context, Effect, Layer } from \"effect\";\nimport {\n type NonEmptyString,\n type PreflightConfig,\n toNonEmptyString,\n} from \"../../lib/types.js\";\nimport { logBuildResult } from \"../logger.js\";\nimport { parseSurfaceSlugFromSecretKey } from \"../secret-key.js\";\nimport {\n InvalidSecretKeyError,\n WithInterfereUsageError,\n} from \"../source-maps/errors.js\";\n\nexport class PreflightService extends Context.Tag(\"PreflightService\")<\n PreflightService,\n {\n readonly validateEnvironment: () => Effect.Effect<void, WithInterfereUsageError>;\n readonly validateSecretKey: (key: string | null) => Effect.Effect<NonEmptyString, InvalidSecretKeyError>;\n readonly extractSurfaceSlug: (key: NonEmptyString) => Effect.Effect<NonEmptyString, InvalidSecretKeyError>;\n readonly buildConfig: (options: {\n environment?: string;\n debug?: boolean;\n cleanupSourceMaps?: boolean;\n }) => Effect.Effect<PreflightConfig, WithInterfereUsageError>;\n }\n>() {}\n\nconst validateEnvironment = () =>\n Effect.gen(function* () {\n if (typeof window !== \"undefined\") {\n return yield* Effect.fail(\n new WithInterfereUsageError({\n message: \"Security Error: withInterfere must only be used in next.config.js (server-side). It should never be imported in client-side code.\"\n })\n );\n }\n\n if (typeof process === \"undefined\" || !process.versions?.node) {\n return yield* Effect.fail(\n new WithInterfereUsageError({\n message: \"Security Error: withInterfere requires Node.js environment. It should only run during build time, not in the browser.\"\n })\n );\n }\n\n if (\n typeof process.env.INTERFERE_SECRET_KEY === \"string\" &&\n process.env.INTERFERE_SECRET_KEY.startsWith(\"NEXT_PUBLIC_\")\n ) {\n return yield* Effect.fail(\n new WithInterfereUsageError({\n message: \"Security Error: Secret key should NOT use NEXT_PUBLIC_ prefix. Use INTERFERE_SECRET_KEY instead to keep it server-side only.\"\n })\n );\n }\n });\n\nconst validateSecretKey = (raw: string | null) =>\n Effect.gen(function* () {\n if (typeof raw !== \"string\") {\n return yield* Effect.fail(\n new InvalidSecretKeyError(\n { message: \"Missing secret key. Set the INTERFERE_SECRET_KEY environment variable\" }\n )\n );\n }\n\n const trimmed = raw.trim();\n const cleaned = trimmed.replace(/^['\"]|['\"]$/g, \"\");\n const result = toNonEmptyString(cleaned);\n\n if (!result) {\n return yield* Effect.fail(\n new InvalidSecretKeyError(\n { message: \"Invalid secret key. Set the INTERFERE_SECRET_KEY environment variable\" }\n )\n );\n }\n\n return result;\n });\n\nconst extractSurfaceSlug = (secretKey: NonEmptyString) =>\n Effect.gen(function* () {\n const parsed = parseSurfaceSlugFromSecretKey(secretKey);\n const result = parsed ? (toNonEmptyString(parsed) as NonEmptyString) : undefined;\n\n if (!result) {\n return yield* Effect.fail(\n new InvalidSecretKeyError(\n { message: \"Invalid secret key format. Please use the secret key provided in your Interfere dashboard.\" }\n )\n );\n }\n\n return result;\n });\n\nexport const PreflightServiceLive = Layer.succeed(\n PreflightService,\n {\n validateEnvironment,\n validateSecretKey,\n extractSurfaceSlug,\n buildConfig: (options) =>\n Effect.gen(function* () {\n yield* validateEnvironment();\n \n const secretKeyRaw = process.env.INTERFERE_SECRET_KEY;\n \n // Try to get secret key and surface slug\n const secretKeyResult = yield* validateSecretKey(\n secretKeyRaw ?? null\n ).pipe(Effect.either);\n\n if (secretKeyResult._tag === \"Left\") {\n const message = secretKeyResult.left.message;\n\n yield* logBuildResult(\n \"Warning\",\n \"Interfere disabled (invalid secret key)\",\n [\n message,\n \"Source maps will not be uploaded for this build.\",\n \"Set a valid INTERFERE_SECRET_KEY in your environment to enable Interfere.\",\n ]\n );\n\n // Return disabled config if no valid secret key\n return {\n enabled: false as const,\n environment: options.environment || process.env.NODE_ENV,\n debug: options.debug ?? false,\n cleanupSourceMaps: options.cleanupSourceMaps ?? true,\n };\n }\n \n const secretKey = secretKeyResult.right;\n const surfaceSlugResult = yield* extractSurfaceSlug(secretKey).pipe(\n Effect.either\n );\n\n if (surfaceSlugResult._tag === \"Left\") {\n const message = surfaceSlugResult.left.message;\n\n yield* logBuildResult(\n \"Warning\",\n \"Interfere disabled (invalid secret key format)\",\n [\n message,\n \"Source maps will not be uploaded for this build.\",\n \"Please use the secret key provided in your Interfere dashboard.\",\n ]\n );\n\n // Return disabled config if no valid surface slug\n return {\n enabled: false as const,\n environment: options.environment || process.env.NODE_ENV,\n debug: options.debug ?? false,\n cleanupSourceMaps: options.cleanupSourceMaps ?? true,\n };\n }\n\n return {\n enabled: true as const,\n surface: surfaceSlugResult.right,\n secretKey,\n environment: options.environment || process.env.NODE_ENV,\n debug: options.debug ?? false,\n cleanupSourceMaps: options.cleanupSourceMaps ?? true,\n };\n }),\n }\n);\n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,gBAAgB,KACjB,CAAC,KAAK,OAAO,OAAO;AAErB,MAAI,gBAAgB,SAAS,QAAQ;GACnC,MAAM,UAAU,gBAAgB,KAAK;AAErC,UAAO,eACL,WACA,2CACA;IACE;IACA;IACA;IACD,CACF;AAGD,UAAO;IACL,SAAS;IACT,aAAa,QAAQ,eAAe,QAAQ,IAAI;IAChD,OAAO,QAAQ,SAAS;IACxB,mBAAmB,QAAQ,qBAAqB;IACjD;;EAGH,MAAM,YAAY,gBAAgB;EAClC,MAAM,oBAAoB,OAAO,mBAAmB,UAAU,CAAC,KAC7D,OAAO,OACR;AAED,MAAI,kBAAkB,SAAS,QAAQ;GACrC,MAAM,UAAU,kBAAkB,KAAK;AAEvC,UAAO,eACL,WACA,kDACA;IACE;IACA;IACA;IACD,CACF;AAGD,UAAO;IACL,SAAS;IACT,aAAa,QAAQ,eAAe,QAAQ,IAAI;IAChD,OAAO,QAAQ,SAAS;IACxB,mBAAmB,QAAQ,qBAAqB;IACjD;;AAGH,SAAO;GACL,SAAS;GACT,SAAS,kBAAkB;GAC3B;GACA,aAAa,QAAQ,eAAe,QAAQ,IAAI;GAChD,OAAO,QAAQ,SAAS;GACxB,mBAAmB,QAAQ,qBAAqB;GACjD;GACD;CACL,CACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { MissingBuildIdError, MissingReleaseIdError } from "../source-maps/errors.mjs";
|
|
2
|
-
import { Context, Effect, Layer } from "effect";
|
|
3
|
-
import { ReleaseDestinationMetadata, ReleaseDestinationType, ReleaseSourceMetadata, ReleaseSourceType } from "@interfere/types/releases/definition";
|
|
4
|
-
|
|
5
|
-
//#region src/build/services/release-identity.service.d.ts
|
|
6
|
-
type ReleaseIdentity = {
|
|
7
|
-
buildId: string;
|
|
8
|
-
releaseId: string;
|
|
9
|
-
sourceControl?: {
|
|
10
|
-
type: ReleaseSourceType;
|
|
11
|
-
metadata: ReleaseSourceMetadata;
|
|
12
|
-
};
|
|
13
|
-
deployment?: {
|
|
14
|
-
type: ReleaseDestinationType;
|
|
15
|
-
metadata: ReleaseDestinationMetadata;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
declare const ReleaseIdentityService_base: Context.TagClass<ReleaseIdentityService, "ReleaseIdentityService", Effect.Effect<ReleaseIdentity, MissingBuildIdError | MissingReleaseIdError, never>>;
|
|
19
|
-
declare class ReleaseIdentityService extends ReleaseIdentityService_base {}
|
|
20
|
-
declare const ReleaseIdentityServiceLive: Layer.Layer<ReleaseIdentityService, never, never>;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { ReleaseIdentity, ReleaseIdentityService, ReleaseIdentityServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release-identity.service.d.mts","names":[],"sources":["../../../src/build/services/release-identity.service.ts"],"sourcesContent":[],"mappings":";;;;;KAUY,eAAA;;EAAA,SAAA,EAAA,MAAA;EAIF,aAAA,CAAA,EAAA;IACI,IAAA,EADJ,iBACI;IAGJ,QAAA,EAHI,qBAGJ;EACI,CAAA;EAA0B,UAAA,CAAA,EAAA;IAEtC,IAAA,EAHQ,sBAGR;cAFY;;;cAEZ;cAEW,sBAAA,SAA+B,2BAAA;cAoG/B,4BAA0B,KAAA,CAAA,MAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { getEnvBuildId, getEnvReleaseId } from "../../lib/env.mjs";
|
|
2
|
-
import { MissingBuildIdError, MissingReleaseIdError } from "../source-maps/errors.mjs";
|
|
3
|
-
import { detectDeployment } from "../source-maps/providers/deployment/detector.mjs";
|
|
4
|
-
import { detectSourceControl } from "../source-maps/providers/source-control/detector.mjs";
|
|
5
|
-
import { Context, Effect, Layer, Option } from "effect";
|
|
6
|
-
|
|
7
|
-
//#region src/build/services/release-identity.service.ts
|
|
8
|
-
var ReleaseIdentityService = class extends Context.Tag("ReleaseIdentityService")() {};
|
|
9
|
-
const makeReleaseIdentity = Effect.gen(function* () {
|
|
10
|
-
const envBuildId = getEnvBuildId();
|
|
11
|
-
const envReleaseId = getEnvReleaseId();
|
|
12
|
-
const deploymentOpt = yield* detectDeployment().pipe(Effect.option);
|
|
13
|
-
const sourceControlOpt = yield* detectSourceControl().pipe(Effect.option);
|
|
14
|
-
const deployment = Option.getOrUndefined(deploymentOpt);
|
|
15
|
-
const sourceControl = Option.getOrUndefined(sourceControlOpt);
|
|
16
|
-
let buildId = envBuildId ?? void 0;
|
|
17
|
-
let releaseId = envReleaseId ?? void 0;
|
|
18
|
-
if (!buildId && deployment && "deployment" in deployment.metadata) {
|
|
19
|
-
const deploymentId = deployment.metadata.deployment?.id ?? void 0;
|
|
20
|
-
if (deploymentId) buildId = deploymentId;
|
|
21
|
-
}
|
|
22
|
-
if (!buildId && sourceControl && "gitCommitSha" in sourceControl.metadata) {
|
|
23
|
-
const sha = sourceControl.metadata.gitCommitSha;
|
|
24
|
-
if (sha) buildId = sha;
|
|
25
|
-
}
|
|
26
|
-
if (!releaseId && sourceControl && "gitCommitSha" in sourceControl.metadata) {
|
|
27
|
-
const sha = sourceControl.metadata.gitCommitSha;
|
|
28
|
-
if (sha) releaseId = sha;
|
|
29
|
-
}
|
|
30
|
-
if (!releaseId && deployment && "deployment" in deployment.metadata) {
|
|
31
|
-
const deploymentId = deployment.metadata.deployment?.id ?? void 0;
|
|
32
|
-
if (deploymentId) releaseId = deploymentId;
|
|
33
|
-
}
|
|
34
|
-
if (!releaseId && buildId) releaseId = buildId;
|
|
35
|
-
if (!buildId && !releaseId) return yield* Effect.fail(new MissingBuildIdError({ message: "Couldn't determine build ID (no deployment provider, git, or env vars found)" }));
|
|
36
|
-
if (!buildId) return yield* Effect.fail(new MissingBuildIdError({ message: "Couldn't determine build ID (tried NEXT_PUBLIC_INTERFERE_BUILD_ID, NEXT_BUILD_ID, deployment metadata, and git)" }));
|
|
37
|
-
if (!releaseId) return yield* Effect.fail(new MissingReleaseIdError({ message: "Couldn't determine release ID (tried NEXT_PUBLIC_INTERFERE_RELEASE_ID, deployment metadata, and git)" }));
|
|
38
|
-
return {
|
|
39
|
-
buildId,
|
|
40
|
-
releaseId,
|
|
41
|
-
sourceControl,
|
|
42
|
-
deployment
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
const ReleaseIdentityServiceLive = Layer.succeed(ReleaseIdentityService, makeReleaseIdentity);
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { ReleaseIdentityService, ReleaseIdentityServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release-identity.service.mjs","names":[],"sources":["../../../src/build/services/release-identity.service.ts"],"sourcesContent":["import type { ReleaseDestinationMetadata, ReleaseDestinationType, ReleaseSourceMetadata, ReleaseSourceType } from \"@interfere/types/releases/definition\";\nimport { Context, Effect, Layer, Option } from \"effect\";\nimport { getEnvBuildId, getEnvReleaseId } from \"../../lib/env.js\";\nimport {\n MissingBuildIdError,\n MissingReleaseIdError,\n} from \"../source-maps/errors.js\";\nimport { detectDeployment } from \"../source-maps/providers/deployment/detector.js\";\nimport { detectSourceControl } from \"../source-maps/providers/source-control/detector.js\";\n\nexport type ReleaseIdentity = {\n buildId: string;\n releaseId: string;\n sourceControl?: {\n type: ReleaseSourceType;\n metadata: ReleaseSourceMetadata;\n };\n deployment?: {\n type: ReleaseDestinationType;\n metadata: ReleaseDestinationMetadata;\n };\n};\n\nexport class ReleaseIdentityService extends Context.Tag(\"ReleaseIdentityService\")<\n ReleaseIdentityService,\n Effect.Effect<ReleaseIdentity, MissingBuildIdError | MissingReleaseIdError>\n>() {}\n\nconst makeReleaseIdentity = Effect.gen(function* () {\n // Read explicitly configured IDs if present\n const envBuildId = getEnvBuildId();\n const envReleaseId = getEnvReleaseId();\n\n // Detect deployment and source control once and reuse\n const deploymentOpt = yield* detectDeployment().pipe(Effect.option);\n const sourceControlOpt = yield* detectSourceControl().pipe(Effect.option);\n\n const deployment = Option.getOrUndefined(deploymentOpt);\n const sourceControl = Option.getOrUndefined(sourceControlOpt);\n\n // Start with env-provided IDs (if any), then fill gaps from metadata\n let buildId = envBuildId ?? undefined;\n let releaseId = envReleaseId ?? undefined;\n\n // Try to get IDs from deployment metadata (Vercel, etc.)\n if (!buildId && deployment && \"deployment\" in deployment.metadata) {\n const deploymentId = deployment.metadata.deployment?.id ?? undefined;\n\n if (deploymentId) {\n buildId = deploymentId;\n }\n }\n\n // Try to get IDs from source control metadata (git)\n if (!buildId && sourceControl && \"gitCommitSha\" in sourceControl.metadata) {\n const sha = sourceControl.metadata.gitCommitSha;\n\n if (sha) {\n buildId = sha;\n }\n }\n\n // Prefer git SHA for releaseId if available\n if (!releaseId && sourceControl && \"gitCommitSha\" in sourceControl.metadata) {\n const sha = sourceControl.metadata.gitCommitSha;\n\n if (sha) {\n releaseId = sha;\n }\n }\n\n // Otherwise fall back to deployment id\n if (!releaseId && deployment && \"deployment\" in deployment.metadata) {\n const deploymentId = deployment.metadata.deployment?.id ?? undefined;\n\n if (deploymentId) {\n releaseId = deploymentId;\n }\n }\n\n // Fall back to buildId for releaseId if we still don't have one\n if (!releaseId && buildId) {\n releaseId = buildId;\n }\n\n // Error if we couldn't determine both IDs\n if (!buildId && !releaseId) {\n return yield* Effect.fail(\n new MissingBuildIdError({\n message:\n \"Couldn't determine build ID (no deployment provider, git, or env vars found)\",\n })\n );\n }\n\n if (!buildId) {\n return yield* Effect.fail(\n new MissingBuildIdError({\n message:\n \"Couldn't determine build ID (tried NEXT_PUBLIC_INTERFERE_BUILD_ID, NEXT_BUILD_ID, deployment metadata, and git)\",\n })\n );\n }\n\n if (!releaseId) {\n return yield* Effect.fail(\n new MissingReleaseIdError({\n message:\n \"Couldn't determine release ID (tried NEXT_PUBLIC_INTERFERE_RELEASE_ID, deployment metadata, and git)\",\n })\n );\n }\n\n const result: ReleaseIdentity = {\n buildId,\n releaseId,\n sourceControl,\n deployment,\n };\n\n return result;\n});\n\nexport const ReleaseIdentityServiceLive = Layer.succeed(\n ReleaseIdentityService,\n makeReleaseIdentity\n);"],"mappings":";;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MAAa,6BAA6B,MAAM,QAC9C,wBACA,oBACD"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from "./config.service.mjs";
|
|
2
|
-
import { FileDeleteError, FileGlobError, FileHashError, FileReadError, InvalidApiUrlError, UploadError } from "../source-maps/errors.mjs";
|
|
3
|
-
import { Context, Effect, Layer } from "effect";
|
|
4
|
-
import { UploadedSourceMap } from "@interfere/types/data/source-maps";
|
|
5
|
-
|
|
6
|
-
//#region src/build/services/source-map.service.d.ts
|
|
7
|
-
type UploadMeta = {
|
|
8
|
-
apiUrl: string;
|
|
9
|
-
orgId: string;
|
|
10
|
-
sourceId: string;
|
|
11
|
-
surfaceId: number;
|
|
12
|
-
environment: string;
|
|
13
|
-
releaseSlug: string;
|
|
14
|
-
};
|
|
15
|
-
declare const SourceMapService_base: Context.TagClass<SourceMapService, "SourceMapService", {
|
|
16
|
-
readonly find: Effect.Effect<string[], FileGlobError>;
|
|
17
|
-
readonly read: (files: string[]) => Effect.Effect<UploadedSourceMap[], FileReadError | FileHashError>;
|
|
18
|
-
readonly upload: (sourceMaps: UploadedSourceMap[], meta: UploadMeta) => Effect.Effect<void, UploadError | InvalidApiUrlError>;
|
|
19
|
-
readonly cleanup: (files: string[], debug: boolean) => Effect.Effect<void, FileDeleteError>;
|
|
20
|
-
}>;
|
|
21
|
-
declare class SourceMapService extends SourceMapService_base {}
|
|
22
|
-
declare const SourceMapServiceLive: Layer.Layer<SourceMapService, never, ConfigService>;
|
|
23
|
-
//#endregion
|
|
24
|
-
export { SourceMapService, SourceMapServiceLive, UploadMeta };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-map.service.d.mts","names":[],"sources":["../../../src/build/services/source-map.service.ts"],"sourcesContent":[],"mappings":";;;;;;KAuBY,UAAA;;EAAA,KAAA,EAAA,MAAU;EAOpB,QAAA,EAAA,MAAA;;EAMyC,WAAA,EAAA,MAAA;EAAxB,WAAO,EAAA,MAAA;CAIH;cAVrB,qBAU0C,kBAAA,iBAAA,EAAA,kBAAA,EAAA;EAAgB,SAAA,IAAA,EAJzC,MAAA,CAAO,MAIkC,CAAA,MAAA,EAAA,EAJjB,aAIiB,CAAA;EAAnD,SAAO,IAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,EAAA,GAAP,MAAA,CAAO,MAAA,CAAO,iBAAP,EAAA,EAA4B,aAA5B,GAA4C,aAA5C,CAAA;EAGE,SAAA,MAAA,EAAA,CAAA,UAAA,EAAA,iBAAA,EAAA,EAAA,IAAA,EACN,UADM,EAAA,GAET,MAAA,CAAO,MAFE,CAAA,IAAA,EAEW,WAFX,GAEyB,kBAFzB,CAAA;EACN,SAAA,OAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,OAAA,EAAA,GAMH,MAAA,CAAO,MANJ,CAAA,IAAA,EAMiB,eANjB,CAAA;CACiB,CAAA;AAAc,cAZ9B,gBAAA,SAAyB,qBAAA,CAYK;AAKd,cAIhB,oBAJgB,EAII,KAAA,CAAA,KAJJ,CAII,gBAJJ,EAAA,KAAA,EAII,aAJJ,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { appendBuildLogLine, logBuildResult } from "../logger.mjs";
|
|
2
|
-
import { ConfigService } from "./config.service.mjs";
|
|
3
|
-
import { UploadError } from "../source-maps/errors.mjs";
|
|
4
|
-
import { uploadSourceMaps } from "../source-maps/api.mjs";
|
|
5
|
-
import { buildSourceMapToGeneratedMapping, cleanupSourceMaps, findGeneratedJsFiles, findSourceMapFiles, readSourceMapsFromFiles } from "../source-maps/files.mjs";
|
|
6
|
-
import { Context, Effect, Layer } from "effect";
|
|
7
|
-
|
|
8
|
-
//#region src/build/services/source-map.service.ts
|
|
9
|
-
var SourceMapService = class extends Context.Tag("SourceMapService")() {};
|
|
10
|
-
const SourceMapServiceLive = Layer.effect(SourceMapService, Effect.gen(function* () {
|
|
11
|
-
const config = yield* ConfigService;
|
|
12
|
-
return {
|
|
13
|
-
find: Effect.gen(function* () {
|
|
14
|
-
return yield* findSourceMapFiles();
|
|
15
|
-
}),
|
|
16
|
-
read: (files) => readSourceMapsFromFiles(files),
|
|
17
|
-
upload: (sourceMaps, meta) => Effect.gen(function* () {
|
|
18
|
-
const sourceMapToGenerated = yield* buildSourceMapToGeneratedMapping(yield* findGeneratedJsFiles().pipe(Effect.mapError((error) => {
|
|
19
|
-
return new UploadError({
|
|
20
|
-
message: `Failed to find generated JS files: ${error.message}`,
|
|
21
|
-
file: "js-files",
|
|
22
|
-
cause: error
|
|
23
|
-
});
|
|
24
|
-
}))).pipe(Effect.mapError((error) => {
|
|
25
|
-
if (error._tag === "FileReadError") return new UploadError({
|
|
26
|
-
message: `Failed to read JS file: ${error.message}`,
|
|
27
|
-
file: error.path,
|
|
28
|
-
cause: error
|
|
29
|
-
});
|
|
30
|
-
return new UploadError({
|
|
31
|
-
message: `Failed to read JS files: ${String(error)}`,
|
|
32
|
-
file: "js-files",
|
|
33
|
-
cause: error
|
|
34
|
-
});
|
|
35
|
-
}));
|
|
36
|
-
const totalMb = (sourceMaps.reduce((sum, sm) => sum + sm.content.length, 0) / 1024 / 1024).toFixed(2);
|
|
37
|
-
yield* appendBuildLogLine(`Uploading ${sourceMaps.length} source map(s) in parallel (${totalMb} MB total)`);
|
|
38
|
-
const result = yield* uploadSourceMaps(sourceMaps, sourceMapToGenerated, config, meta).pipe(Effect.mapError((error) => {
|
|
39
|
-
if (error._tag === "TokenRequestError") return new UploadError({
|
|
40
|
-
message: "Failed to request upload token",
|
|
41
|
-
file: "batch",
|
|
42
|
-
cause: error
|
|
43
|
-
});
|
|
44
|
-
if (error._tag === "NotificationError") return new UploadError({
|
|
45
|
-
message: "Failed to notify upload completion",
|
|
46
|
-
file: "batch",
|
|
47
|
-
cause: error
|
|
48
|
-
});
|
|
49
|
-
return error;
|
|
50
|
-
}));
|
|
51
|
-
yield* logBuildResult("Info", "Source map upload complete", [`${result.uploaded} source map${result.uploaded === 1 ? "" : "s"} uploaded successfully`]);
|
|
52
|
-
}),
|
|
53
|
-
cleanup: (files, debug) => config.cleanupSourceMaps !== false ? cleanupSourceMaps(files, debug) : Effect.void
|
|
54
|
-
};
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { SourceMapService, SourceMapServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-map.service.mjs","names":[],"sources":["../../../src/build/services/source-map.service.ts"],"sourcesContent":["import type { UploadedSourceMap } from \"@interfere/types/data/source-maps\";\nimport { Context, Effect, Layer } from \"effect\";\nimport { appendBuildLogLine, logBuildResult } from \"../logger.js\";\nimport {\n uploadSourceMaps,\n} from \"../source-maps/api.js\";\nimport {\n FileDeleteError,\n FileGlobError,\n FileHashError,\n FileReadError,\n InvalidApiUrlError,\n UploadError,\n} from \"../source-maps/errors.js\";\nimport {\n buildSourceMapToGeneratedMapping,\n cleanupSourceMaps,\n findGeneratedJsFiles,\n findSourceMapFiles,\n readSourceMapsFromFiles,\n} from \"../source-maps/files.js\";\nimport { ConfigService } from \"./config.service.js\";\n\nexport type UploadMeta = {\n apiUrl: string;\n orgId: string;\n sourceId: string;\n surfaceId: number;\n environment: string;\n releaseSlug: string;\n};\n\n\nexport class SourceMapService extends Context.Tag(\"SourceMapService\")<\n SourceMapService,\n {\n readonly find: Effect.Effect<string[], FileGlobError>;\n\n readonly read: (\n files: string[]\n ) => Effect.Effect<UploadedSourceMap[], FileReadError | FileHashError>;\n\n readonly upload: (\n sourceMaps: UploadedSourceMap[],\n meta: UploadMeta\n ) => Effect.Effect<void, UploadError | InvalidApiUrlError>;\n\n readonly cleanup: (\n files: string[],\n debug: boolean\n ) => Effect.Effect<void, FileDeleteError>;\n }\n>() {}\n\nexport const SourceMapServiceLive = Layer.effect(\n SourceMapService,\n Effect.gen(function* () {\n const config = yield* ConfigService;\n\n return {\n // Lazily evaluate file discovery so that simply constructing the layer\n // (e.g. in tests or early‑exit paths) does not trigger any filesystem work.\n find: Effect.gen(function* () {\n return yield* findSourceMapFiles();\n }),\n \n read: (files: string[]) => readSourceMapsFromFiles(files),\n \n upload: (\n sourceMaps: UploadedSourceMap[],\n meta: UploadMeta\n ) =>\n Effect.gen(function* () {\n // Find and read generated JS files to extract sourceMappingURL mapping\n const jsFilePaths = yield* findGeneratedJsFiles().pipe(\n Effect.mapError((error) => {\n return new UploadError({\n message: `Failed to find generated JS files: ${error.message}`,\n file: \"js-files\",\n cause: error,\n });\n })\n );\n\n // Build mapping from source map filename to generated JS file path\n const sourceMapToGenerated = yield* buildSourceMapToGeneratedMapping(jsFilePaths).pipe(\n Effect.mapError((error) => {\n if (error._tag === \"FileReadError\") {\n return new UploadError({\n message: `Failed to read JS file: ${error.message}`,\n file: error.path,\n cause: error,\n });\n }\n return new UploadError({\n message: `Failed to read JS files: ${String(error)}`,\n file: \"js-files\",\n cause: error,\n });\n })\n );\n\n // Calculate total bytes for logging (only source maps, not JS files)\n const sourceMapBytes = sourceMaps.reduce(\n (sum, sm) => sum + sm.content.length,\n 0\n );\n const totalMb = (sourceMapBytes / 1024 / 1024).toFixed(2);\n\n yield* appendBuildLogLine(\n `Uploading ${sourceMaps.length} source map(s) in parallel (${totalMb} MB total)`\n );\n\n const result = yield* uploadSourceMaps(\n sourceMaps,\n sourceMapToGenerated,\n config,\n meta\n ).pipe(\n Effect.mapError((error) => {\n if (error._tag === \"TokenRequestError\") {\n return new UploadError({\n message: \"Failed to request upload token\",\n file: \"batch\",\n cause: error,\n });\n }\n\n if (error._tag === \"NotificationError\") {\n return new UploadError({\n message: \"Failed to notify upload completion\",\n file: \"batch\",\n cause: error,\n });\n }\n\n return error;\n })\n );\n\n yield* logBuildResult(\"Info\", \"Source map upload complete\", [\n `${result.uploaded} source map${\n result.uploaded === 1 ? \"\" : \"s\"\n } uploaded successfully`,\n ]);\n }),\n \n cleanup: (files: string[], debug: boolean) =>\n config.cleanupSourceMaps !== false\n ? cleanupSourceMaps(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