@getexception/cli 0.1.18 → 0.1.19

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 CHANGED
@@ -18,6 +18,33 @@ The Owner creates **Source map upload tokens** in the project's settings. Store
18
18
 
19
19
  For GitLab MR previews use short-lived `GETEXCEPTION_GITLAB_ID_TOKEN` instead, after the operator has configured the pinned GitLab trust policy. Run `getexception ci context --url <HTTPS dashboard origin> --project <UUID>` before building; use the returned release, deployment and asset prefix for the actual JavaScript output. Upload and release registration use that identity automatically. Never set both credential variables. See the [GitLab integration guide](../../docs/gitlab-ci.md) for server configuration, exact build isolation and production restrictions. Version 0.1.7 does not support this flow.
20
20
 
21
+ ## Reusable GitLab deployment integration
22
+
23
+ Applications with a Node deployment script can use `@getexception/cli/integration` instead of implementing CI identity checks, source-map batching, public-output checks, upload retries and release registration themselves:
24
+
25
+ ```ts
26
+ import { deployWithGetException } from "@getexception/cli/integration";
27
+
28
+ await deployWithGetException({
29
+ url: "https://monitor.example.com",
30
+ projectId: process.env.GETEXCEPTION_PROJECT_ID!,
31
+ releasePrefix: "account",
32
+ repository: { id: 123, path: "company/frontend/account" },
33
+ environment: "production",
34
+ environmentName: "production/app",
35
+ output: "packages/app/build",
36
+ runtimeEnv: {
37
+ release: "APP_GETEXCEPTION_RELEASE",
38
+ environment: "APP_GETEXCEPTION_ENVIRONMENT",
39
+ },
40
+ beforeBuild: async (safeEnv) => installAndSetUpDeployment(safeEnv),
41
+ build: async (safeEnv) => buildApplication(safeEnv),
42
+ deploy: async () => deployApplication(),
43
+ });
44
+ ```
45
+
46
+ `beforeBuild` is optional and runs once after the GitLab token has been removed from the process and the environment passed to the callback; use it for installation or SSH setup. `build` and `deploy` are the application's existing operations. `build` must start from a clean output directory on every call: if private map preparation fails or exceeds its five-minute preparation deadline, the integration calls it once more with maps disabled, then checks the public output before deploy. A compiler error, unsafe public output or failed deploy still stops the job. Context, registration and map-delivery failures do not undo a successful deploy; the result records `ready`, `disabled`, `failed` or `incomplete` and logs one safe summary. Registration and upload run only after deploy. The signed server context still decides what each job may upload. The integration works for other projects by changing the explicit project, repository, release prefix, environment and callbacks. It supports final ESM `.js`/`.mjs` and external non-indexed source maps; framework-specific build and deploy commands remain in the application.
47
+
21
48
  The current CI context contract is **version 2**; CLI 0.1.8 must be upgraded to use it. The Owner selects **Production only** or **Production and MR** under project settings and adds trusted fork project IDs/paths. No container restart is needed. A context includes `sourceMaps: {enabled: true}` or, for a trusted preview with maps disabled, `{enabled: false, reason: "preview_disabled"}`. An unlisted preview source receives only `{version: 2, sourceMaps: {enabled: false, reason: "source_not_allowed"}}` with no build context or release-registration permission. Skip responses mean build/deploy without maps, not disable SDK events. Invalid credentials, HTTP failures and unknown contracts remain CLI errors; the caller handles them as optional monitoring failures and continues the normal application build/deploy without maps. A trusted context can still register its release while maps are disabled. Production never receives a skip response.
22
49
 
23
50
  Permanent upload tokens cannot be created or used for projects with GitLab authentication configured. They remain available for other trusted CI integrations. Forks may upload only their own preview job's maps; the main repository remains the only production source. Actual map read access is never granted to CI.
@@ -28,7 +55,7 @@ Deploy the resulting `dist` unchanged. Upload failure does not undo preparation:
28
55
 
