@gjsify/cli 0.64.44 → 0.64.46

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.
@@ -186,6 +186,7 @@ export const flatpakInitCommand = {
186
186
  command,
187
187
  kind,
188
188
  flatpak,
189
+ desktopExecArgs: configData.ship?.desktopExecArgs,
189
190
  };
190
191
  const missing = validateScaffoldInputs(scaffold);
191
192
  if (missing.length > 0) {
@@ -7,6 +7,8 @@ export interface ScaffoldInputs {
7
7
  command: string;
8
8
  kind: 'app' | 'cli';
9
9
  flatpak: ConfigDataFlatpak;
10
+ /** `gjsify.ship.desktopExecArgs`, when the project declares it. */
11
+ desktopExecArgs?: readonly string[];
10
12
  }
11
13
  /**
12
14
  * Validate that the config has the minimum set of fields required for
@@ -26,6 +26,7 @@ function toMetadataInputs(inputs) {
26
26
  command: inputs.command,
27
27
  kind: inputs.kind,
28
28
  metadata: inputs.flatpak,
29
+ desktopExecArgs: inputs.desktopExecArgs,
29
30
  channel: 'flathub',
30
31
  configKey: 'gjsify.flatpak',
31
32
  };
@@ -396,6 +396,7 @@ async function assemble(args) {
396
396
  command: settings.binaryName,
397
397
  kind: settings.kind,
398
398
  metadata,
399
+ desktopExecArgs: settings.desktopExecArgs,
399
400
  channel,
400
401
  configKey: 'gjsify.ship',
401
402
  copyrightYear: new Date(mtime * 1000).getUTCFullYear(),
@@ -1,8 +1,8 @@
1
1
  // `gjsify webext` — yargs subcommand-group dispatcher (ADR 0077).
2
2
  //
3
- // Wires {build, zip, dev, listing}; each is a self-contained `Command<>` in `subcommands.ts`,
3
+ // Wires {build, zip, dev, listing, submit}; each is a self-contained `Command<>` in `subcommands.ts`,
4
4
  // the same composition `flatpak/index.ts` uses.
5
- import { webextBuildCommand, webextDevCommand, webextListingCommand, webextZipCommand } from './subcommands.js';
5
+ import { webextBuildCommand, webextDevCommand, webextListingCommand, webextSubmitCommand, webextZipCommand, } from './subcommands.js';
6
6
  export const webextCommand = {
7
7
  command: 'webext <subcommand>',
8
8
  description: 'Browser extensions: build, zip and develop one WebExtension for Chrome, Edge, Firefox, Opera and Safari.',
@@ -11,6 +11,7 @@ export const webextCommand = {
11
11
  .command(webextZipCommand.command, webextZipCommand.description, webextZipCommand.builder, webextZipCommand.handler)
12
12
  .command(webextDevCommand.command, webextDevCommand.description, webextDevCommand.builder, webextDevCommand.handler)
13
13
  .command(webextListingCommand.command, webextListingCommand.description, webextListingCommand.builder, webextListingCommand.handler)
14
+ .command(webextSubmitCommand.command, webextSubmitCommand.description, webextSubmitCommand.builder, webextSubmitCommand.handler)
14
15
  .demandCommand(1)
15
16
  .strict(),
16
17
  };
@@ -27,4 +27,13 @@ interface ListingArgs {
27
27
  globals?: string;
28
28
  }
29
29
  export declare const webextListingCommand: Command<unknown, ListingArgs>;
30
+ interface SubmitArgs {
31
+ store: string;
32
+ zip?: string;
33
+ dryRun: boolean;
34
+ submit: boolean;
35
+ timeout?: number;
36
+ listingDir?: string;
37
+ }
38
+ export declare const webextSubmitCommand: Command<unknown, SubmitArgs>;
30
39
  export {};
@@ -6,8 +6,9 @@
6
6
  import { existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
7
7
  import { dirname, join, resolve, sep } from 'node:path';
8
8
  import { dispatchSite } from '../../utils/site-dispatch.js';
9
+ import { runSubmit } from '../../utils/webext/submit.js';
9
10
  import { buildWebext } from '../../utils/webext/build.js';
10
- import { resolveWebextConfig, selectTargets } from '../../utils/webext/config.js';
11
+ import { resolveSubmitProject, resolveWebextConfig, selectTargets, } from '../../utils/webext/config.js';
11
12
  import { defaultDevProfile, resolveWebExt, WEB_EXT_MISSING, webExtRunArgs, } from '../../utils/webext/launch.js';
12
13
  function loadConfig(cwd) {
13
14
  const manifest = join(cwd, 'package.json');
@@ -15,6 +16,12 @@ function loadConfig(cwd) {
15
16
  throw new Error(`gjsify webext: no package.json in ${cwd}.`);
16
17
  return resolveWebextConfig(JSON.parse(readFileSync(manifest, 'utf8')), cwd);
17
18
  }
19
+ function loadSubmitProject(cwd) {
20
+ const manifest = join(cwd, 'package.json');
21
+ if (!existsSync(manifest))
22
+ throw new Error(`gjsify webext: no package.json in ${cwd}.`);
23
+ return resolveSubmitProject(JSON.parse(readFileSync(manifest, 'utf8')), cwd);
24
+ }
18
25
  /** `--define K=V` entries on top of the config's map, the way `gjsify build` spells them. */
19
26
  function effectiveDefines(config, flags) {
20
27
  const out = { ...config.define };
@@ -271,3 +278,56 @@ export const webextListingCommand = {
271
278
  });
272
279
  },
