@xlinklight/publishing 3.3.0 → 3.4.0

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.
Files changed (119) hide show
  1. package/README.md +23 -3
  2. package/dist/src/acceptance-delivery-binding.d.ts +20 -0
  3. package/dist/src/acceptance-delivery-binding.js +59 -0
  4. package/dist/src/acceptance.d.ts +49 -0
  5. package/dist/src/acceptance.js +79 -0
  6. package/dist/src/client.d.ts +71 -0
  7. package/dist/src/client.js +146 -0
  8. package/dist/src/index.d.ts +6 -0
  9. package/dist/src/index.js +3 -0
  10. package/dist/src/node/acceptance-delivery.d.ts +34 -0
  11. package/dist/src/node/acceptance-delivery.js +88 -0
  12. package/dist/src/node/activation.d.ts +5 -0
  13. package/dist/src/node/activation.js +3 -0
  14. package/dist/src/node/authorization.d.ts +31 -0
  15. package/dist/src/node/authorization.js +76 -0
  16. package/dist/src/node/cli.d.ts +2 -0
  17. package/dist/src/node/cli.js +22 -0
  18. package/dist/src/node/index.d.ts +20 -0
  19. package/dist/src/node/index.js +11 -0
  20. package/dist/src/node/journal-directory.d.ts +2 -0
  21. package/dist/src/node/journal-directory.js +121 -0
  22. package/dist/src/node/journal.d.ts +49 -0
  23. package/dist/src/node/journal.js +280 -0
  24. package/dist/src/node/local-json-file.d.ts +3 -0
  25. package/dist/src/node/local-json-file.js +49 -0
  26. package/dist/src/node/publishing-command.d.ts +46 -0
  27. package/dist/src/node/publishing-command.js +268 -0
  28. package/dist/src/node/session.d.ts +95 -0
  29. package/dist/src/node/session.js +223 -0
  30. package/dist/src/node/solution-package.d.ts +55 -0
  31. package/dist/src/node/solution-package.js +217 -0
  32. package/dist/src/node/source-error.d.ts +10 -0
  33. package/dist/src/node/source-error.js +15 -0
  34. package/dist/src/node/source-producer.d.ts +5 -0
  35. package/dist/src/node/source-producer.js +145 -0
  36. package/dist/src/node/terminal-network.d.ts +23 -0
  37. package/dist/src/node/terminal-network.js +122 -0
  38. package/dist/src/node/workflow.d.ts +74 -0
  39. package/dist/src/node/workflow.js +467 -0
  40. package/dist/src/package.d.ts +38 -0
  41. package/dist/src/package.js +74 -0
  42. package/dist/src/protocol.d.ts +83 -0
  43. package/dist/src/protocol.js +105 -0
  44. package/dist/src/shared/activation-types.d.ts +37 -0
  45. package/dist/src/shared/activation-types.js +1 -0
  46. package/dist/src/shared/activation.d.ts +17 -0
  47. package/dist/src/shared/activation.js +111 -0
  48. package/dist/src/shared/records.d.ts +10 -0
  49. package/dist/src/shared/records.js +26 -0
  50. package/dist/src/shared/release-version.d.ts +4 -0
  51. package/dist/src/shared/release-version.js +15 -0
  52. package/dist/src/worker/activation.d.ts +12 -0
  53. package/dist/src/worker/activation.js +11 -0
  54. package/dist/src/worker/durable-retention.d.ts +9 -0
  55. package/dist/src/worker/durable-retention.js +96 -0
  56. package/dist/src/worker/index.d.ts +12 -0
  57. package/dist/src/worker/index.js +7 -0
  58. package/dist/src/worker/journal.d.ts +129 -0
  59. package/dist/src/worker/journal.js +328 -0
  60. package/dist/src/worker/package.d.ts +60 -0
  61. package/dist/src/worker/package.js +116 -0
  62. package/dist/src/worker/release-retention.d.ts +34 -0
  63. package/dist/src/worker/release-retention.js +27 -0
  64. package/dist/src/worker/release.d.ts +22 -0
  65. package/dist/src/worker/release.js +59 -0
  66. package/dist/src/worker/runtime.d.ts +47 -0
  67. package/dist/src/worker/runtime.js +98 -0
  68. package/dist/src/worker/service.d.ts +128 -0
  69. package/dist/src/worker/service.js +520 -0
  70. package/package.json +23 -14
  71. package/src/acceptance-delivery-binding.mjs +0 -49
  72. package/src/acceptance.d.mts +0 -24
  73. package/src/acceptance.mjs +0 -67
  74. package/src/client.d.mts +0 -16
  75. package/src/client.mjs +0 -74
  76. package/src/index.d.mts +0 -6
  77. package/src/index.mjs +0 -3
  78. package/src/node/acceptance-delivery.d.mts +0 -11
  79. package/src/node/acceptance-delivery.mjs +0 -70
  80. package/src/node/activation.d.mts +0 -8
  81. package/src/node/activation.mjs +0 -3
  82. package/src/node/authorization.d.mts +0 -8
  83. package/src/node/authorization.mjs +0 -49
  84. package/src/node/cli.mjs +0 -12
  85. package/src/node/index.d.mts +0 -17
  86. package/src/node/index.mjs +0 -9
  87. package/src/node/journal.d.mts +0 -13
  88. package/src/node/journal.mjs +0 -135
  89. package/src/node/publishing-command.d.mts +0 -20
  90. package/src/node/publishing-command.mjs +0 -104
  91. package/src/node/session.d.mts +0 -25
  92. package/src/node/session.mjs +0 -134
  93. package/src/node/solution-package.d.mts +0 -15
  94. package/src/node/solution-package.mjs +0 -113
  95. package/src/node/source-error.d.mts +0 -5
  96. package/src/node/source-error.mjs +0 -9
  97. package/src/node/source-producer.mjs +0 -103
  98. package/src/node/workflow.d.mts +0 -37
  99. package/src/node/workflow.mjs +0 -320
  100. package/src/package.d.mts +0 -11
  101. package/src/package.mjs +0 -36
  102. package/src/protocol.d.mts +0 -27
  103. package/src/protocol.mjs +0 -50
  104. package/src/shared/activation.d.mts +0 -5
  105. package/src/shared/activation.mjs +0 -64
  106. package/src/worker/activation.d.mts +0 -7
  107. package/src/worker/activation.mjs +0 -4
  108. package/src/worker/index.d.mts +0 -6
  109. package/src/worker/index.mjs +0 -6
  110. package/src/worker/journal.d.mts +0 -21
  111. package/src/worker/journal.mjs +0 -151
  112. package/src/worker/package.d.mts +0 -16
  113. package/src/worker/package.mjs +0 -32
  114. package/src/worker/release.d.mts +0 -7
  115. package/src/worker/release.mjs +0 -21
  116. package/src/worker/runtime.d.mts +0 -4
  117. package/src/worker/runtime.mjs +0 -23
  118. package/src/worker/service.d.mts +0 -41
  119. package/src/worker/service.mjs +0 -251
