@interfere/next 0.1.0-alpha.11 → 0.1.0-alpha.2
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 -305
- package/dist/_virtual/_rolldown/runtime.mjs +11 -5
- package/dist/config.d.mts +11 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +116 -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/logger.d.mts +8 -0
- package/dist/internal/build/logger.d.mts.map +1 -0
- package/dist/internal/build/logger.mjs +44 -0
- package/dist/internal/build/logger.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 +26 -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 +15 -0
- package/dist/internal/env.d.mts.map +1 -0
- package/dist/internal/env.mjs +18 -0
- package/dist/internal/env.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 +12 -0
- package/dist/internal/server/transport.d.mts.map +1 -0
- package/dist/internal/server/transport.mjs +17 -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 +52 -84
- package/LICENSE +0 -21
- package/dist/build/env-config.d.mts +0 -9
- package/dist/build/env-config.d.mts.map +0 -1
- package/dist/build/env-config.mjs +0 -25
- package/dist/build/env-config.mjs.map +0 -1
- package/dist/build/exchange-surface.d.mts +0 -9
- package/dist/build/exchange-surface.d.mts.map +0 -1
- package/dist/build/exchange-surface.mjs +0 -36
- package/dist/build/exchange-surface.mjs.map +0 -1
- package/dist/build/loaders/value-injection-loader.d.mts +0 -22
- package/dist/build/loaders/value-injection-loader.d.mts.map +0 -1
- package/dist/build/loaders/value-injection-loader.mjs +0 -35
- 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 -153
- package/dist/build/logger.mjs.map +0 -1
- package/dist/build/nextjs-version.d.mts +0 -40
- package/dist/build/nextjs-version.d.mts.map +0 -1
- package/dist/build/nextjs-version.mjs +0 -66
- package/dist/build/nextjs-version.mjs.map +0 -1
- package/dist/build/release-program.d.mts +0 -21
- package/dist/build/release-program.d.mts.map +0 -1
- package/dist/build/release-program.mjs +0 -91
- package/dist/build/release-program.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 -19
- package/dist/build/services/instrumentation-detection.service.d.mts.map +0 -1
- package/dist/build/services/instrumentation-detection.service.mjs +0 -77
- package/dist/build/services/instrumentation-detection.service.mjs.map +0 -1
- package/dist/build/services/preflight.service.d.mts +0 -18
- package/dist/build/services/preflight.service.d.mts.map +0 -1
- package/dist/build/services/preflight.service.mjs +0 -67
- package/dist/build/services/preflight.service.mjs.map +0 -1
- package/dist/build/services/release-api.service.d.mts +0 -11
- package/dist/build/services/release-api.service.d.mts.map +0 -1
- package/dist/build/services/release-api.service.mjs +0 -9
- package/dist/build/services/release-api.service.mjs.map +0 -1
- package/dist/build/services/release-identity.service.d.mts +0 -23
- package/dist/build/services/release-identity.service.d.mts.map +0 -1
- package/dist/build/services/release-identity.service.mjs +0 -61
- package/dist/build/services/release-identity.service.mjs.map +0 -1
- package/dist/build/services/source-map-failure-cleanup.service.d.mts +0 -11
- package/dist/build/services/source-map-failure-cleanup.service.d.mts.map +0 -1
- package/dist/build/services/source-map-failure-cleanup.service.mjs +0 -9
- package/dist/build/services/source-map-failure-cleanup.service.mjs.map +0 -1
- package/dist/build/services/source-map.service.d.mts +0 -20
- package/dist/build/services/source-map.service.d.mts.map +0 -1
- package/dist/build/services/source-map.service.mjs +0 -56
- package/dist/build/services/source-map.service.mjs.map +0 -1
- package/dist/build/source-maps/api.d.mts +0 -44
- package/dist/build/source-maps/api.d.mts.map +0 -1
- package/dist/build/source-maps/api.mjs +0 -64
- package/dist/build/source-maps/api.mjs.map +0 -1
- package/dist/build/source-maps/client.d.mts +0 -82
- package/dist/build/source-maps/client.d.mts.map +0 -1
- package/dist/build/source-maps/client.mjs +0 -239
- package/dist/build/source-maps/client.mjs.map +0 -1
- package/dist/build/source-maps/errors.d.mts +0 -121
- package/dist/build/source-maps/errors.d.mts.map +0 -1
- package/dist/build/source-maps/errors.mjs +0 -46
- 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 -220
- package/dist/build/source-maps/files.mjs.map +0 -1
- package/dist/build/source-maps/providers/deployment/detector.d.mts +0 -17
- package/dist/build/source-maps/providers/deployment/detector.d.mts.map +0 -1
- package/dist/build/source-maps/providers/deployment/detector.mjs +0 -20
- 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 -33
- package/dist/build/source-maps/providers/deployment/vercel.mjs.map +0 -1
- package/dist/build/source-maps/providers/source-control/detector.d.mts +0 -16
- 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 -20
- 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 -47
- 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 -14
- 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 -182
- package/dist/build/with-interfere.mjs.map +0 -1
- package/dist/client/auto-init.d.mts +0 -91
- 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/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/auto-init.d.mts +0 -88
- package/dist/server/auto-init.d.mts.map +0 -1
- package/dist/server/auto-init.mjs +0 -101
- package/dist/server/auto-init.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 -92
- package/dist/server/middleware.mjs.map +0 -1
- package/dist/server/on-request-error.d.mts +0 -27
- package/dist/server/on-request-error.d.mts.map +0 -1
- package/dist/server/on-request-error.mjs +0 -74
- package/dist/server/on-request-error.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 -29
- package/dist/server/proxy.mjs.map +0 -1
- package/dist/server/route-handler.d.mts +0 -39
- package/dist/server/route-handler.d.mts.map +0 -1
- package/dist/server/route-handler.mjs +0 -171
- package/dist/server/route-handler.mjs.map +0 -1
- package/dist/server/sdk.d.mts +0 -96
- package/dist/server/sdk.d.mts.map +0 -1
- package/dist/server/sdk.mjs +0 -152
- package/dist/server/sdk.mjs.map +0 -1
- package/dist/server/services/config.service.d.mts +0 -48
- package/dist/server/services/config.service.d.mts.map +0 -1
- package/dist/server/services/config.service.mjs +0 -67
- 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 -33
- package/dist/server/services/error-tracking.service.mjs.map +0 -1
- package/dist/server/session-context.d.mts +0 -60
- package/dist/server/session-context.d.mts.map +0 -1
- package/dist/server/session-context.mjs +0 -62
- package/dist/server/session-context.mjs.map +0 -1
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { toNonEmptyString } from "../../lib/types.mjs";
|
|
2
|
-
import { normalizeApiKey, resolveApiUrl } from "../env-config.mjs";
|
|
3
|
-
import { fetchSurfaceSlugFromExchange } from "../exchange-surface.mjs";
|
|
4
|
-
import { logBuildResult } from "../logger.mjs";
|
|
5
|
-
import { ExchangeFailedError, MissingApiKeyError, WithInterfereUsageError } from "../source-maps/errors.mjs";
|
|
6
|
-
import { Context, Effect, Layer } from "effect";
|
|
7
|
-
|
|
8
|
-
//#region src/build/services/preflight.service.ts
|
|
9
|
-
var PreflightService = class extends Context.Tag("PreflightService")() {};
|
|
10
|
-
const validateEnvironment = Effect.fn("validateEnvironment")(function* () {
|
|
11
|
-
if (typeof window !== "undefined") return yield* 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." });
|
|
12
|
-
if (typeof process === "undefined" || !process.versions?.node) return yield* new WithInterfereUsageError({ message: "Security Error: withInterfere requires Node.js environment. It should only run during build time, not in the browser." });
|
|
13
|
-
if (typeof process.env.INTERFERE_API_KEY === "string" && process.env.INTERFERE_API_KEY.startsWith("NEXT_PUBLIC_")) return yield* new WithInterfereUsageError({ message: "Security Error: API key should NOT use NEXT_PUBLIC_ prefix. Use INTERFERE_API_KEY instead to keep it server-side only." });
|
|
14
|
-
});
|
|
15
|
-
const validateApiKey = Effect.fn("validateApiKey")(function* (_raw) {
|
|
16
|
-
const result = normalizeApiKey(process.env.INTERFERE_API_KEY);
|
|
17
|
-
if (!result) return yield* new MissingApiKeyError({ message: "Missing API key. Set INTERFERE_API_KEY in your environment." });
|
|
18
|
-
return result;
|
|
19
|
-
});
|
|
20
|
-
const PreflightServiceLive = Layer.succeed(PreflightService, {
|
|
21
|
-
validateEnvironment,
|
|
22
|
-
validateApiKey,
|
|
23
|
-
buildConfig: Effect.fn("buildConfig")(function* (options) {
|
|
24
|
-
yield* validateEnvironment();
|
|
25
|
-
const apiKeyResult = yield* validateApiKey(null).pipe(Effect.either);
|
|
26
|
-
if (apiKeyResult._tag === "Left") {
|
|
27
|
-
yield* logBuildResult("Warning", "Interfere disabled (missing API key)", [
|
|
28
|
-
apiKeyResult.left.message,
|
|
29
|
-
"Source maps will not be uploaded for this build.",
|
|
30
|
-
"Set INTERFERE_API_KEY in your environment to enable Interfere. Ensure you are using the correct key."
|
|
31
|
-
]);
|
|
32
|
-
return {
|
|
33
|
-
enabled: false,
|
|
34
|
-
environment: options.environment || process.env.NODE_ENV,
|
|
35
|
-
debug: options.debug ?? false,
|
|
36
|
-
cleanupSourceMaps: options.cleanupSourceMaps ?? true
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const surfaceResult = yield* Effect.tryPromise({
|
|
40
|
-
try: () => fetchSurfaceSlugFromExchange(resolveApiUrl(), apiKeyResult.right),
|
|
41
|
-
catch: (cause) => new ExchangeFailedError({
|
|
42
|
-
message: "exchange failed",
|
|
43
|
-
cause
|
|
44
|
-
})
|
|
45
|
-
}).pipe(Effect.map((s) => s && s.trim() ? toNonEmptyString(s.trim()) : null), Effect.either);
|
|
46
|
-
if (surfaceResult._tag === "Left" || !surfaceResult.right) {
|
|
47
|
-
yield* logBuildResult("Warning", "Interfere disabled (exchange unreachable)", ["Could not reach the API.", "Source maps will not be uploaded for this build."]);
|
|
48
|
-
return {
|
|
49
|
-
enabled: false,
|
|
50
|
-
environment: options.environment || process.env.NODE_ENV,
|
|
51
|
-
debug: options.debug ?? false,
|
|
52
|
-
cleanupSourceMaps: options.cleanupSourceMaps ?? true
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
enabled: true,
|
|
57
|
-
surface: surfaceResult.right,
|
|
58
|
-
apiKey: apiKeyResult.right,
|
|
59
|
-
environment: options.environment || process.env.NODE_ENV,
|
|
60
|
-
debug: options.debug ?? false,
|
|
61
|
-
cleanupSourceMaps: options.cleanupSourceMaps ?? true
|
|
62
|
-
};
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
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 { fetchSurfaceSlugFromExchange } from \"../exchange-surface.js\";\nimport { logBuildResult } from \"../logger.js\";\nimport { normalizeApiKey, resolveApiUrl } from \"../env-config.js\";\nimport {\n ExchangeFailedError,\n MissingApiKeyError,\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 validateApiKey: (key: string | null) => Effect.Effect<NonEmptyString, MissingApiKeyError>;\n readonly buildConfig: (options: {\n environment?: string;\n debug?: boolean;\n cleanupSourceMaps?: boolean;\n }) => Effect.Effect<PreflightConfig, WithInterfereUsageError>;\n }\n>() {}\n\nconst validateEnvironment = Effect.fn(\"validateEnvironment\")(function* () {\n if (typeof window !== \"undefined\") {\n return yield* new WithInterfereUsageError({\n message:\n \"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 if (typeof process === \"undefined\" || !process.versions?.node) {\n return yield* new WithInterfereUsageError({\n message:\n \"Security Error: withInterfere requires Node.js environment. It should only run during build time, not in the browser.\",\n });\n }\n\n if (\n typeof process.env.INTERFERE_API_KEY === \"string\" &&\n process.env.INTERFERE_API_KEY.startsWith(\"NEXT_PUBLIC_\")\n ) {\n return yield* new WithInterfereUsageError({\n message:\n \"Security Error: API key should NOT use NEXT_PUBLIC_ prefix. Use INTERFERE_API_KEY instead to keep it server-side only.\",\n });\n }\n});\n\nconst validateApiKey = Effect.fn(\"validateApiKey\")(function* (\n _raw: string | null\n) {\n const result = normalizeApiKey(process.env.INTERFERE_API_KEY);\n\n if (!result) {\n return yield* new MissingApiKeyError({\n message: \"Missing API key. Set INTERFERE_API_KEY in your environment.\",\n });\n }\n\n return result;\n});\n\nexport const PreflightServiceLive = Layer.succeed(PreflightService, {\n validateEnvironment,\n validateApiKey,\n buildConfig: Effect.fn(\"buildConfig\")(function* (options: {\n environment?: string;\n debug?: boolean;\n cleanupSourceMaps?: boolean;\n }) {\n yield* validateEnvironment();\n\n const apiKeyResult = yield* validateApiKey(null).pipe(\n Effect.either\n );\n\n if (apiKeyResult._tag === \"Left\") {\n yield* logBuildResult(\n \"Warning\",\n \"Interfere disabled (missing API key)\",\n [\n apiKeyResult.left.message,\n \"Source maps will not be uploaded for this build.\",\n \"Set INTERFERE_API_KEY in your environment to enable Interfere. Ensure you are using the correct key.\",\n ]\n );\n\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 surfaceResult = yield* Effect.tryPromise({\n try: () =>\n fetchSurfaceSlugFromExchange(\n resolveApiUrl(),\n apiKeyResult.right\n ),\n catch: (cause) =>\n new ExchangeFailedError({ message: \"exchange failed\", cause }),\n }).pipe(\n Effect.map((s) => (s && s.trim() ? toNonEmptyString(s.trim()) : null)),\n Effect.either\n );\n\n if (surfaceResult._tag === \"Left\" || !surfaceResult.right) {\n yield* logBuildResult(\n \"Warning\",\n \"Interfere disabled (exchange unreachable)\",\n [\n \"Could not reach the API.\",\n \"Source maps will not be uploaded for this build.\",\n ]\n );\n\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: surfaceResult.right,\n apiKey: apiKeyResult.right,\n environment: options.environment || process.env.NODE_ENV,\n debug: options.debug ?? false,\n cleanupSourceMaps: options.cleanupSourceMaps ?? true,\n };\n }),\n});\n"],"mappings":";;;;;;;;AAeA,IAAa,mBAAb,cAAsC,QAAQ,IAAI,mBAAmB,EAWlE,CAAC;AAEJ,MAAM,sBAAsB,OAAO,GAAG,sBAAsB,CAAC,aAAa;AACxE,KAAI,OAAO,WAAW,YACpB,QAAO,OAAO,IAAI,wBAAwB,EACxC,SACE,qIACH,CAAC;AAGJ,KAAI,OAAO,YAAY,eAAe,CAAC,QAAQ,UAAU,KACvD,Q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,mBAAmB,QAAQ,qBAAqB;IACjD;;AAGH,SAAO;GACL,SAAS;GACT,SAAS,cAAc;GACvB,QAAQ,aAAa;GACrB,aAAa,QAAQ,eAAe,QAAQ,IAAI;GAChD,OAAO,QAAQ,SAAS;GACxB,mBAAmB,QAAQ,qBAAqB;GACjD;GACD;CACH,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRelease } from "../source-maps/api.mjs";
|
|
2
|
-
import { Context, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/build/services/release-api.service.d.ts
|
|
5
|
-
declare const ReleaseApiService_base: Context.TagClass<ReleaseApiService, "ReleaseApiService", {
|
|
6
|
-
readonly createRelease: typeof createRelease;
|
|
7
|
-
}>;
|
|
8
|
-
declare class ReleaseApiService extends ReleaseApiService_base {}
|
|
9
|
-
declare const ReleaseApiServiceLive: Layer.Layer<ReleaseApiService, never, never>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { ReleaseApiService, ReleaseApiServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release-api.service.d.mts","names":[],"sources":["../../../src/build/services/release-api.service.ts"],"mappings":";;;;cAEsD,sBAAA;iCAKnB,aAAA;AAAA;AAAA,cAHtB,iBAAA,SAA0B,sBAAA;AAAA,cAO1B,qBAAA,EAAqB,KAAA,CAAA,KAAA,CAAA,iBAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRelease } from "../source-maps/api.mjs";
|
|
2
|
-
import { Context, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/build/services/release-api.service.ts
|
|
5
|
-
var ReleaseApiService = class extends Context.Tag("ReleaseApiService")() {};
|
|
6
|
-
const ReleaseApiServiceLive = Layer.succeed(ReleaseApiService, { createRelease });
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ReleaseApiService, ReleaseApiServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release-api.service.mjs","names":[],"sources":["../../../src/build/services/release-api.service.ts"],"sourcesContent":["import { Context, Layer } from \"effect\";\n\nimport { createRelease } from \"../source-maps/api.js\";\n\nexport class ReleaseApiService extends Context.Tag(\"ReleaseApiService\")<\n ReleaseApiService,\n {\n readonly createRelease: typeof createRelease;\n }\n>() {}\n\nexport const ReleaseApiServiceLive = Layer.succeed(ReleaseApiService, {\n createRelease,\n});\n\n"],"mappings":";;;;AAIA,IAAa,oBAAb,cAAuC,QAAQ,IAAI,oBAAoB,EAKpE,CAAC;AAEJ,MAAa,wBAAwB,MAAM,QAAQ,mBAAmB,EACpE,eACD,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { MissingBuildIdError, MissingReleaseIdError } from "../source-maps/errors.mjs";
|
|
2
|
-
import { Context, Effect, Layer } from "effect";
|
|
3
|
-
import { ReleaseDestinationMetadata, ReleaseSourceMetadata } from "@interfere/types/integrations";
|
|
4
|
-
|
|
5
|
-
//#region src/build/services/release-identity.service.d.ts
|
|
6
|
-
type ReleaseIdentity = {
|
|
7
|
-
buildId: string;
|
|
8
|
-
releaseId: string;
|
|
9
|
-
sourceControl?: {
|
|
10
|
-
name: "github";
|
|
11
|
-
metadata: ReleaseSourceMetadata;
|
|
12
|
-
gitCommitSha: string;
|
|
13
|
-
};
|
|
14
|
-
deployment?: {
|
|
15
|
-
name: "vercel";
|
|
16
|
-
metadata: ReleaseDestinationMetadata;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
declare const ReleaseIdentityService_base: Context.TagClass<ReleaseIdentityService, "ReleaseIdentityService", Effect.Effect<ReleaseIdentity, MissingBuildIdError | MissingReleaseIdError, never>>;
|
|
20
|
-
declare class ReleaseIdentityService extends ReleaseIdentityService_base {}
|
|
21
|
-
declare const ReleaseIdentityServiceLive: Layer.Layer<ReleaseIdentityService, never, never>;
|
|
22
|
-
//#endregion
|
|
23
|
-
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"],"mappings":";;;;;KAaY,eAAA;EACV,OAAA;EACA,SAAA;EACA,aAAA;IACE,IAAA;IACA,QAAA,EAAU,qBAAA;IACV,YAAA;EAAA;EAEF,UAAA;IACE,IAAA;IACA,QAAA,EAAU,0BAAA;EAAA;AAAA;AAAA,cAEZ,2BAAA;cAEW,sBAAA,SAA+B,2BAAA;AAAA,cAsG/B,0BAAA,EAA0B,KAAA,CAAA,KAAA,CAAA,sBAAA"}
|
|
@@ -1,61 +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.fn("makeReleaseIdentity")(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 deploymentResult = Option.getOrUndefined(deploymentOpt);
|
|
15
|
-
const sourceControlResult = Option.getOrUndefined(sourceControlOpt);
|
|
16
|
-
let buildId = envBuildId ?? void 0;
|
|
17
|
-
let releaseId = envReleaseId ?? void 0;
|
|
18
|
-
if (!buildId && deploymentResult) {
|
|
19
|
-
const deploymentId = deploymentResult.metadata.deploymentId ?? void 0;
|
|
20
|
-
if (deploymentId) buildId = deploymentId;
|
|
21
|
-
}
|
|
22
|
-
if (!buildId && sourceControlResult) {
|
|
23
|
-
const sha = sourceControlResult.metadata.gitCommitSha;
|
|
24
|
-
if (sha) buildId = sha;
|
|
25
|
-
}
|
|
26
|
-
if (!releaseId && sourceControlResult) {
|
|
27
|
-
const sha = sourceControlResult.metadata.gitCommitSha;
|
|
28
|
-
if (sha) releaseId = sha;
|
|
29
|
-
}
|
|
30
|
-
if (!releaseId && deploymentResult) {
|
|
31
|
-
const deploymentId = deploymentResult.metadata.deploymentId ?? void 0;
|
|
32
|
-
if (deploymentId) releaseId = deploymentId;
|
|
33
|
-
}
|
|
34
|
-
if (!releaseId && buildId) releaseId = buildId;
|
|
35
|
-
if (!buildId && !releaseId) return yield* new MissingBuildIdError({ message: "Couldn't determine build ID (no deployment provider, git, or env vars found)" });
|
|
36
|
-
if (!buildId) return yield* 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* new MissingReleaseIdError({ message: "Couldn't determine release ID (tried NEXT_PUBLIC_INTERFERE_RELEASE_ID, deployment metadata, and git)" });
|
|
38
|
-
const sourceControl = sourceControlResult ? {
|
|
39
|
-
name: "github",
|
|
40
|
-
metadata: {
|
|
41
|
-
provider: "github",
|
|
42
|
-
commitMessage: sourceControlResult.metadata.commitMessage,
|
|
43
|
-
branch: sourceControlResult.metadata.branch
|
|
44
|
-
},
|
|
45
|
-
gitCommitSha: sourceControlResult.metadata.gitCommitSha
|
|
46
|
-
} : void 0;
|
|
47
|
-
const deployment = deploymentResult ? {
|
|
48
|
-
name: "vercel",
|
|
49
|
-
metadata: deploymentResult.metadata
|
|
50
|
-
} : void 0;
|
|
51
|
-
return {
|
|
52
|
-
buildId,
|
|
53
|
-
releaseId,
|
|
54
|
-
sourceControl,
|
|
55
|
-
deployment
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
const ReleaseIdentityServiceLive = Layer.succeed(ReleaseIdentityService, makeReleaseIdentity());
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
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 {\n ReleaseDestinationMetadata,\n ReleaseSourceMetadata,\n} from \"@interfere/types/integrations\";\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 name: \"github\";\n metadata: ReleaseSourceMetadata;\n gitCommitSha: string;\n };\n deployment?: {\n name: \"vercel\";\n metadata: ReleaseDestinationMetadata;\n };\n};\n\nexport class ReleaseIdentityService extends Context.Tag(\n \"ReleaseIdentityService\"\n)<\n ReleaseIdentityService,\n Effect.Effect<ReleaseIdentity, MissingBuildIdError | MissingReleaseIdError>\n>() {}\n\nconst makeReleaseIdentity = Effect.fn(\"makeReleaseIdentity\")(function* () {\n const envBuildId = getEnvBuildId();\n const envReleaseId = getEnvReleaseId();\n\n const deploymentOpt = yield* detectDeployment().pipe(Effect.option);\n const sourceControlOpt = yield* detectSourceControl().pipe(Effect.option);\n\n const deploymentResult = Option.getOrUndefined(deploymentOpt);\n const sourceControlResult = Option.getOrUndefined(sourceControlOpt);\n\n let buildId = envBuildId ?? undefined;\n let releaseId = envReleaseId ?? undefined;\n\n if (!buildId && deploymentResult) {\n const deploymentId = deploymentResult.metadata.deploymentId ?? undefined;\n if (deploymentId) {\n buildId = deploymentId;\n }\n }\n\n if (!buildId && sourceControlResult) {\n const sha = sourceControlResult.metadata.gitCommitSha;\n if (sha) {\n buildId = sha;\n }\n }\n\n if (!releaseId && sourceControlResult) {\n const sha = sourceControlResult.metadata.gitCommitSha;\n if (sha) {\n releaseId = sha;\n }\n }\n\n if (!releaseId && deploymentResult) {\n const deploymentId = deploymentResult.metadata.deploymentId ?? undefined;\n if (deploymentId) {\n releaseId = deploymentId;\n }\n }\n\n if (!releaseId && buildId) {\n releaseId = buildId;\n }\n\n if (!buildId && !releaseId) {\n return yield* new MissingBuildIdError({\n message:\n \"Couldn't determine build ID (no deployment provider, git, or env vars found)\",\n });\n }\n\n if (!buildId) {\n return yield* 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 if (!releaseId) {\n return yield* new MissingReleaseIdError({\n message:\n \"Couldn't determine release ID (tried NEXT_PUBLIC_INTERFERE_RELEASE_ID, deployment metadata, and git)\",\n });\n }\n\n const sourceControl = sourceControlResult\n ? {\n name: \"github\" as const,\n metadata: {\n provider: \"github\" as const,\n commitMessage: sourceControlResult.metadata.commitMessage,\n branch: sourceControlResult.metadata.branch,\n },\n gitCommitSha: sourceControlResult.metadata.gitCommitSha,\n }\n : undefined;\n\n const deployment = deploymentResult\n ? {\n name: \"vercel\" as const,\n metadata: deploymentResult.metadata,\n }\n : undefined;\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);\n"],"mappings":";;;;;;;AA2BA,IAAa,yBAAb,cAA4C,QAAQ,IAClD,yBACD,EAGE,CAAC;AAEJ,MAAM,sBAAsB,OAAO,GAAG,sBAAsB,CAAC,aAAa;CACxE,MAAM,aAAa,eAAe;CAClC,MAAM,eAAe,iBAAiB;CAEtC,MAAM,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 @@
|
|
|
1
|
-
import { maybeCleanupAfterFailure } from "../source-maps/files.mjs";
|
|
2
|
-
import { Context, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/build/services/source-map-failure-cleanup.service.d.ts
|
|
5
|
-
declare const SourceMapFailureCleanupService_base: Context.TagClass<SourceMapFailureCleanupService, "SourceMapFailureCleanupService", {
|
|
6
|
-
readonly maybeCleanupAfterFailure: typeof maybeCleanupAfterFailure;
|
|
7
|
-
}>;
|
|
8
|
-
declare class SourceMapFailureCleanupService extends SourceMapFailureCleanupService_base {}
|
|
9
|
-
declare const SourceMapFailureCleanupServiceLive: Layer.Layer<SourceMapFailureCleanupService, never, never>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { SourceMapFailureCleanupService, SourceMapFailureCleanupServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-failure-cleanup.service.d.mts","names":[],"sources":["../../../src/build/services/source-map-failure-cleanup.service.ts"],"mappings":";;;;cAEmE,mCAAA;4CAIW,wBAAA;AAAA;AAAA,cAFjE,8BAAA,SAAuC,mCAAA;AAAA,cAIvC,kCAAA,EAAkC,KAAA,CAAA,KAAA,CAAA,8BAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { maybeCleanupAfterFailure } from "../source-maps/files.mjs";
|
|
2
|
-
import { Context, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/build/services/source-map-failure-cleanup.service.ts
|
|
5
|
-
var SourceMapFailureCleanupService = class extends Context.Tag("SourceMapFailureCleanupService")() {};
|
|
6
|
-
const SourceMapFailureCleanupServiceLive = Layer.succeed(SourceMapFailureCleanupService, { maybeCleanupAfterFailure });
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { SourceMapFailureCleanupService, SourceMapFailureCleanupServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-failure-cleanup.service.mjs","names":[],"sources":["../../../src/build/services/source-map-failure-cleanup.service.ts"],"sourcesContent":["import { Context, Layer } from \"effect\";\n\nimport { maybeCleanupAfterFailure } from \"../source-maps/files.js\";\n\nexport class SourceMapFailureCleanupService extends Context.Tag(\n \"SourceMapFailureCleanupService\"\n)<SourceMapFailureCleanupService, { readonly maybeCleanupAfterFailure: typeof maybeCleanupAfterFailure }>() {}\n\nexport const SourceMapFailureCleanupServiceLive = Layer.succeed(\n SourceMapFailureCleanupService,\n {\n maybeCleanupAfterFailure,\n }\n);\n\n"],"mappings":";;;;AAIA,IAAa,iCAAb,cAAoD,QAAQ,IAC1D,iCACD,EAA0G,CAAC;AAE5G,MAAa,qCAAqC,MAAM,QACtD,gCACA,EACE,0BACD,CACF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FileDeleteError, FileGlobError, FileHashError, FileReadError, InvalidApiUrlError, UploadError } from "../source-maps/errors.mjs";
|
|
2
|
-
import { ConfigService } from "./config.service.mjs";
|
|
3
|
-
import { Context, Effect, Layer } from "effect";
|
|
4
|
-
import { CreateReleaseResponse } from "@interfere/types/releases/definition";
|
|
5
|
-
import { UploadedSourceMap } from "@interfere/types/data/source-maps";
|
|
6
|
-
|
|
7
|
-
//#region src/build/services/source-map.service.d.ts
|
|
8
|
-
type UploadMeta = CreateReleaseResponse & {
|
|
9
|
-
apiUrl: string;
|
|
10
|
-
};
|
|
11
|
-
declare const SourceMapService_base: Context.TagClass<SourceMapService, "SourceMapService", {
|
|
12
|
-
readonly find: Effect.Effect<string[], FileGlobError>;
|
|
13
|
-
readonly read: (files: string[]) => Effect.Effect<UploadedSourceMap[], FileReadError | FileHashError>;
|
|
14
|
-
readonly upload: (sourceMaps: UploadedSourceMap[], meta: UploadMeta) => Effect.Effect<void, UploadError | InvalidApiUrlError>;
|
|
15
|
-
readonly cleanup: (files: string[], debug: boolean) => Effect.Effect<void, FileDeleteError>;
|
|
16
|
-
}>;
|
|
17
|
-
declare class SourceMapService extends SourceMapService_base {}
|
|
18
|
-
declare const SourceMapServiceLive: Layer.Layer<SourceMapService, never, ConfigService>;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { SourceMapService, SourceMapServiceLive };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"source-map.service.d.mts","names":[],"sources":["../../../src/build/services/source-map.service.ts"],"mappings":";;;;;;;KAwBK,UAAA,GAAa,qBAAA;EAChB,MAAA;AAAA;AAAA,cAAM,qBAAA;iBAMW,MAAA,CAAO,MAAA,WAAiB,aAAA;EAAA,gBAGrC,KAAA,eACG,MAAA,CAAO,MAAA,CAAO,iBAAA,IAAqB,aAAA,GAAgB,aAAA;EAAA,kBAGtD,UAAA,EAAY,iBAAA,IACZ,IAAA,EAAM,UAAA,KACH,MAAA,CAAO,MAAA,OAAa,WAAA,GAAc,kBAAA;EAAA,mBAGrC,KAAA,YACA,KAAA,cACG,MAAA,CAAO,MAAA,OAAa,eAAA;AAAA;AAAA,cAjBhB,gBAAA,SAAyB,qBAAA;AAAA,cAqBzB,oBAAA,EAAoB,KAAA,CAAA,KAAA,CAAA,gBAAA,SAAA,aAAA"}
|
|
@@ -1,56 +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.suspend(findSourceMapFiles),
|
|
14
|
-
read: (files) => readSourceMapsFromFiles(files),
|
|
15
|
-
upload: Effect.fn("upload")(function* (sourceMaps, meta) {
|
|
16
|
-
const sourceMapToGenerated = yield* buildSourceMapToGeneratedMapping(yield* findGeneratedJsFiles().pipe(Effect.mapError((error) => {
|
|
17
|
-
return new UploadError({
|
|
18
|
-
message: `Failed to find generated JS files: ${error.message}`,
|
|
19
|
-
file: "js-files",
|
|
20
|
-
cause: error
|
|
21
|
-
});
|
|
22
|
-
}))).pipe(Effect.mapError((error) => {
|
|
23
|
-
if (error._tag === "FileReadError") return new UploadError({
|
|
24
|
-
message: `Failed to read JS file: ${error.message}`,
|
|
25
|
-
file: error.path,
|
|
26
|
-
cause: error
|
|
27
|
-
});
|
|
28
|
-
return new UploadError({
|
|
29
|
-
message: `Failed to read JS files: ${String(error)}`,
|
|
30
|
-
file: "js-files",
|
|
31
|
-
cause: error
|
|
32
|
-
});
|
|
33
|
-
}));
|
|
34
|
-
const totalMb = (sourceMaps.reduce((sum, sm) => sum + sm.content.length, 0) / 1024 / 1024).toFixed(2);
|
|
35
|
-
yield* appendBuildLogLine(`Uploading ${sourceMaps.length} source map(s) in parallel (${totalMb} MB total)`);
|
|
36
|
-
const result = yield* uploadSourceMaps(sourceMaps, sourceMapToGenerated, config, meta).pipe(Effect.mapError((error) => {
|
|
37
|
-
if (error._tag === "TokenRequestError") return new UploadError({
|
|
38
|
-
message: "Failed to request upload token",
|
|
39
|
-
file: "batch",
|
|
40
|
-
cause: error
|
|
41
|
-
});
|
|
42
|
-
if (error._tag === "NotificationError") return new UploadError({
|
|
43
|
-
message: "Failed to notify upload completion",
|
|
44
|
-
file: "batch",
|
|
45
|
-
cause: error
|
|
46
|
-
});
|
|
47
|
-
return error;
|
|
48
|
-
}));
|
|
49
|
-
yield* logBuildResult("Info", "Source map upload complete", [`${result.uploaded} source map${result.uploaded === 1 ? "" : "s"} uploaded successfully`]);
|
|
50
|
-
}),
|
|
51
|
-
cleanup: (files, debug) => config.cleanupSourceMaps !== false ? cleanupSourceMaps(files, debug) : Effect.void
|
|
52
|
-
};
|
|
53
|
-
}));
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
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\";\nimport type { CreateReleaseResponse } from \"@interfere/types/releases/definition\";\n\ntype UploadMeta = CreateReleaseResponse & {\n apiUrl: string;\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.suspend(findSourceMapFiles),\n \n read: (files: string[]) => readSourceMapsFromFiles(files),\n \n upload: Effect.fn(\"upload\")(function* (\n sourceMaps: UploadedSourceMap[],\n meta: UploadMeta\n ) {\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(files, debug)\n : Effect.void,\n };\n })\n);"],"mappings":";;;;;;;;AA4BA,IAAa,mBAAb,cA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,IAC9B,wBACF,CAAC;IACF;EAEJ,UAAU,OAAiB,UACzB,OAAO,sBAAsB,QACzB,kBAAkB,OAAO,MAAM,GAC/B,OAAO;EACd;EACD,CACH"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { PreflightConfig } from "../../lib/types.mjs";
|
|
2
|
-
import { InvalidApiUrlError, MissingApiKeyError, NotificationError, TokenRequestError, UploadError } from "./errors.mjs";
|
|
3
|
-
import { Effect } from "effect";
|
|
4
|
-
import { CreateReleaseResponse } from "@interfere/types/releases/definition";
|
|
5
|
-
import { UploadedSourceMap } from "@interfere/types/data/source-maps";
|
|
6
|
-
import { ReleaseDestinationMetadata, ReleaseSourceMetadata } from "@interfere/types/integrations";
|
|
7
|
-
|
|
8
|
-
//#region src/build/source-maps/api.d.ts
|
|
9
|
-
type ReleaseInfo = {
|
|
10
|
-
environment: string;
|
|
11
|
-
sourceId: string;
|
|
12
|
-
sourceMetadata?: ReleaseSourceMetadata;
|
|
13
|
-
destinationMetadata?: ReleaseDestinationMetadata;
|
|
14
|
-
};
|
|
15
|
-
declare function createRelease(config: PreflightConfig, releaseInfo: ReleaseInfo): Effect.Effect<{
|
|
16
|
-
org: {
|
|
17
|
-
id: string;
|
|
18
|
-
slug: string;
|
|
19
|
-
};
|
|
20
|
-
surface: {
|
|
21
|
-
id: string;
|
|
22
|
-
slug: string;
|
|
23
|
-
};
|
|
24
|
-
source: {
|
|
25
|
-
id: string;
|
|
26
|
-
};
|
|
27
|
-
destination: {
|
|
28
|
-
id: string;
|
|
29
|
-
slug: string;
|
|
30
|
-
environment: string | null;
|
|
31
|
-
};
|
|
32
|
-
}, MissingApiKeyError | UploadError | InvalidApiUrlError, never>;
|
|
33
|
-
/**
|
|
34
|
-
* Upload source maps using the new v2 client
|
|
35
|
-
* @param sourceMapToGenerated - Mapping from source map filename to generated JS file path
|
|
36
|
-
*/
|
|
37
|
-
declare function uploadSourceMaps(sourceMaps: UploadedSourceMap[], sourceMapToGenerated: Record<string, string>, config: PreflightConfig, meta: CreateReleaseResponse & {
|
|
38
|
-
apiUrl: string;
|
|
39
|
-
}): Effect.Effect<{
|
|
40
|
-
uploaded: number;
|
|
41
|
-
processed: any;
|
|
42
|
-
}, UploadError | TokenRequestError | NotificationError, never>;
|
|
43
|
-
//#endregion
|
|
44
|
-
export { createRelease, uploadSourceMaps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.mts","names":[],"sources":["../../../src/build/source-maps/api.ts"],"mappings":";;;;;;;;KAkBK,WAAA;EACH,WAAA;EACA,QAAA;EACA,cAAA,GAAiB,qBAAA;EACjB,mBAAA,GAAsB,0BAAA;AAAA;AAAA,iBAmGR,aAAA,CAAc,MAAA,EAAQ,eAAA,EAAiB,WAAA,EAAa,WAAA,GAAW,MAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;iBAoB/D,gBAAA,CACd,UAAA,EAAY,iBAAA,IACZ,oBAAA,EAAsB,MAAA,kBACtB,MAAA,EAAQ,eAAA,EACR,IAAA,EAAM,qBAAA;EAA0B,MAAA;AAAA,IAAgB,MAAA,CAAA,MAAA"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { resolveApiUrl } from "../env-config.mjs";
|
|
2
|
-
import { InvalidApiUrlError, MissingApiKeyError, UploadError } from "./errors.mjs";
|
|
3
|
-
import { SourceMapClient } from "./client.mjs";
|
|
4
|
-
import { Duration, Effect, pipe } from "effect";
|
|
5
|
-
import { createReleaseResponse } from "@interfere/types/releases/definition";
|
|
6
|
-
|
|
7
|
-
//#region src/build/source-maps/api.ts
|
|
8
|
-
const API_TIMEOUT = Duration.seconds(30);
|
|
9
|
-
const validateConfig = (config) => config.enabled ? Effect.succeed(config) : Effect.fail(new MissingApiKeyError({ message: "Interfere is disabled - API key or surface slug missing" }));
|
|
10
|
-
const createReleaseEffect = (config, body) => pipe(Effect.tryPromise({
|
|
11
|
-
try: () => fetch(`${resolveApiUrl()}/releases`, {
|
|
12
|
-
method: "PUT",
|
|
13
|
-
body: JSON.stringify(body),
|
|
14
|
-
headers: {
|
|
15
|
-
"X-API-Key": config.apiKey,
|
|
16
|
-
"Content-Type": "application/json"
|
|
17
|
-
}
|
|
18
|
-
}).then((response) => ({
|
|
19
|
-
config,
|
|
20
|
-
response
|
|
21
|
-
})),
|
|
22
|
-
catch: (error) => new InvalidApiUrlError({ message: `Failed to reach Interfere API: ${String(error)}` })
|
|
23
|
-
}), Effect.timeoutFail({
|
|
24
|
-
duration: API_TIMEOUT,
|
|
25
|
-
onTimeout: () => new InvalidApiUrlError({ message: "Timed out while connecting to the Interfere API. Check INTERFERE_API_URL." })
|
|
26
|
-
}));
|
|
27
|
-
const handleResponse = ({ config, response }) => {
|
|
28
|
-
if (response.status === 401) return Effect.fail(new MissingApiKeyError({ message: `INTERFERE_API_KEY ending in '${config.apiKey.slice(-4)}' is invalid. Check the environment variable in your build environment.` }));
|
|
29
|
-
if (!response.ok) return pipe(Effect.promise(() => response.text().catch(() => "Unknown error")), Effect.flatMap((errorText) => Effect.fail(new UploadError({ message: `Failed to create release: ${response.status} ${errorText}` }))));
|
|
30
|
-
return Effect.succeed(response);
|
|
31
|
-
};
|
|
32
|
-
const parseReleaseResponse = (response) => pipe(Effect.promise(() => response.json()), Effect.flatMap((json) => {
|
|
33
|
-
const parseResult = createReleaseResponse.safeParse(json);
|
|
34
|
-
return parseResult.success ? Effect.succeed(parseResult.data) : Effect.fail(new UploadError({ message: `Invalid release response: ${parseResult.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join(", ")}` }));
|
|
35
|
-
}));
|
|
36
|
-
function createRelease(config, releaseInfo) {
|
|
37
|
-
return pipe(validateConfig(config), Effect.flatMap((validConfig) => pipe(createReleaseEffect(validConfig, {
|
|
38
|
-
...releaseInfo,
|
|
39
|
-
surfaceSlug: validConfig.surface
|
|
40
|
-
}), Effect.flatMap(handleResponse), Effect.flatMap(parseReleaseResponse))));
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Upload source maps using the new v2 client
|
|
44
|
-
* @param sourceMapToGenerated - Mapping from source map filename to generated JS file path
|
|
45
|
-
*/
|
|
46
|
-
function uploadSourceMaps(sourceMaps, sourceMapToGenerated, config, meta) {
|
|
47
|
-
if (!config.enabled || sourceMaps.length === 0) return Effect.succeed({
|
|
48
|
-
uploaded: 0,
|
|
49
|
-
processed: 0
|
|
50
|
-
});
|
|
51
|
-
const sourceMapFiles = sourceMaps.map((sm) => ({
|
|
52
|
-
relativePath: sm.relativePath,
|
|
53
|
-
content: sm.content,
|
|
54
|
-
hash: sm.hash,
|
|
55
|
-
size: Buffer.byteLength(sm.content, "utf8")
|
|
56
|
-
}));
|
|
57
|
-
return new SourceMapClient(config, meta.apiUrl, {
|
|
58
|
-
concurrency: 8,
|
|
59
|
-
uploadTimeoutMs: Duration.toMillis(API_TIMEOUT)
|
|
60
|
-
}).uploadSourceMaps(meta.destination.slug, sourceMapFiles, sourceMapToGenerated);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { createRelease, uploadSourceMaps };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":[],"sources":["../../../src/build/source-maps/api.ts"],"sourcesContent":["import type { UploadedSourceMap } from \"@interfere/types/data/source-maps\";\nimport type {\n ReleaseDestinationMetadata,\n ReleaseSourceMetadata,\n} from \"@interfere/types/integrations\";\nimport { createReleaseResponse, type CreateReleaseResponse } from \"@interfere/types/releases/definition\";\nimport { Duration, Effect, pipe } from \"effect\";\nimport type { PreflightConfig, PreflightEnabled } from \"../../lib/types.js\";\nimport { resolveApiUrl } from \"../env-config.js\";\nimport { SourceMapClient } from \"./client.js\";\nimport {\n InvalidApiUrlError,\n MissingApiKeyError,\n UploadError,\n} from \"./errors.js\";\n\nconst API_TIMEOUT = Duration.seconds(30);\n\ntype ReleaseInfo = {\n environment: string;\n sourceId: string;\n sourceMetadata?: ReleaseSourceMetadata;\n destinationMetadata?: ReleaseDestinationMetadata;\n};\n\nconst validateConfig = (\n config: PreflightConfig\n): Effect.Effect<PreflightEnabled, MissingApiKeyError> =>\n config.enabled\n ? Effect.succeed(config as PreflightEnabled)\n : Effect.fail(\n new MissingApiKeyError({\n message: \"Interfere is disabled - API key or surface slug missing\",\n })\n );\n\nconst createReleaseEffect = (\n config: PreflightEnabled,\n body: ReleaseInfo & { surfaceSlug: string }\n) =>\n pipe(\n Effect.tryPromise({\n try: () =>\n fetch(`${resolveApiUrl()}/releases`, {\n method: \"PUT\",\n body: JSON.stringify(body),\n headers: {\n \"X-API-Key\": config.apiKey,\n \"Content-Type\": \"application/json\",\n },\n }).then((response) => ({\n config,\n response,\n })),\n catch: (error) =>\n new InvalidApiUrlError({\n message: `Failed to reach Interfere API: ${String(error)}`,\n }),\n }),\n Effect.timeoutFail({\n duration: API_TIMEOUT,\n onTimeout: () =>\n new InvalidApiUrlError({\n message:\n \"Timed out while connecting to the Interfere API. Check INTERFERE_API_URL.\",\n }),\n })\n );\n\nconst handleResponse = ({\n config,\n response,\n}: {\n config: PreflightEnabled;\n response: Response;\n}): Effect.Effect<Response, MissingApiKeyError | UploadError> => {\n // Handle 401 specifically - invalid API key\n if (response.status === 401) {\n return Effect.fail(\n new MissingApiKeyError({\n message: `INTERFERE_API_KEY ending in '${config.apiKey.slice(-4)}' is invalid. Check the environment variable in your build environment.`,\n })\n );\n }\n\n // Handle other non-ok responses\n if (!response.ok) {\n return pipe(\n Effect.promise(() => response.text().catch(() => \"Unknown error\")),\n Effect.flatMap((errorText) =>\n Effect.fail(\n new UploadError({\n message: `Failed to create release: ${response.status} ${errorText}`,\n })\n )\n )\n );\n }\n\n // Success\n return Effect.succeed(response);\n};\n\nconst parseReleaseResponse = (response: Response) =>\n pipe(\n Effect.promise(() => response.json()),\n Effect.flatMap((json) => {\n const parseResult = createReleaseResponse.safeParse(json);\n\n return parseResult.success\n ? Effect.succeed(parseResult.data)\n : Effect.fail(\n new UploadError({\n message: `Invalid release response: ${parseResult.error.issues\n .map((i) => `${i.path.join(\".\")}: ${i.message}`)\n .join(\", \")}`,\n })\n );\n })\n );\n\nexport function createRelease(config: PreflightConfig, releaseInfo: ReleaseInfo) {\n return pipe(\n validateConfig(config),\n Effect.flatMap((validConfig) =>\n pipe(\n createReleaseEffect(validConfig, {\n ...releaseInfo,\n surfaceSlug: validConfig.surface,\n }),\n Effect.flatMap(handleResponse),\n Effect.flatMap(parseReleaseResponse)\n )\n )\n );\n}\n\n/**\n * Upload source maps using the new v2 client\n * @param sourceMapToGenerated - Mapping from source map filename to generated JS file path\n */\nexport function uploadSourceMaps(\n sourceMaps: UploadedSourceMap[],\n sourceMapToGenerated: Record<string, string>,\n config: PreflightConfig,\n meta: CreateReleaseResponse & { apiUrl: string }\n) {\n // Early return for disabled or no source maps\n if (!config.enabled || sourceMaps.length === 0) {\n return Effect.succeed({ uploaded: 0, processed: 0 });\n }\n\n // Convert source maps to client format\n const sourceMapFiles = sourceMaps.map((sm) => ({\n relativePath: sm.relativePath,\n content: sm.content,\n hash: sm.hash,\n size: Buffer.byteLength(sm.content, \"utf8\"),\n }));\n\n // Create client and upload with higher concurrency for faster uploads\n const client = new SourceMapClient(config, meta.apiUrl, {\n concurrency: 8,\n uploadTimeoutMs: Duration.toMillis(API_TIMEOUT),\n });\n\n return client.uploadSourceMaps(\n meta.destination.slug,\n sourceMapFiles,\n sourceMapToGenerated\n );\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,cAAc,SAAS,QAAQ,GAAG;AASxC,MAAM,kBACJ,WAEA,OAAO,UACH,OAAO,QAAQ,OAA2B,GAC1C,OAAO,KACL,IAAI,mBAAmB,EACrB,SAAS,2DACV,CAAC,CACH;AAEP,MAAM,uBACJ,QACA,SAEA,KACE,OAAO,WAAW;CAChB,WACE,MAAM,GAAG,eAAe,CAAC,YAAY;EACnC,QAAQ;EACR,MAAM,KAAK,UAAU,KAAK;EAC1B,SAAS;GACP,aAAa,OAAO;GACpB,gBAAgB;G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BACd,YACA,sBACA,QACA,MACA;AAEA,KAAI,CAAC,OAAO,WAAW,WAAW,WAAW,EAC3C,QAAO,OAAO,QAAQ;EAAE,UAAU;EAAG,WAAW;EAAG,CAAC;CAItD,MAAM,iBAAiB,WAAW,KAAK,QAAQ;EAC7C,cAAc,GAAG;EACjB,SAAS,GAAG;EACZ,MAAM,GAAG;EACT,MAAM,OAAO,WAAW,GAAG,SAAS,OAAO;EAC5C,EAAE;AAQH,QALe,IAAI,gBAAgB,QAAQ,KAAK,QAAQ;EACtD,aAAa;EACb,iBAAiB,SAAS,SAAS,YAAY;EAChD,CAAC,CAEY,iBACZ,KAAK,YAAY,MACjB,gBACA,qBACD"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { PreflightConfig } from "../../lib/types.mjs";
|
|
2
|
-
import { NotificationError, TokenRequestError, UploadError } from "./errors.mjs";
|
|
3
|
-
import { Effect } from "effect";
|
|
4
|
-
import { BatchUploadPaths, SourceMapConfig, SourceMapFile, UploadedBlob } from "@interfere/types/data/source-maps";
|
|
5
|
-
import { upload } from "@vercel/blob/client";
|
|
6
|
-
|
|
7
|
-
//#region src/build/source-maps/client.d.ts
|
|
8
|
-
type SourceMapFileWithContent = SourceMapFile & {
|
|
9
|
-
content: string;
|
|
10
|
-
};
|
|
11
|
-
type UploadFn = typeof upload;
|
|
12
|
-
type SourceMapClientDeps = {
|
|
13
|
-
readonly fetch?: typeof fetch;
|
|
14
|
-
readonly upload?: UploadFn;
|
|
15
|
-
};
|
|
16
|
-
declare class SourceMapClient {
|
|
17
|
-
private readonly config;
|
|
18
|
-
private readonly apiUrl;
|
|
19
|
-
private readonly apiKey;
|
|
20
|
-
private readonly surfaceSlug;
|
|
21
|
-
private readonly fetchImpl;
|
|
22
|
-
private readonly uploadImpl;
|
|
23
|
-
constructor(preflightConfig: PreflightConfig, apiUrl: string, options?: Partial<SourceMapConfig>, deps?: SourceMapClientDeps);
|
|
24
|
-
/**
|
|
25
|
-
* Request upload paths for source maps (paths only, no tokens).
|
|
26
|
-
* Tokens are generated per-file via the /upload endpoint.
|
|
27
|
-
*/
|
|
28
|
-
requestUploadPaths(releaseSlug: string, request: {
|
|
29
|
-
files: SourceMapFile[];
|
|
30
|
-
folderPrefix?: string;
|
|
31
|
-
}): Effect.Effect<{
|
|
32
|
-
uploadPaths: Record<string, {
|
|
33
|
-
uploadPath: string;
|
|
34
|
-
contentType: string;
|
|
35
|
-
}>;
|
|
36
|
-
expiresAt: string;
|
|
37
|
-
}, TokenRequestError, never>;
|
|
38
|
-
/**
|
|
39
|
-
* Upload a source map file using Vercel Blob's secure client upload.
|
|
40
|
-
* The server validates auth and issues a path-scoped token via /upload endpoint.
|
|
41
|
-
*/
|
|
42
|
-
uploadFile(releaseSlug: string, file: SourceMapFileWithContent, uploadInfo: {
|
|
43
|
-
uploadPath: string;
|
|
44
|
-
contentType: string;
|
|
45
|
-
}): Effect.Effect<{
|
|
46
|
-
relativePath: string;
|
|
47
|
-
hash: string;
|
|
48
|
-
blobUrl: string;
|
|
49
|
-
}, UploadError, never>;
|
|
50
|
-
/**
|
|
51
|
-
* Upload multiple source maps in parallel using secure client uploads.
|
|
52
|
-
* Each upload gets a path-scoped token from the server.
|
|
53
|
-
*/
|
|
54
|
-
uploadBatch(releaseSlug: string, files: SourceMapFileWithContent[], batchPaths: BatchUploadPaths): Effect.Effect<{
|
|
55
|
-
relativePath: string;
|
|
56
|
-
hash: string;
|
|
57
|
-
blobUrl: string;
|
|
58
|
-
}[], UploadError, never>;
|
|
59
|
-
/**
|
|
60
|
-
* Notify the server that uploads are complete
|
|
61
|
-
*/
|
|
62
|
-
notifyCompletion(releaseSlug: string, notification: {
|
|
63
|
-
uploadedFiles: UploadedBlob[];
|
|
64
|
-
sourceMapToGenerated?: Record<string, string>;
|
|
65
|
-
}): Effect.Effect<any, NotificationError, never>;
|
|
66
|
-
/**
|
|
67
|
-
* Complete workflow: request paths, upload files with secure tokens, notify completion
|
|
68
|
-
*
|
|
69
|
-
* Flow:
|
|
70
|
-
* 1. Request upload paths from API (paths only, no tokens)
|
|
71
|
-
* 2. Upload files using secure client uploads (server issues path-scoped tokens)
|
|
72
|
-
* 3. Notify API that uploads are complete for processing
|
|
73
|
-
*
|
|
74
|
-
* @param sourceMapToGenerated - Mapping from source map filename to generated JS file path
|
|
75
|
-
*/
|
|
76
|
-
uploadSourceMaps(releaseSlug: string, sourceMapFiles: SourceMapFileWithContent[], sourceMapToGenerated: Record<string, string>): Effect.Effect<{
|
|
77
|
-
uploaded: number;
|
|
78
|
-
processed: any;
|
|
79
|
-
}, UploadError | TokenRequestError | NotificationError, never>;
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { SourceMapClient };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../../../src/build/source-maps/client.ts"],"mappings":";;;;;;;KAcK,wBAAA,GAA2B,aAAA;EAC9B,OAAA;AAAA;AAAA,KAGG,QAAA,UAAkB,MAAA;AAAA,KAElB,mBAAA;EAAA,SACM,KAAA,UAAe,KAAA;EAAA,SACf,MAAA,GAAS,QAAA;AAAA;AAAA,cAGP,eAAA;EAAA,iBACM,MAAA;EAAA,iBACA,MAAA;EAAA,iBACA,MAAA;EAAA,iBACA,WAAA;EAAA,iBACA,SAAA;EAAA,iBACA,UAAA;cAGf,eAAA,EAAiB,eAAA,EACjB,MAAA,UACA,OAAA,GAAU,OAAA,CAAQ,eAAA,GAClB,IAAA,GAAO,mBAAA;EAhBA;;;;EA2CT,kBAAA,CACE,WAAA,UACA,OAAA;IAAW,KAAA,EAAO,aAAA;IAAiB,YAAA;EAAA,IAAuB,MAAA,CAAA,MAAA;;;;;;;;;;;EA4D5D,UAAA,CACE,WAAA,UACA,IAAA,EAAM,wBAAA,EACN,UAAA;IAAc,UAAA;IAAoB,WAAA;EAAA,IAAqB,MAAA,CAAA,MAAA;;;;;EAgGtD;;;;EA7CH,WAAA,CACE,WAAA,UACA,KAAA,EAAO,wBAAA,IACP,UAAA,EAAY,gBAAA,GAAgB,MAAA,CAAA,MAAA;;;;;EA4IgB;;;EAvG9C,gBAAA,CACE,WAAA,UACA,YAAA;IACE,aAAA,EAAe,YAAA;IACf,oBAAA,GAAuB,MAAA;EAAA,IACxB,MAAA,CAAA,MAAA,MAAA,iBAAA;;;;;;;;;;;EA+FH,gBAAA,CACE,WAAA,UACA,cAAA,EAAgB,wBAAA,IAChB,oBAAA,EAAsB,MAAA,mBAAsB,MAAA,CAAA,MAAA"}
|