273
280
  };
281
+ export const webextSubmitCommand = {
282
+ command: 'submit',
283
+ description: 'Upload the built zip to the Chrome Web Store or Edge Add-ons as a draft; --submit also asks for review (tags only).',
284
+ builder: (yargs) => yargs
285
+ .option('store', {
286
+ description: 'Which store (amo is not implemented: Firefox is distributed by the project itself).',
287
+ type: 'string',
288
+ choices: ['chrome', 'edge', 'amo'],
289
+ demandOption: true,
290
+ })
291
+ .option('zip', {
292
+ description: "The zip to upload (default: what `webext zip` writes for the store's target).",
293
+ type: 'string',
294
+ })
295
+ .option('dry-run', {
296
+ description: 'Check the credentials with one read call; upload nothing.',
297
+ type: 'boolean',
298
+ default: false,
299
+ })
300
+ .option('submit', {
301
+ description: 'Ask for review after the upload. Refused unless $GITHUB_REF is a tag.',
302
+ type: 'boolean',
303
+ default: false,
304
+ })
305
+ .option('timeout', {
306
+ description: 'Seconds to wait for the store to resolve an upload or submission (default: 600).',
307
+ type: 'number',
308
+ })
309
+ .option('listing-dir', {
310
+ description: 'Where `webext listing` wrote store.json (default: dist/listing).',
311
+ type: 'string',
312
+ })
313
+ .epilog('Credentials come from the environment only (see ADR 0077 § Amendment 1). Exit codes: 0 done or nothing to do, ' +
314
+ '1 rejected or failed, 3 accepted but unresolved (run again), 4 unverifiable. ' +
315
+ 'A submission stuck in review is cancelled in the Chrome dashboard (:cancelSubmission); this command never does.'),
316
+ handler: async (args) => {
317
+ const cwd = process.cwd();
318
+ const code = await runSubmit({
319
+ store: args.store,
320
+ zip: args.zip ? resolve(cwd, args.zip) : undefined,
321
+ dryRun: args.dryRun,
322
+ submit: args.submit,
323
+ timeoutSeconds: args.timeout,
324
+ listingDir: args.listingDir,
325
+ project: loadSubmitProject(cwd),
326
+ env: process.env,
327
+ out: (line) => console.log(line),
328
+ err: (line) => console.error(line),
329
+ });
330
+ if (code !== 0)
331
+ process.exitCode = code;
332
+ },
333
+ };
@@ -741,6 +741,14 @@ export interface ConfigDataShip extends AppMetadata {
741
741
  extraFiles?: Record<string, string>;
742
742
  /** Arguments the launcher appends before the user's own. */
743
743
  execArgs?: string[];
744
+ /**
745
+ * Arguments for the desktop entry's `Exec=` line, after the command and before the `%u`/`%f`
746
+ * field code. Separate from `execArgs` on purpose: `execArgs` is baked into the launcher
747
+ * script, so it applies to every invocation including the CLI; this one only changes what a
748
+ * menu click runs. An app whose binary is both CLI and GUI (`curlew` alone errors, `curlew
749
+ * window` opens the window) needs `["window"]` here and nothing in `execArgs`.
750
+ */
751
+ desktopExecArgs?: string[];
744
752
  /**
745
753
  * Further executables of the SAME package, beside the primary one `gjsify.main` names.
746
754
  *
@@ -10,6 +10,12 @@ export interface AppMetadataInputs {
10
10
  /** `'app'` renders a desktop-application component, `'cli'` a console one. */
11
11
  kind: 'app' | 'cli';
12
12
  metadata: AppMetadata;
13
+ /**
14
+ * Arguments placed in the desktop entry's `Exec=` after {@link command} and
15
+ * before the `%u`/`%f` field code (`gjsify.ship.desktopExecArgs`). Only the
16
+ * launcher entry sees them; the binary itself is unchanged.
17
+ */
18
+ desktopExecArgs?: readonly string[];
13
19
  /** Distribution channel (ADR 0113, 0139). `<url type="donation">` is emitted only where `support` is `external-link`. */
14
20
  channel?: string;
15
21
  /**
@@ -115,13 +115,32 @@ export function renderDesktopEntry(inputs) {
115
115
  return substitute(loadDesktopTemplate(), {
116
116
  NAME: inputs.name,
117
117
  SUMMARY: m.summary ?? inputs.name,
118
- COMMAND: `${inputs.command}${execFieldCode(mimetypes)}`,
118
+ COMMAND: [inputs.command, ...(inputs.desktopExecArgs ?? []).map((arg) => quoteExecArg(arg, inputs.configKey))].join(' ') + execFieldCode(mimetypes),
119
119
  APP_ID: inputs.appId,
120
120
  CATEGORIES_LINE: categoriesLine,
121
121
  KEYWORDS_LINE: keywordsLine,
122
122
  MIMETYPES_LINE: mimetypesLine,
123
123
  });
124
124
  }
125
+ const EXEC_RESERVED = /[\s"'\\><~|&;$*?#()`]/;
126
+ /**
127
+ * One `Exec=` argument per the Desktop Entry spec: `%` doubles (else it is a
128
+ * field code), an argument with a reserved character goes in double quotes with
129
+ * `"`, backtick, `$` and `\` backslash-escaped, and every backslash doubles
130
+ * again for the key-value string layer. A newline cannot be expressed at all.
131
+ */
132
+ function quoteExecArg(arg, configKey) {
133
+ if (/[\r\n]/.test(arg)) {
134
+ throw new Error(`${configKey}.desktopExecArgs contains ${JSON.stringify(arg)}: a newline cannot appear in a desktop entry's Exec= line.`);
135
+ }
136
+ const text = arg.replace(/%/g, '%%');
137
+ if (text === '')
138
+ return '""';
139
+ if (!EXEC_RESERVED.test(text))
140
+ return text;
141
+ const quoted = text.replace(/(["`$\\])/g, '\\$1').replace(/\\/g, '\\\\');
142
+ return `"${quoted}"`;
143
+ }
125
144
  /** The `Exec=` field code implied by the declared MIME types. */
126
145
  function execFieldCode(mimetypes) {
127
146
  if (mimetypes.some((t) => t.startsWith('x-scheme-handler/')))
@@ -44,9 +44,16 @@ export declare function pickFlatpakBuildKeys(preferred: ShipFlatpakOptions | und
44
44
  /** The branch a `ship` Flatpak is exported under when the project names none. */
45
45
  export declare const DEFAULT_SHIP_FLATPAK_BRANCH = "stable";
46
46
  /**
47
- * The scalable icon directory a `kind: 'app'` Flatpak drops before
47
+ * The cleanup entry that drops the app's OWN scalable icon
48
+ * (`scalable/apps/<appId>.svg`) from a `kind: 'app'` Flatpak before
48
49
  * `appstreamcli compose` reads the tree.
49
50
  *
51
+ * ONLY THAT FILE, never the `scalable` directory. The compose failure concerns
52
+ * the app icon alone; removing the whole directory also deleted every extra icon
53
+ * an app ships via `gjsify.ship.extraFiles` (Curlew's
54
+ * `scalable/apps/curlew-protocol-*.svg` badges vanished from the v0.2.0-rc.1
55
+ * Flatpak and the UI showed missing icons).
56
+ *
50
57
  * THE OTHER HALF OF `LAYOUTS.linux.icon`, and the half that cannot live in the
51
58
  * layout: the stage is one payload for four Linux formats (ADR 0024 § 2) and the
52
59
  * `.deb`, the `.rpm` and the AppImage all WANT the SVG — it is the icon GTK
@@ -75,10 +82,12 @@ export declare const DEFAULT_SHIP_FLATPAK_BRANCH = "stable";
75
82
  * icon without gdk-pixbuf at all. Reported as an `Upstream (AppStream, file by
76
83
  * hand)` issue rather than filed there (root AGENTS.md).
77
84
  */
78
- export declare const SCALABLE_ICONS_CLEANUP = "/share/icons/hicolor/scalable";
85
+ export declare function scalableAppIconCleanup(appId: string): string;
79
86
  export interface ShipFlatpakInput {
80
87
  ship: ConfigDataShip;
81
88
  flatpak: ConfigDataFlatpak;
89
+ /** The application id; names the one scalable icon the cleanup removes. */
90
+ appId: string;
82
91
  /** Decides the finish-args default: a GUI app needs a display, a CLI does not. */
83
92
  kind: 'app' | 'cli';
84
93
  }
@@ -89,9 +89,16 @@ export function pickFlatpakBuildKeys(preferred, legacy) {
89
89
  /** The branch a `ship` Flatpak is exported under when the project names none. */
90
90
  export const DEFAULT_SHIP_FLATPAK_BRANCH = 'stable';
91
91
  /**
92
- * The scalable icon directory a `kind: 'app'` Flatpak drops before
92
+ * The cleanup entry that drops the app's OWN scalable icon
93
+ * (`scalable/apps/<appId>.svg`) from a `kind: 'app'` Flatpak before
93
94
  * `appstreamcli compose` reads the tree.
94
95
  *
96
+ * ONLY THAT FILE, never the `scalable` directory. The compose failure concerns
97
+ * the app icon alone; removing the whole directory also deleted every extra icon
98
+ * an app ships via `gjsify.ship.extraFiles` (Curlew's
99
+ * `scalable/apps/curlew-protocol-*.svg` badges vanished from the v0.2.0-rc.1
100
+ * Flatpak and the UI showed missing icons).
101
+ *
95
102
  * THE OTHER HALF OF `LAYOUTS.linux.icon`, and the half that cannot live in the
96
103
  * layout: the stage is one payload for four Linux formats (ADR 0024 § 2) and the
97
104
  * `.deb`, the `.rpm` and the AppImage all WANT the SVG — it is the icon GTK
@@ -120,7 +127,9 @@ export const DEFAULT_SHIP_FLATPAK_BRANCH = 'stable';
120
127
  * icon without gdk-pixbuf at all. Reported as an `Upstream (AppStream, file by
121
128
  * hand)` issue rather than filed there (root AGENTS.md).
122
129
  */
123
- export const SCALABLE_ICONS_CLEANUP = '/share/icons/hicolor/scalable';
130
+ export function scalableAppIconCleanup(appId) {
131
+ return `/share/icons/hicolor/scalable/apps/${appId}.svg`;
132
+ }
124
133
  /**
125
134
  * Resolve the Flatpak half of `gjsify.ship`, reading the legacy block where the
126
135
  * new one is silent, and applying `ship`'s own defaults.
@@ -152,10 +161,12 @@ export function resolveShipFlatpakSettings(input) {
152
161
  // APPENDED to what the project declared, not defaulted to — the one entry
153
162
  // here that is not the author's choice. A project with its own `cleanup`
154
163
  // list would otherwise lose the entry that keeps its own Flatpak buildable
155
- // (see {@link SCALABLE_ICONS_CLEANUP}), and `??` cannot express "ours as
156
- // well as theirs". Deduplicated so a project that already wrote the glob —
157
- // the workaround this replaces — gets one, and in ITS position.
158
- cleanup: [...new Set([...(cleanup ?? []), ...(input.kind === 'app' ? [SCALABLE_ICONS_CLEANUP] : [])])],
164
+ // (see {@link scalableAppIconCleanup}), and `??` cannot express "ours as
165
+ // well as theirs". Deduplicated so a project that already wrote the old
166
+ // glob gets one, and in ITS position.
167
+ cleanup: [
168
+ ...new Set([...(cleanup ?? []), ...(input.kind === 'app' ? [scalableAppIconCleanup(input.appId)] : [])]),
169
+ ],
159
170
  };
160
171
  return { settings, warnings: fromLegacy.length === 0 ? [] : [deprecationWarning(fromLegacy)] };
161
172
  }
@@ -191,7 +191,7 @@ export function resolveShipSettings(input) {
191
191
  // Resolved here rather than in the packer, because the packer may run on a
192
192
  // host with no `package.json` at all (ADR 0024 § A2) — and because the
193
193
  // finish-args default depends on `kind`, which is a project fact.
194
- const flatpakSettings = resolveShipFlatpakSettings({ ship, flatpak, kind });
194
+ const flatpakSettings = resolveShipFlatpakSettings({ ship, flatpak, kind, appId });
195
195
  warnings.push(...flatpakSettings.warnings);
196
196
  // `gjsify.ship.nestedBundles`/`helperExecutables` describe what the DARWIN
197
197
  // `.app` carries — on any other layout they are IGNORED, with one combined
@@ -255,6 +255,7 @@ export function resolveShipSettings(input) {
255
255
  fontFiles: discovered.fontFiles,
256
256
  extraFiles: ship.extraFiles ?? {},
257
257
  execArgs: ship.execArgs ?? [],
258
+ desktopExecArgs: ship.desktopExecArgs ?? [],
258
259
  executables: resolveShipExecutables({
259
260
  declared: ship.executables,
260
261
  binaryName,
@@ -349,7 +349,7 @@ export interface ShipMimeType {
349
349
  * by the payload's own paths. There is no scriptlet to key off it either:
350
350
  * fontconfig scans the directory and caches lazily per user, measured rather
351
351
  * than assumed.
352
- * - `kind`, `execArgs` — read by the planner and the metadata renderers, all of
352
+ * - `kind`, `execArgs`, `desktopExecArgs` — read by the planner and the metadata renderers, all of
353
353
  * which have run by the time a stage exists. `appId` was on this line and
354
354
  * MOVED: the Flatpak packer needs it at pack time twice over — it is the
355
355
  * manifest's `id` and the ref `flatpak build-bundle` exports — and neither is
@@ -631,6 +631,14 @@ export interface ShipSettings extends PackSettings {
631
631
  extraFiles: Record<string, string>;
632
632
  /** Arguments appended to the launcher's `exec` line. */
633
633
  execArgs: string[];
634
+ /**
635
+ * Arguments for the desktop entry's `Exec=` line only (`gjsify.ship.desktopExecArgs`).
636
+ *
637
+ * Not `execArgs`: that one is baked into the launcher script and so reaches the CLI too,
638
+ * which breaks a binary that is both CLI and GUI (`curlew` errors on purpose,
639
+ * `curlew window` opens the window). This one leaves the launcher untouched.
640
+ */
641
+ desktopExecArgs: string[];
634
642
  /** The further executables with their entries; narrows {@link PackSettings.executables}. */
635
643
  executables: ShipExecutable[];
636
644
  /** Output root; `stage/`, `overlay/` and `out/` hang under it. */
@@ -67,6 +67,13 @@ export declare function iconSourceForSize(source: WebextIconSource, size: number
67
67
  * one to disk.
68
68
  */
69
69
  export declare function resolveWebextConfig(pkg: PackageShape, root: string, exists?: (path: string, kind: 'file' | 'dir') => boolean): ResolvedWebext;
70
+ /**
71
+ * What `webext submit` needs: the package name and version, the targets (to find the default zip)
72
+ * and the output folder. It uploads a zip somebody else built, so it neither needs nor checks the
73
+ * manifest, scripts or pages: a project with its own build script (Beifahrer) declares only
74
+ * `gjsify.webext.listing`, and must still be able to submit.
75
+ */
76
+ export declare function resolveSubmitProject(pkg: PackageShape, root: string): Pick<ResolvedWebext, 'root' | 'name' | 'version' | 'targets' | 'outDir'>;
70
77
  /** Narrow the configured targets to the ones a command was asked for. */
71
78
  export declare function selectTargets(config: ResolvedWebext, requested: readonly string[] | undefined): WebextTarget[];
72
79
  export {};
@@ -213,6 +213,46 @@ export function resolveWebextConfig(pkg, root, exists = defaultExists) {
213
213
  minify: block.minify ?? true,
214
214
  };
215
215
  }
216
+ /**
217
+ * What `webext submit` needs: the package name and version, the targets (to find the default zip)
218
+ * and the output folder. It uploads a zip somebody else built, so it neither needs nor checks the
219
+ * manifest, scripts or pages: a project with its own build script (Beifahrer) declares only
220
+ * `gjsify.webext.listing`, and must still be able to submit.
221
+ */
222
+ export function resolveSubmitProject(pkg, root) {
223
+ const raw = pkg.gjsify?.webext;
224
+ if (raw !== undefined && !isRecord(raw))
225
+ throw new Error('gjsify webext: `gjsify.webext` must be an object.');
226
+ const block = (raw ?? {});
227
+ const problems = [];
228
+ const targetIds = block.targets ?? [...DEFAULT_WEBEXT_TARGETS];
229
+ const targets = [];
230
+ if (!Array.isArray(targetIds) || targetIds.length === 0) {
231
+ problems.push('`targets` must be a non-empty array of target names.');
232
+ }
233
+ else {
234
+ for (const id of targetIds) {
235
+ try {
236
+ targets.push(parseWebextTarget(String(id)));
237
+ }
238
+ catch (err) {
239
+ problems.push(err.message.replace(/^gjsify webext: /, ''));
240
+ }
241
+ }
242
+ }
243
+ if (problems.length > 0) {
244
+ throw new Error(`gjsify webext: \`gjsify.webext\` in ${join(root, 'package.json')}:\n - ${problems.join('\n - ')}`);
245
+ }
246
+ return {
247
+ root,
248
+ name: block.name ?? defaultArtifactName(pkg.name),
249
+ version: pkg.version ?? '0.0.0',
250
+ targets,
251
+ outDir: isAbsolute(block.outDir ?? '.output')
252
+ ? block.outDir
253
+ : resolve(root, block.outDir ?? '.output'),
254
+ };
255
+ }
216
256
  function defaultExists(path, kind) {
217
257
  if (!existsSync(path))
218
258
  return false;
@@ -0,0 +1,167 @@
1
+ import { type StoreBackend, type StoreId, type StorePublishInput, type StoreUploadInput } from './index.js';
2
+ /**
3
+ * What a drive ENDED as. Nine, because the store's three asynchronous answers
4
+ * ("busy", "accepted", "I cannot say") are facts a caller acts on differently
5
+ * and a boolean would throw all three away.
6
+ */
7
+ export type SubmitVerdict =
8
+ /** The draft holds this version and no publish was asked for — `submit` without `--submit`. */
9
+ 'uploaded'
10
+ /** The store confirms a submission for THIS version: Chrome `PENDING_REVIEW`, or Edge's publish operation `Succeeded`. */
11
+ | 'submitted'
12
+ /** The store reports this version as live. Chrome only; Edge has no endpoint that says so. */
13
+ | 'published'
14
+ /** The store was already on this version, so this run had nothing to do (`StoreVersionAlreadyThereError`). */
15
+ | 'already-there'
16
+ /** A submission is in review and this run changed nothing. Not a failure — see {@link SUBMIT_EXIT_CODES}. */
17
+ | 'in-review'
18
+ /** The store refused it: a 4xx that is not 408/429, or an operation it reported as failed. A re-run gets the same answer. */
19
+ | 'rejected'
20
+ /** A repeatable failure that kept repeating — a 5xx, a 429, a transport error — until the retries or the deadline ran out. */
21
+ | 'failed'
22
+ /** The store accepted something and never resolved it inside the deadline. The caller may call again later. */
23
+ | 'unresolved'
24
+ /** The store answered with a handle this client cannot read, so the outcome is not knowable from here. A gap in the backend, named as one. */
25
+ | 'unverifiable';
26
+ /**
27
+ * Exit code per verdict. The three decisions in it:
28
+ *
29
+ * **`in-review` exits 0.** The alternative — its own non-zero code — was
30
+ * considered and rejected. The state means the PREVIOUS submit worked and the
31
+ * store is busy with it; nothing in this run failed, nothing was corrupted, and
32
+ * the way out (Chrome's `:cancelSubmission`; Edge documents none) is the
33
+ * person's decision and never this command's. The step that calls `submit` sits
34
+ * behind a GitHub Environment with a required reviewer, so a red there costs a
35
+ * human a re-run of a workflow that did its job — and a check that cries wolf
36
+ * is one somebody switches off, the lesson `publish-readback.ts` paid for. What
37
+ * keeps that honest is that exit 0 here never CLAIMS a submission: the verdict
38
+ * is its own value, `detail` names which version is blocking, and a caller that
39
+ * wants a red can read `verdict` and decide. The plan behind this slice and
40
+ * ADR 0077 § Amendment 1 both say the same ("three outcomes, not one non-zero
41
+ * exit"), so this is also the already-recorded decision.
42
+ *
43
+ * **`failed` and `rejected` share exit 1** — the operator's next move is the
44
+ * same, look at `detail` — while `unresolved` gets its own code, because its
45
+ * next move is the opposite one: call again later, unchanged, and expect
46
+ * progress. Those two must never be one number.
47
+ *
48
+ * **`2` is not in this table.** `cli-app.ts`'s `.fail()` handler exits 2 for a
49
+ * usage error, so a store outcome spelled 2 would be indistinguishable from a
50
+ * mistyped flag.
51
+ */
52
+ export declare const SUBMIT_EXIT_CODES: Readonly<Record<SubmitVerdict, number>>;
53
+ /**
54
+ * Default deadline for the whole drive: 600 s.
55
+ *
56
+ * What this waits for is INGESTION and the resolution of an operation, never a
57
+ * review verdict — a review takes days at both stores and no CI job may sit on
58
+ * one. 600 s is `publish-readback.ts`'s budget, chosen there against measured
59
+ * registry lag; nothing comparable has been measured against a store, so the
60
+ * number is borrowed rather than derived, and `--timeout` is what a real
61
+ * observation changes. A non-positive value waits not at all: every async step
62
+ * is read exactly once and an unfinished one ends the drive at `unresolved`.
63
+ */
64
+ export declare const DEFAULT_SUBMIT_TIMEOUT_MS = 600000;
65
+ /** How often a repeatable failure of one call is repeated before the drive gives up. */
66
+ export declare const MAX_SAFE_RETRIES = 3;
67
+ /** Delay before the poll after `round` (0-based). */
68
+ export declare function pollBackoffFor(round: number): number;
69
+ /** Delay before retry `round` (0-based) of a repeatable failure; throttling gets its own, longer table. */
70
+ export declare function retryBackoffFor(round: number, throttled: boolean): number;
71
+ /** Which call failed, for {@link retryDecision}. A verb, not an endpoint: what matters is whether repeating it WRITES. */
72
+ export type StoreVerb = 'read' | 'upload' | 'publish';
73
+ /**
74
+ * Is this failure's CLASS one that a repeat of the same request could survive?
75
+ *
76
+ * Only {@link StoreApiError} can be: the two idempotent skips are answers, not
77
+ * failures, and anything else reaching here is a defect in this client, which a
78
+ * repeat cannot fix.
79
+ */
80
+ export declare function isRepeatableFailure(error: unknown): boolean;
81
+ /** True for the failure class whose remedy is specifically "wait longer than usual". */
82
+ export declare function isThrottled(error: unknown): boolean;
83
+ export type RetryDecision =
84
+ /** Send the same request again after a backoff. */
85
+ 'retry'
86
+ /** Do not resend. Ask the store what happened first — only `publish` reaches this. */
87
+ | 'verify-first'
88
+ /** The store has answered the question; a repeat gets the same answer. */
89
+ | 'fatal';
90
+ /**
91
+ * What to do about `error` from `verb`.
92
+ *
93
+ * The asymmetry between the two POSTs is the whole point: an `upload` writes the
94
+ * draft, which is a SLOT — sending the same zip twice leaves the same draft, so
95
+ * a repeat costs bytes. A `publish` CREATES a submission, so a repeat after a
96
+ * transport failure risks a second one against a store that already took the
97
+ * first; `status()` is the only thing allowed to decide that.
98
+ */
99
+ export declare function retryDecision(error: unknown, verb: StoreVerb): RetryDecision;
100
+ /** Where a drive was when a phase ended. */
101
+ export type SubmitPhaseName = 'upload' | 'await-upload' | 'publish' | 'await-publish' | 'confirm';
102
+ /** One phase of a drive, appended when it ends. The subcommand prints these in order. */
103
+ export interface SubmitPhase {
104
+ readonly phase: SubmitPhaseName;
105
+ /** Requests this phase sent, retries and polls included. */
106
+ readonly requests: number;
107
+ /** Milliseconds since the drive started, on the injected clock. */
108
+ readonly elapsedMs: number;
109
+ /** The store's own account of what happened, redacted. */
110
+ readonly detail: string;
111
+ }
112
+ /**
113
+ * What a drive established. A pure value: no printing, no exiting, no `process`
114
+ * — the subcommand (S6) renders it and exits {@link SubmitResult.exitCode}.
115
+ */
116
+ export interface SubmitResult {
117
+ readonly store: StoreId;
118
+ readonly version: string;
119
+ readonly verdict: SubmitVerdict;
120
+ /** `SUBMIT_EXIT_CODES[verdict]`, carried so a caller cannot re-derive it differently. */
121
+ readonly exitCode: number;
122
+ /** One line naming the evidence the verdict rests on, redacted. */
123
+ readonly detail: string;
124
+ readonly phases: readonly SubmitPhase[];
125
+ readonly elapsedMs: number;
126
+ /** Requests the whole drive sent. */
127
+ readonly requests: number;
128
+ /** How many of them were repeats of a failed one. */
129
+ readonly retries: number;
130
+ /** True when calling again later, unchanged, can make progress on its own. */
131
+ readonly retryable: boolean;
132
+ }
133
+ export interface SubmitDriveInput {
134
+ readonly backend: StoreBackend;
135
+ readonly upload: StoreUploadInput;
136
+ /**
137
+ * Absent = upload the draft and stop, which is `submit`'s default; `--submit`
138
+ * is what fills this in. A draft that is never submitted is a complete,
139
+ * successful outcome and not half of one.
140
+ */
141
+ readonly publish?: StorePublishInput;
142
+ }
143
+ export interface SubmitDriveOptions {
144
+ /** `--timeout`'s value in ms. Default {@link DEFAULT_SUBMIT_TIMEOUT_MS}; `<= 0` waits not at all. */
145
+ readonly timeoutMs?: number;
146
+ /** Injected in tests — nothing here calls `setTimeout` itself. */
147
+ readonly sleep?: (ms: number) => Promise<void>;
148
+ readonly now?: () => number;
149
+ /** Called per step under `GJSIFY_WEBEXT_DEBUG`. Already redacted. */
150
+ readonly log?: (msg: string) => void;
151
+ /**
152
+ * Values that may never appear in a phase detail, the result or a log line —
153
+ * `secretValuesOf(store, credentials)`. The backends redact their own
154
+ * messages; this is the second net, because a detail here is assembled from
155
+ * vendor text and vendor text is where an echoed credential turns up.
156
+ */
157
+ readonly secrets?: readonly string[];
158
+ }
159
+ /**
160
+ * Drive one version into one store and say what the store ended up at.
161
+ *
162
+ * upload → wait for the ingest → publish → wait for the submission, each step
163
+ * bounded by ONE shared deadline: two budgets would make the wall clock twice
164
+ * what `--timeout` promises, the same mistake `probeTimeoutFor` was written to
165
+ * stop in the read-back.
166
+ */
167
+ export declare function driveSubmission(input: SubmitDriveInput, options?: SubmitDriveOptions): Promise<SubmitResult>;