@@ -0,0 +1,145 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { createRequire, findPackageJSON } from 'node:module';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { validatePortableRelativePath } from '@openge/forge-path-safety';
6
+ import { protocolRecord, publishingError } from '../protocol.js';
7
+ export const defaultProducer = 'deployment/publishing.mjs';
8
+ const maximumSourceBytes = 65536n;
9
+ const fail = (code) => publishingError('SOURCE_' + code);
10
+ const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
11
+ const sameFile = (before, after) => ['dev', 'ino', 'size', 'mtimeNs', 'ctimeNs'].every(key => before[key] === after[key]);
12
+ const readOnlyFlags = fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0) | (fs.constants.O_NONBLOCK ?? 0);
13
+ export function validateLocalProducer(relative) {
14
+ try {
15
+ if (validatePortableRelativePath(relative) === relative && relative.endsWith('.mjs'))
16
+ return relative;
17
+ }
18
+ catch {
19
+ throw fail('PATH_INVALID');
20
+ }
21
+ throw fail('PATH_INVALID');
22
+ }
23
+ async function localProducerFile(root, relative) {
24
+ const parts = relative.split('/');
25
+ let current = root;
26
+ for (const [index, part] of parts.entries()) {
27
+ current = path.join(current, part);
28
+ const info = await fs.lstat(current, { bigint: true });
29
+ if (info.isSymbolicLink() || await fs.realpath(current) !== current || (index === parts.length - 1 ? !info.isFile() || info.nlink !== 1n || info.size > maximumSourceBytes : !info.isDirectory()))
30
+ throw fail('PATH_INVALID');
31
+ }
32
+ return current;
33
+ }
34
+ async function readManifest(file, { checkout = false } = {}) {
35
+ let before;
36
+ try {
37
+ before = await fs.lstat(file, { bigint: true });
38
+ }
39
+ catch (error) {
40
+ if (checkout && error instanceof Error && 'code' in error && error.code === 'ENOENT')
41
+ return undefined;
42
+ throw error;
43
+ }
44
+ if (!before.isFile() || before.size > maximumSourceBytes || checkout && before.nlink !== 1n)
45
+ throw fail('METADATA_INVALID');
46
+ const handle = await fs.open(file, readOnlyFlags);
47
+ try {
48
+ if (!sameFile(before, await handle.stat({ bigint: true })))
49
+ throw fail('METADATA_INVALID');
50
+ const bytes = Buffer.alloc(Number(before.size) + 1);
51
+ let offset = 0;
52
+ while (offset < bytes.length) {
53
+ const { bytesRead } = await handle.read(bytes, offset, bytes.length - offset, offset);
54
+ if (bytesRead === 0)
55
+ break;
56
+ offset += bytesRead;
57
+ }
58
+ if (offset !== Number(before.size) || !sameFile(before, await handle.stat({ bigint: true })) || !sameFile(before, await fs.lstat(file, { bigint: true })))
59
+ throw fail('METADATA_INVALID');
60
+ const value = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes.subarray(0, offset)));
61
+ if (!record(value))
62
+ throw fail('METADATA_INVALID');
63
+ return value;
64
+ }
65
+ finally {
66
+ await handle.close();
67
+ }
68
+ }
69
+ export async function checkoutReleaseVersion(root, packageName) {
70
+ const manifest = await readManifest(path.join(root, 'package.json'), { checkout: true });
71
+ if (!manifest || manifest.name === undefined && manifest.version === undefined)
72
+ return undefined;
73
+ if (manifest.name !== packageName || typeof manifest.version !== 'string' ||
74
+ !/^(?:0|[1-9]\d{0,7})(?:\.(?:0|[1-9]\d{0,7})){2}$/.test(manifest.version))
75
+ throw fail('PACKAGE_BINDING_INVALID');
76
+ return manifest.version;
77
+ }
78
+ export async function checkoutRequiresAcceptanceDelivery(root) {
79
+ const manifest = await readManifest(path.join(root, 'package.json'), { checkout: true });
80
+ const metadata = manifest?.linkLight;
81
+ const mode = record(metadata) ? metadata.acceptanceDelivery : undefined;
82
+ if (mode !== undefined && mode !== 'required')
83
+ throw fail('METADATA_INVALID');
84
+ return mode === 'required';
85
+ }
86
+ function contains(parent, child) {
87
+ const relative = path.relative(parent, child);
88
+ return relative !== '' && relative !== '..' && !relative.startsWith('..' + path.sep) && !path.isAbsolute(relative);
89
+ }
90
+ async function packageProducerFile(root, manifest, checkout, selection) {
91
+ if (!protocolRecord(selection, ['module']) || typeof selection.module !== 'string' || selection.module.length > 512)
92
+ throw fail('METADATA_INVALID');
93
+ const specifier = selection.module;
94
+ const match = /^((?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*)(\/[A-Za-z0-9_-][A-Za-z0-9._-]*)+$/.exec(specifier);
95
+ if (match?.[0] !== specifier)
96
+ throw fail('METADATA_INVALID');
97
+ const packageName = match[1];
98
+ if (![checkout.dependencies, checkout.devDependencies].some(group => record(group) && Object.hasOwn(group, packageName) && typeof group[packageName] === 'string' && group[packageName].trim()))
99
+ throw fail('PACKAGE_UNDECLARED');
100
+ const modules = path.join(root, 'node_modules');
101
+ if (await fs.realpath(modules) !== modules)
102
+ throw fail('PATH_INVALID');
103
+ const installed = await fs.realpath(path.join(modules, ...packageName.split('/')));
104
+ if (!contains(modules, installed))
105
+ throw fail('PATH_INVALID');
106
+ const dependency = await readManifest(path.join(installed, 'package.json'));
107
+ if (dependency.name !== packageName || dependency.exports == null)
108
+ throw fail('PACKAGE_EXPORT_INVALID');
109
+ const file = await fs.realpath(createRequire(manifest).resolve(specifier));
110
+ if (!contains(installed, file))
111
+ throw fail('PATH_INVALID');
112
+ if (!file.endsWith('.mjs')) {
113
+ if (!file.endsWith('.js'))
114
+ throw fail('PATH_INVALID');
115
+ const scope = findPackageJSON(pathToFileURL(file));
116
+ if (!scope)
117
+ throw fail('PATH_INVALID');
118
+ const scopePath = await fs.realpath(scope);
119
+ if (!contains(installed, scopePath))
120
+ throw fail('PATH_INVALID');
121
+ const metadata = scopePath === path.join(installed, 'package.json') ? dependency : await readManifest(scope);
122
+ if (metadata.type !== 'module')
123
+ throw fail('PATH_INVALID');
124
+ }
125
+ const info = await fs.lstat(file, { bigint: true });
126
+ if (!info.isFile() || info.size > maximumSourceBytes)
127
+ throw fail('PATH_INVALID');
128
+ return file;
129
+ }
130
+ export async function selectProducerFile(root, explicit) {
131
+ if (explicit !== undefined)
132
+ return localProducerFile(root, explicit);
133
+ const manifest = path.join(root, 'package.json'), checkout = await readManifest(manifest, { checkout: true });
134
+ const metadata = checkout?.linkLight;
135
+ if (metadata !== undefined && !record(metadata))
136
+ throw fail('METADATA_INVALID');
137
+ const selection = metadata?.publishingProducer;
138
+ if (selection === undefined)
139
+ return localProducerFile(root, defaultProducer);
140
+ if (typeof selection === 'string')
141
+ return localProducerFile(root, validateLocalProducer(selection));
142
+ if (!checkout)
143
+ throw fail('METADATA_INVALID');
144
+ return packageProducerFile(root, manifest, checkout, selection);
145
+ }
@@ -0,0 +1,23 @@
1
+ import type { PublishingMetadataTransport } from '../protocol.js';
2
+ type Origins = {
3
+ serviceUrl: string;
4
+ coreOrigin: string;
5
+ deliveryOrigin?: string;
6
+ };
7
+ type Discover = typeof discoverWindowsProxyRoutes;
8
+ /** Resolve a single Windows proxy-settings snapshot for the supplied HTTPS origins. */
9
+ export declare function discoverWindowsProxyRoutes(origins: readonly string[], signal?: AbortSignal): Promise<readonly (string | null)[]>;
10
+ export declare function openPublishingTerminalNetwork(configuration: Origins, { signal, proxy }?: {
11
+ signal?: AbortSignal;
12
+ proxy?: string;
13
+ }): Promise<{
14
+ request: typeof fetch;
15
+ metadataTransport: PublishingMetadataTransport;
16
+ close(): Promise<void>;
17
+ } | undefined>;
18
+ export declare function openPublishingNetwork(configuration: Origins, proxyOverride?: string, signal?: AbortSignal, discover?: Discover | null): Promise<{
19
+ request: typeof fetch;
20
+ metadataTransport: PublishingMetadataTransport;
21
+ close(): Promise<void>;
22
+ } | undefined>;
23
+ export {};
@@ -0,0 +1,122 @@
1
+ import { execFile } from 'node:child_process';
2
+ import path from 'node:path';
3
+ import { publishingError } from '../protocol.js';
4
+ const fail = (code) => publishingError('NETWORK_' + code);
5
+ function localProxy(value) {
6
+ if (typeof value !== 'string' || !/^http:\/\/(?:127\.0\.0\.1|\[::1\])(?::[1-9]\d{0,4})?\/?$/.test(value))
7
+ throw fail('CONFIG_INVALID');
8
+ let url;
9
+ try {
10
+ url = new URL(value);
11
+ }
12
+ catch {
13
+ throw fail('CONFIG_INVALID');
14
+ }
15
+ return url.origin;
16
+ }
17
+ function httpsOrigin(value) {
18
+ if (typeof value !== 'string' || value.length > 2048)
19
+ throw fail('ORIGIN_INVALID');
20
+ const url = URL.parse(value);
21
+ if (url?.protocol !== 'https:' || url.origin !== value)
22
+ throw fail('ORIGIN_INVALID');
23
+ return value;
24
+ }
25
+ // A fresh, bounded child sees only the public origins. The Windows API applies the existing
26
+ // system bypass/PAC rules to each origin. Neither PowerShell nor this command changes them.
27
+ const windowsQuery = `$ErrorActionPreference='Stop'
28
+ try {
29
+ $origins=ConvertFrom-Json ([Console]::In.ReadToEnd())
30
+ $system=[System.Net.WebRequest]::GetSystemWebProxy()
31
+ $routes=New-Object 'System.Collections.Generic.List[object]'
32
+ foreach($entry in $origins){
33
+ $uri=[Uri]$entry
34
+ $proxy=$system.GetProxy($uri)
35
+ if($system.IsBypassed($uri) -or ($null -ne $proxy -and $proxy.AbsoluteUri -eq $uri.AbsoluteUri)){$routes.Add($null)}
36
+ elseif($null -eq $proxy){exit 1}
37
+ elseif($proxy.Scheme -eq 'http' -and ($proxy.Host -eq '127.0.0.1' -or $proxy.Host -eq '[::1]') -and !$proxy.UserInfo -and $proxy.AbsolutePath -eq '/' -and !$proxy.Query -and !$proxy.Fragment){$routes.Add($proxy.GetLeftPart([UriPartial]::Authority))}
38
+ else {exit 2}
39
+ }
40
+ [Console]::Out.Write((ConvertTo-Json -InputObject $routes.ToArray() -Compress))
41
+ } catch {exit 1}`;
42
+ /** Resolve a single Windows proxy-settings snapshot for the supplied HTTPS origins. */
43
+ export async function discoverWindowsProxyRoutes(origins, signal) {
44
+ if (!Array.isArray(origins) || origins.length < 1 || origins.length > 16)
45
+ throw fail('ORIGIN_INVALID');
46
+ const targets = Array.from(origins, httpsOrigin);
47
+ const systemRoot = process.env.SystemRoot;
48
+ if (signal?.aborted || process.platform !== 'win32' || !systemRoot || !path.isAbsolute(systemRoot))
49
+ throw fail('SYSTEM_PROXY_UNAVAILABLE');
50
+ const exe = path.join(systemRoot, 'System32/WindowsPowerShell/v1.0/powershell.exe');
51
+ return new Promise((resolve, reject) => {
52
+ const child = execFile(exe, ['-NoLogo', '-NoProfile', '-NonInteractive', '-EncodedCommand', Buffer.from(windowsQuery, 'utf16le').toString('base64')], { encoding: 'utf8', env: { SystemRoot: systemRoot, WINDIR: systemRoot }, windowsHide: true, timeout: 5000, maxBuffer: 8192, signal }, (error, stdout) => {
53
+ if (error) {
54
+ reject(fail('SYSTEM_PROXY_UNAVAILABLE'));
55
+ return;
56
+ }
57
+ try {
58
+ const routes = JSON.parse(stdout);
59
+ if (!Array.isArray(routes) || routes.length !== targets.length)
60
+ throw Error();
61
+ resolve(routes.map(route => route === null ? null : localProxy(route)));
62
+ }
63
+ catch {
64
+ reject(fail('SYSTEM_PROXY_UNAVAILABLE'));
65
+ }
66
+ });
67
+ child.stdin?.on('error', () => { });
68
+ child.stdin?.end(JSON.stringify(targets));
69
+ });
70
+ }
71
+ export function openPublishingTerminalNetwork(configuration, { signal, proxy } = {}) {
72
+ return openPublishingNetwork(configuration, proxy, signal, process.platform === 'win32' ? discoverWindowsProxyRoutes : null);
73
+ }
74
+ export async function openPublishingNetwork(configuration, proxyOverride, signal, discover = null) {
75
+ signal?.throwIfAborted();
76
+ if (!configuration || typeof configuration !== 'object')
77
+ throw fail('ORIGIN_INVALID');
78
+ const publisher = httpsOrigin(configuration.serviceUrl), core = httpsOrigin(configuration.coreOrigin);
79
+ const delivery = configuration.deliveryOrigin === undefined ? undefined : httpsOrigin(configuration.deliveryOrigin);
80
+ const origins = [...new Set([publisher, core, ...(delivery ? [delivery] : [])])];
81
+ const proxy = proxyOverride === undefined ? undefined : localProxy(proxyOverride);
82
+ const routes = proxy ? origins.map(() => proxy) : await discover?.(origins, signal);
83
+ if (!routes)
84
+ return;
85
+ if (routes.length !== origins.length)
86
+ throw fail('SYSTEM_PROXY_UNAVAILABLE');
87
+ if (routes.every(route => route === null))
88
+ return;
89
+ const selection = new Map(origins.map((origin, index) => [origin, routes[index] === null ? null : localProxy(routes[index])]));
90
+ let forge;
91
+ try {
92
+ forge = await import('@openge/forge-http-transport/node');
93
+ }
94
+ catch {
95
+ throw fail('TRANSPORT_REQUIRED');
96
+ }
97
+ const transports = new Map();
98
+ for (const proxy of new Set(selection.values()))
99
+ transports.set(proxy, forge.createNodeHttpTransport(proxy ? { route: 'proxy', proxyUrl: proxy, noProxy: '' } : { route: 'direct' }));
100
+ const request = async (input, init) => {
101
+ const url = new URL(input instanceof Request ? input.url : String(input));
102
+ const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
103
+ if (url.username || url.password || url.hash || !([publisher, delivery].includes(url.origin)) ||
104
+ (headers.has('authorization') && url.origin !== publisher) || ((headers.has('x-link-light-signature') || headers.has('x-link-light-binding')) && url.origin !== delivery) ||
105
+ headers.has('host') || headers.has('proxy-authorization') || headers.has('cookie'))
106
+ throw fail('ORIGIN_INVALID');
107
+ return transports.get(selection.get(url.origin) ?? null).fetch(input, init);
108
+ };
109
+ const metadataTransport = async (address, options) => {
110
+ const url = new URL(address);
111
+ if (url.origin !== core || url.username || url.password || url.hash || url.search ||
112
+ !/^\/api\/registry\/releases\/sha256%3A[a-f0-9]{64}$/.test(url.pathname))
113
+ throw fail('ORIGIN_INVALID');
114
+ const platform = await import('@xlinklight/platform/server'), proxy = selection.get(core);
115
+ return proxy ? platform.createProxiedReleaseMetadataTransport(proxy)(address, options) : platform.requestReleaseMetadata(address, options);
116
+ };
117
+ return { request, metadataTransport, async close() {
118
+ const results = await Promise.allSettled([...transports.values()].map(transport => transport.close()));
119
+ if (results.some(result => result.status === 'rejected'))
120
+ throw fail('CLOSURE_UNKNOWN');
121
+ } };
122
+ }
@@ -0,0 +1,74 @@
1
+ import type { PublishingConfiguration, PublishingMetadataTransport, PublishingProject } from '../protocol.js';
2
+ import type { PublishingJournal } from './journal.js';
3
+ import type { PublishingClientLimits } from '../client.js';
4
+ import type { AcceptanceArchive, AcceptanceDeliveryCredential } from './acceptance-delivery.js';
5
+ import type { PreparedSolutionPackage } from './solution-package.js';
6
+ export interface PublishingSourceProducer {
7
+ prepare(input: {
8
+ root: string;
9
+ project: PublishingProject;
10
+ signal?: AbortSignal;
11
+ requestId: string;
12
+ includeAcceptanceArchive?: boolean;
13
+ }): Promise<{
14
+ prepared: PreparedSolutionPackage;
15
+ acceptanceArchive?: AcceptanceArchive;
16
+ processesClosed: true;
17
+ }>;
18
+ }
19
+ export interface PublishingWorkflowOptions {
20
+ root: string;
21
+ journal: PublishingJournal;
22
+ configuration: PublishingConfiguration;
23
+ credential: string;
24
+ acceptanceDelivery?: AcceptanceDeliveryCredential;
25
+ allowLoopback?: boolean;
26
+ request?: typeof fetch;
27
+ clientLimits?: PublishingClientLimits;
28
+ pathCaseSensitivity?: 'case-sensitive' | 'case-insensitive';
29
+ metadataTransport?: PublishingMetadataTransport;
30
+ operationLimits?: {
31
+ timeoutMilliseconds: number;
32
+ closeTimeoutMilliseconds: number;
33
+ };
34
+ }
35
+ export interface PublishingWorkflowResult {
36
+ requestId?: string;
37
+ state: 'empty' | 'checked' | 'preparation-unknown' | 'preparation-failed' | 'uploading' | 'queued' | 'deploying' | 'registered' | 'awaiting-acceptance' | 'active' | 'failed' | 'unknown' | 'abandoned' | 'superseded';
38
+ active: boolean;
39
+ sideEffects?: 'none' | 'pending' | 'unknown' | 'closed';
40
+ timedOut?: true;
41
+ error?: {
42
+ code: string;
43
+ };
44
+ }
45
+ export interface PublishingSourceOptions {
46
+ producer?: string;
47
+ newPreparation?: boolean;
48
+ signal?: AbortSignal;
49
+ }
50
+ export interface PublishingPublishOptions extends PublishingSourceOptions {
51
+ /** 0 (default) returns immediately; positive values bound read-only status polling after submission. */
52
+ waitMs?: number;
53
+ /** Status polling interval, 1–30000ms; defaults to 1000ms. */
54
+ pollMs?: number;
55
+ }
56
+ export interface PublishingWorkflow {
57
+ check(input?: PublishingSourceOptions): Promise<PublishingWorkflowResult>;
58
+ publish(input?: PublishingPublishOptions): Promise<PublishingWorkflowResult>;
59
+ status(input?: {
60
+ signal?: AbortSignal;
61
+ }): Promise<PublishingWorkflowResult>;
62
+ recover(input?: {
63
+ signal?: AbortSignal;
64
+ }): Promise<PublishingWorkflowResult>;
65
+ verify(input?: {
66
+ signal?: AbortSignal;
67
+ }): Promise<PublishingWorkflowResult>;
68
+ abandon(input?: {
69
+ signal?: AbortSignal;
70
+ }): Promise<PublishingWorkflowResult>;
71
+ }
72
+ /** One active request per project/client journal. Recovery never imports source
73
+ * or performs an operation whose durable Foundation claim already exists. */
74
+ export declare function createPublishingWorkflow(options: PublishingWorkflowOptions): PublishingWorkflow;