29
56
  `upload` sends an authenticated manifest, gzip-compresses each map in memory, uploads up to eight files concurrently with checksums, then waits for background validation. It retries bounded transient network/server failures, resumes the same manifest from its missing files, has a twenty-minute deadline per batch, and exits nonzero on failure. Neither production nor preview deployment depends on GetException availability. Deploy the safe prepared JavaScript first, then attempt map delivery from the same isolated job workspace. The CI wrapper catches monitoring failures and emits a prominent production warning or a single neutral preview log line. Only report successful map delivery when all batches are ready. A failed local prepare requires one clean rebuild without maps; a late successful upload automatically reprocesses existing errors. Do not retain maps in GitLab artifacts as a fallback. Raw maps have no download endpoint.
30
57
 
31
- Limits: 128 JS files and 128 MiB per upload, 16 MiB per map, 1 GiB per project, 10 GiB per installation. Non-indexed Source Map v3 JSON only; no archives or remote source downloads. Gzip is used only as bounded HTTPS transfer encoding and does not change the stored map format. Existing events are processed after a late upload. Errors thrown in the browser console have no source file and cannot gain a source snippet from a map.
58
+ Limits: 128 JS files and 128 MiB per upload, 16 MiB per map, 4 GiB per project, 8 GiB per installation, with a 5 GiB free-disk reserve for uploads. The Node integration splits a larger build into upload batches automatically. Non-indexed Source Map v3 JSON only; no archives or remote source downloads. Gzip is used only as bounded HTTPS transfer encoding and does not change the stored map format. Existing events are processed after a late upload. Errors thrown in the browser console have no source file and cannot gain a source snippet from a map.
32
59
 
33
60
  MIT. See `THIRD-PARTY-NOTICES.md`.
34
61
 
@@ -44,7 +71,7 @@ Use the GitLab target repository's numeric project ID and the MR IID belonging t
44
71
 
45
72
  With GitLab build authentication, use the exact `release` and `deployment` returned by `ci context` instead of constructing registration metadata yourself. `CI_MERGE_REQUEST_PROJECT_ID` is not a substitute for the target project in a fork workflow.
46
73
 
47
- Debug IDs are deterministic for identical JS, maps and paths, regardless of the release SHA. The server reuses private bytes within the project and `upload` skips files it already has. Every release still sends its own manifest. Changed JavaScript requires its matching map: there is no fallback to the latest production map. Ready maps older than 30 days are eligible for cleanup only when their release has no retained events or pending inbox events. Shared files survive until all references expire.
74
+ Debug IDs are deterministic for identical JS, maps and paths, regardless of the release SHA. The server reuses private bytes within the project and `upload` skips files it already has. Every release still sends its own manifest. Changed JavaScript requires its matching map: there is no fallback to the latest production map. Ready maps older than 30 days are eligible for cleanup when retained events do not use their Debug IDs, and expire after 60 days even if those events remain. Pending events postpone cleanup until processed. Shared files survive until all references expire.
48
75
 
49
76
  CI wrappers must keep `ci context` and release registration on short timeouts. Run map delivery only after the application is deployed and give each upload subprocess a hard timeout slightly longer than the CLI's twenty-minute deadline. Do not impose one small shared timeout on all batches: that makes valid larger builds fail based on transfer time. See the [failure handling contract](../../docs/gitlab-ci.md#обработка-сбоев-в-account). Do not mark the whole build job as allowed to fail. Compiler, deployment and public-output safety failures remain real job failures.
50
77
 
package/dist/index.js CHANGED
@@ -18932,8 +18932,9 @@ var SOURCE_MAP_LIMITS = {
18932
18932
  files: 128,
18933
18933
  fileBytes: 16 * 1024 * 1024,
18934
18934
  releaseBytes: 128 * 1024 * 1024,
18935
- projectBytes: 1024 * 1024 * 1024,
18936
- installationBytes: 10 * 1024 * 1024 * 1024,
18935
+ projectBytes: 4 * 1024 * 1024 * 1024,
18936
+ installationBytes: 8 * 1024 * 1024 * 1024,
18937
+ diskReserveBytes: 5 * 1024 * 1024 * 1024,
18937
18938
  manifestBytes: 64 * 1024
18938
18939
  };
18939
18940
  var releaseNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,79}@[a-f0-9]{40}$/);
@@ -19522,23 +19523,19 @@ async function uploadMaps(directory, address, project, token, transport = fetch)
19522
19523
  // packages/cli/src/releases.ts
19523
19524
  async function registerRelease(address, project, token, value, transport = fetch) {
19524
19525
  const input2 = releaseRegistrationSchema.parse(value);
19525
- await projectApi(
19526
- address,
19527
- project,
19528
- token,
19529
- transport
19530
- )("/releases", "POST", JSON.stringify(input2));
19526
+ await projectApi(address, project, token, transport, {
19527
+ deadlineMs: 1e4,
19528
+ requestTimeoutMs: 1e4
19529
+ })("/releases", "POST", JSON.stringify(input2));
19531
19530
  }
19532
19531
 
19533
19532
  // packages/cli/src/ci.ts
19534
19533
  async function buildContext(address, project, credential, transport = fetch) {
19535
19534
  const result = ciContextSchema.safeParse(
19536
- await projectApi(
19537
- address,
19538
- project,
19539
- credential,
19540
- transport
19541
- )("/ci?version=2", "POST")
19535
+ await projectApi(address, project, credential, transport, {
19536
+ deadlineMs: 1e4,
19537
+ requestTimeoutMs: 1e4
19538
+ })("/ci?version=2", "POST")
19542
19539
  );
19543
19540
  if (!result.success) {
19544
19541
  throw new CliError("CONTRACT_RESPONSE", 200);
@@ -0,0 +1,62 @@
1
+ type GitLabDeploymentOptions = {
2
+ url: string;
3
+ projectId: string;
4
+ releasePrefix: string;
5
+ repository: {
6
+ id: number;
7
+ path: string;
8
+ };
9
+ environment: "production" | "staging";
10
+ environmentName: string;
11
+ output: string;
12
+ beforeBuild?: (environment: NodeJS.ProcessEnv) => Promise<void>;
13
+ build: (environment: NodeJS.ProcessEnv) => Promise<void>;
14
+ deploy: () => Promise<void>;
15
+ runtimeEnv?: {
16
+ release: string;
17
+ environment: string;
18
+ };
19
+ env?: NodeJS.ProcessEnv;
20
+ transport?: typeof fetch;
21
+ log?: (message: string) => void;
22
+ };
23
+ type GitLabDeploymentResult = {
24
+ maps: "ready" | "disabled" | "failed" | "incomplete";
25
+ registration: "registered" | "failed" | "skipped";
26
+ diagnostic?: string;
27
+ cleanupFailed: boolean;
28
+ };
29
+ declare function validateGitLabContext(value: unknown, env: NodeJS.ProcessEnv, options: Pick<GitLabDeploymentOptions, "releasePrefix" | "repository" | "environment" | "environmentName">): {
30
+ release: string;
31
+ assetPrefix: string;
32
+ deployment: {
33
+ environment: "production" | "staging" | "development";
34
+ review?: {
35
+ provider: "gitlab";
36
+ repositoryId: number;
37
+ number: number;
38
+ } | undefined;
39
+ };
40
+ version: 2;
41
+ sourceMaps: {
42
+ enabled: true;
43
+ } | {
44
+ enabled: false;
45
+ reason: "preview_disabled";
46
+ };
47
+ } | {
48
+ version: 2;
49
+ sourceMaps: {
50
+ enabled: false;
51
+ reason: "source_not_allowed";
52
+ };
53
+ };
54
+ declare function deployWithGetException(options: GitLabDeploymentOptions): Promise<GitLabDeploymentResult>;
55
+
56
+ declare function assertPublicOutput(root: string, options?: {
57
+ assetPrefix?: string;
58
+ credentials?: string[];
59
+ mapsEnabled?: boolean;
60
+ }): Promise<void>;
61
+
62
+ export { type GitLabDeploymentOptions, type GitLabDeploymentResult, assertPublicOutput, deployWithGetException, validateGitLabContext };