@jini-ai/devops 0.3.3 → 0.5.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 (104) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +65 -5
  3. package/dist/agent-jobs/entry.d.ts +4 -0
  4. package/dist/agent-jobs/entry.js +4 -0
  5. package/dist/agent-jobs/jobs.d.ts +25 -0
  6. package/dist/agent-jobs/jobs.js +115 -0
  7. package/dist/agent-jobs/node.d.ts +12 -0
  8. package/dist/agent-jobs/node.js +53 -0
  9. package/dist/agent-jobs/ports.d.ts +69 -0
  10. package/dist/agent-jobs/ports.js +2 -0
  11. package/dist/checks/coverage/diff.d.ts +57 -0
  12. package/dist/checks/coverage/diff.js +48 -0
  13. package/dist/checks/coverage/disk.d.ts +65 -0
  14. package/dist/checks/coverage/disk.js +136 -0
  15. package/dist/checks/coverage/floors.d.ts +31 -0
  16. package/dist/checks/coverage/floors.js +24 -0
  17. package/dist/checks/coverage/index.d.ts +7 -0
  18. package/dist/checks/coverage/index.js +6 -0
  19. package/dist/checks/coverage/integrity.d.ts +79 -0
  20. package/dist/checks/coverage/integrity.js +140 -0
  21. package/dist/checks/coverage/lcov.d.ts +65 -0
  22. package/dist/checks/coverage/lcov.js +64 -0
  23. package/dist/checks/node.d.ts +19 -0
  24. package/dist/checks/node.js +40 -0
  25. package/dist/checks/ports.d.ts +67 -0
  26. package/dist/checks/ports.js +2 -0
  27. package/dist/checks/published-types/index.d.ts +77 -0
  28. package/dist/checks/published-types/index.js +186 -0
  29. package/dist/deploy/host-kit.d.ts +27 -10
  30. package/dist/deploy/index.d.ts +0 -4
  31. package/dist/deploy/index.js +0 -4
  32. package/dist/deploy/naming.d.ts +9 -6
  33. package/dist/deploy/naming.js +5 -7
  34. package/dist/deploy/node.d.ts +18 -0
  35. package/dist/deploy/node.js +57 -0
  36. package/dist/deploy/reachability.d.ts +47 -18
  37. package/dist/deploy/reachability.js +77 -71
  38. package/dist/deploy/redirect-guard.d.ts +15 -11
  39. package/dist/deploy/redirect-guard.js +11 -12
  40. package/dist/deploy/tokens.d.ts +17 -14
  41. package/dist/deploy/tokens.js +16 -16
  42. package/dist/deploy/tool.d.ts +12 -8
  43. package/dist/deploy/tool.js +9 -10
  44. package/dist/deploy/types.d.ts +27 -15
  45. package/dist/deploy/types.js +3 -3
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +2 -1
  48. package/dist/local-dev/index.d.ts +34 -0
  49. package/dist/local-dev/index.js +37 -0
  50. package/dist/packaging/electron/archive.d.ts +41 -0
  51. package/dist/packaging/electron/archive.js +77 -0
  52. package/dist/packaging/electron/asar-adapter.d.ts +13 -0
  53. package/dist/packaging/electron/asar-adapter.js +5 -0
  54. package/dist/packaging/electron/entry.d.ts +9 -0
  55. package/dist/packaging/electron/entry.js +9 -0
  56. package/dist/packaging/electron/imports.d.ts +13 -0
  57. package/dist/packaging/electron/imports.js +44 -0
  58. package/dist/packaging/electron/node.d.ts +8 -0
  59. package/dist/packaging/electron/node.js +51 -0
  60. package/dist/packaging/electron/policies.d.ts +64 -0
  61. package/dist/packaging/electron/policies.js +63 -0
  62. package/dist/packaging/electron/ports.d.ts +113 -0
  63. package/dist/packaging/electron/ports.js +2 -0
  64. package/dist/packaging/electron/stability.d.ts +9 -0
  65. package/dist/packaging/electron/stability.js +12 -0
  66. package/dist/packaging/electron/staging.d.ts +108 -0
  67. package/dist/packaging/electron/staging.js +249 -0
  68. package/dist/packaging/electron/typescript.d.ts +7 -0
  69. package/dist/packaging/electron/typescript.js +18 -0
  70. package/dist/source-control/commit.d.ts +11 -0
  71. package/dist/source-control/commit.js +71 -0
  72. package/dist/source-control/contracts.d.ts +327 -0
  73. package/dist/source-control/contracts.js +2 -0
  74. package/dist/source-control/entry.d.ts +6 -0
  75. package/dist/source-control/entry.js +6 -0
  76. package/dist/source-control/kit.d.ts +15 -0
  77. package/dist/source-control/kit.js +17 -0
  78. package/dist/source-control/registry.d.ts +100 -0
  79. package/dist/source-control/registry.js +174 -0
  80. package/dist/source-control/repository-target.d.ts +13 -0
  81. package/dist/source-control/repository-target.js +28 -0
  82. package/dist/static-export/contracts.d.ts +138 -0
  83. package/dist/static-export/contracts.js +5 -0
  84. package/dist/static-export/entry.d.ts +6 -0
  85. package/dist/static-export/entry.js +6 -0
  86. package/dist/static-export/failure-summary.d.ts +12 -0
  87. package/dist/static-export/failure-summary.js +12 -0
  88. package/dist/static-export/fetch-adapter.d.ts +6 -0
  89. package/dist/static-export/fetch-adapter.js +5 -0
  90. package/dist/static-export/node-adapters.d.ts +11 -0
  91. package/dist/static-export/node-adapters.js +111 -0
  92. package/dist/static-export/runner.d.ts +6 -0
  93. package/dist/static-export/runner.js +135 -0
  94. package/dist/static-export/transforms.d.ts +53 -0
  95. package/dist/static-export/transforms.js +154 -0
  96. package/package.json +82 -5
  97. package/dist/deploy/cloudflare-pages.d.ts +0 -105
  98. package/dist/deploy/cloudflare-pages.js +0 -943
  99. package/dist/deploy/github-pages.d.ts +0 -62
  100. package/dist/deploy/github-pages.js +0 -373
  101. package/dist/deploy/netlify.d.ts +0 -40
  102. package/dist/deploy/netlify.js +0 -299
  103. package/dist/deploy/vercel.d.ts +0 -56
  104. package/dist/deploy/vercel.js +0 -258
@@ -0,0 +1,174 @@
1
+ function object(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
2
+ function relativeModule(value) {
3
+ return typeof value === 'string' && value.endsWith('.mjs') && !/[\\\x00-\x1f\x7f:]/.test(value) && value.split('/').every(segment => segment !== '' && segment !== '.' && segment !== '..');
4
+ }
5
+ function httpsOrigin(value) {
6
+ if (typeof value !== 'string')
7
+ return false;
8
+ try {
9
+ const url = new URL(value);
10
+ return url.protocol === 'https:' && url.origin === value;
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
16
+ function pathList(value) {
17
+ return Array.isArray(value) && value.length <= 20 && value.every(entry => typeof entry === 'string' && entry.length <= 200 && !/[\\\x00-\x1f\x7f:]/.test(entry) && entry.split('/').every(segment => segment !== '' && segment !== '.' && segment !== '..'));
18
+ }
19
+ function parseDescriptor(entry, at, readExtensions) {
20
+ if (!object(entry))
21
+ return `${at} must be an object`;
22
+ const { id, label, apiOrigin, maxFileBytes, reservedPaths, workflowPaths, module } = entry;
23
+ if (typeof id !== 'string' || id.length > 64 || /\s/.test(id) || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(id))
24
+ return `${at}.id must be a lowercase hyphenated id`;
25
+ if (typeof label !== 'string' || label.trim() === '' || label.length > 100)
26
+ return `${at}.label must be a non-empty string`;
27
+ if (!httpsOrigin(apiOrigin))
28
+ return `${at}.apiOrigin must be an https origin with no path`;
29
+ if (maxFileBytes !== undefined && (typeof maxFileBytes !== 'number' || !Number.isSafeInteger(maxFileBytes) || maxFileBytes <= 0))
30
+ return `${at}.maxFileBytes must be a positive integer`;
31
+ if (reservedPaths !== undefined && !pathList(reservedPaths))
32
+ return `${at}.reservedPaths must be a list of at most 20 relative folder paths`;
33
+ if (workflowPaths !== undefined && !pathList(workflowPaths))
34
+ return `${at}.workflowPaths must be a list of at most 20 relative folder paths`;
35
+ if (!relativeModule(module))
36
+ return `${at}.module must be a relative path ending in .mjs`;
37
+ const extras = readExtensions({ entry, at });
38
+ if (!extras.ok)
39
+ return extras.reason;
40
+ return { ...extras.extensions, id, label, apiOrigin, module, ...(typeof maxFileBytes === 'number' ? { maxFileBytes } : {}), ...(pathList(reservedPaths) ? { reservedPaths } : {}), ...(pathList(workflowPaths) ? { workflowPaths } : {}) };
41
+ }
42
+ /** Parse generic host facts; the caller validates credential/i18n extensions. Unknown keys are ignored. */
43
+ export function parseSourceControlProvidersFile(required) {
44
+ let value;
45
+ try {
46
+ value = JSON.parse(required.raw);
47
+ }
48
+ catch {
49
+ return { ok: false, reason: 'not valid JSON' };
50
+ }
51
+ if (!object(value) || value.schemaVersion !== 1)
52
+ return { ok: false, reason: 'schemaVersion must be 1' };
53
+ if (!Array.isArray(value.providers))
54
+ return { ok: false, reason: 'providers must be an array' };
55
+ const descriptors = [];
56
+ for (const [index, entry] of value.providers.entries()) {
57
+ const descriptor = parseDescriptor(entry, `providers[${index}]`, required.readExtensions);
58
+ if (typeof descriptor === 'string')
59
+ return { ok: false, reason: descriptor };
60
+ if (descriptors.some(prior => prior.id === descriptor.id))
61
+ return { ok: false, reason: `providers[${index}].id '${descriptor.id}' is declared twice` };
62
+ descriptors.push(descriptor);
63
+ }
64
+ return { ok: true, descriptors };
65
+ }
66
+ function moduleError(value) {
67
+ if (!object(value) || typeof value.create !== 'function')
68
+ return 'its module has no create() function';
69
+ if (value.validateTarget !== undefined && typeof value.validateTarget !== 'function')
70
+ return "its module's validateTarget is not a function";
71
+ return null;
72
+ }
73
+ /** Fresh instance-local registry; only the catalog can grant the ability to import trusted modules. */
74
+ export async function loadSourceControlProviderRegistry(required) {
75
+ const packages = [...await required.catalog.list({ workspaceId: required.workspaceId, descriptorFileName: required.descriptorFileName })].sort((a, b) => a.pluginId < b.pluginId ? -1 : a.pluginId > b.pluginId ? 1 : 0);
76
+ const providers = [];
77
+ const refusals = [];
78
+ const switchedOff = new Map();
79
+ for (const item of packages) {
80
+ if (item.state === 'refused') {
81
+ refusals.push(`${item.pluginId}: ${item.reason}`);
82
+ continue;
83
+ }
84
+ let parsed;
85
+ try {
86
+ parsed = parseSourceControlProvidersFile({ raw: item.descriptorText, readExtensions: required.readExtensions });
87
+ }
88
+ catch (error) {
89
+ refusals.push(`${item.pluginId}: ${required.describeError({ error })}`);
90
+ continue;
91
+ }
92
+ if (!parsed.ok) {
93
+ refusals.push(`${item.pluginId}: ${parsed.reason}`);
94
+ continue;
95
+ }
96
+ if (item.state === 'inactive') {
97
+ for (const descriptor of parsed.descriptors)
98
+ if (!switchedOff.has(descriptor.id))
99
+ switchedOff.set(descriptor.id, item.pluginId);
100
+ continue;
101
+ }
102
+ for (const descriptor of parsed.descriptors) {
103
+ try {
104
+ const candidate = await item.importModule({ relativePath: descriptor.module });
105
+ const reason = moduleError(candidate);
106
+ if (reason) {
107
+ refusals.push(`${item.pluginId}/${descriptor.id}: ${reason}`);
108
+ continue;
109
+ }
110
+ providers.push({ descriptor, pluginId: item.pluginId, module: candidate });
111
+ }
112
+ catch (error) {
113
+ refusals.push(`${item.pluginId}/${descriptor.id}: ${required.describeError({ error })}`);
114
+ }
115
+ }
116
+ }
117
+ const frozen = Object.freeze(providers.slice());
118
+ return { list: () => frozen, get: ({ providerId }) => frozen.find(provider => provider.descriptor.id === providerId), refusals: Object.freeze(refusals.slice()), switchedOff };
119
+ }
120
+ /** Build operations and host facts without allowing module operations to overwrite declared facts. */
121
+ export function buildLoadedSourceControlProvider(required) {
122
+ const { loaded, kit } = required;
123
+ const { id, label, apiOrigin, maxFileBytes, reservedPaths, workflowPaths } = loaded.descriptor;
124
+ return { ...loaded.module.create({ kit }), ...(loaded.module.validateTarget ? { validateTarget: loaded.module.validateTarget } : {}), id, label, apiOrigin,
125
+ ...(maxFileBytes !== undefined ? { maxFileBytes } : {}), ...(reservedPaths !== undefined ? { reservedPaths } : {}), ...(workflowPaths !== undefined ? { workflowPaths } : {}) };
126
+ }
127
+ /** Operator navigation/copy is supplied by the host, with no descriptor or product defaults. */
128
+ export async function buildSourceControlProvider(required) {
129
+ const registry = await required.load({ workspaceId: required.workspaceId });
130
+ const loaded = registry.get({ providerId: required.providerId });
131
+ if (!loaded)
132
+ return { ok: false, message: required.noProviderMessage({ registry, providerId: required.providerId }), refusals: registry.refusals };
133
+ return { ok: true, provider: buildLoadedSourceControlProvider({ loaded, kit: required.kit }) };
134
+ }
135
+ /** Build every enabled provider over the same guarded kit, in catalog order. */
136
+ export async function buildSourceControlProviders(required) {
137
+ const registry = await required.load({ workspaceId: required.workspaceId });
138
+ return { providers: registry.list({}).map(loaded => buildLoadedSourceControlProvider({ loaded, kit: required.kit })), refusals: registry.refusals, noProviderMessage: required.noProviderMessage({ registry }) };
139
+ }
140
+ /** Build and select a provider for one custom credential's API origin. */
141
+ export async function buildSourceControlProviderForApi(required) {
142
+ const built = await buildSourceControlProviders(required);
143
+ const picked = pickSourceControlProviderForApi({ providers: built.providers, baseUrl: required.baseUrl, noProviderMessage: built.noProviderMessage });
144
+ if (picked.ok)
145
+ return picked;
146
+ return { ...picked, refusals: built.refusals };
147
+ }
148
+ /** Find the folder or ancestor that has provider-defined reserved semantics, ignoring case. */
149
+ export function findReservedPath(required, optional = {}) {
150
+ const lower = required.folder.toLowerCase();
151
+ return optional.reservedPaths?.find(reserved => lower === reserved.toLowerCase() || lower.startsWith(`${reserved.toLowerCase()}/`));
152
+ }
153
+ /** Workflow recognition is case-sensitive and relative to repository root. */
154
+ export function isUnderWorkflowPath(required, optional = {}) {
155
+ return optional.workflowPaths?.some(folder => required.filePath.startsWith(`${folder}/`)) ?? false;
156
+ }
157
+ /** URL origin or undefined for malformed URLs. */
158
+ export function originOf(required) {
159
+ try {
160
+ return new URL(required.url).origin;
161
+ }
162
+ catch {
163
+ return undefined;
164
+ }
165
+ }
166
+ /** Exact API-origin match first; a sole provider may serve a self-hosted origin. */
167
+ export function pickSourceControlProviderForApi(required) {
168
+ const origin = originOf({ url: required.baseUrl });
169
+ const match = required.providers.find(provider => originOf({ url: provider.apiOrigin }) === origin) ?? (required.providers.length === 1 ? required.providers[0] : undefined);
170
+ if (match)
171
+ return { ok: true, provider: match };
172
+ return { ok: false, message: required.providers.length === 0 ? required.noProviderMessage : `No enabled provider supplies source control for ${origin ?? required.baseUrl}.` };
173
+ }
174
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1,13 @@
1
+ import type { RepositoryTarget, RepositoryTargetValidator } from './contracts.js';
2
+ /** Host rules precede the common one-URL-segment rule. Returns caller-safe refusal text. */
3
+ export declare function repositoryTargetError(required: RepositoryTarget, optional?: {
4
+ validateTarget?: RepositoryTargetValidator;
5
+ }): string | null;
6
+ /** Validate before resolving credentials or exporting bytes. */
7
+ export declare function validateCommitTarget(required: RepositoryTarget & {
8
+ commitMessage: string;
9
+ }, optional?: {
10
+ validateTarget?: RepositoryTargetValidator;
11
+ branch?: string;
12
+ }): string | null;
13
+ //# sourceMappingURL=repository-target.d.ts.map
@@ -0,0 +1,28 @@
1
+ const GENERIC_SEGMENT_PATTERN = /^[^\s/\\\x00-\x1f\x7f]{1,100}$/;
2
+ const BRANCH_PATTERN = /^[A-Za-z0-9._/-]{1,250}$/;
3
+ function isGenericSegment(value) {
4
+ return GENERIC_SEGMENT_PATTERN.test(value) && !/[\s\x00-\x1f\x7f]/.test(value) && value !== '.' && value !== '..';
5
+ }
6
+ /** Host rules precede the common one-URL-segment rule. Returns caller-safe refusal text. */
7
+ export function repositoryTargetError(required, optional = {}) {
8
+ const hostError = optional.validateTarget?.(required) ?? null;
9
+ if (hostError !== null)
10
+ return hostError;
11
+ if (!isGenericSegment(required.owner))
12
+ return `invalid owner '${required.owner.slice(0, 60)}'`;
13
+ if (!isGenericSegment(required.repo))
14
+ return `invalid repo '${required.repo.slice(0, 100)}'`;
15
+ return null;
16
+ }
17
+ /** Validate before resolving credentials or exporting bytes. */
18
+ export function validateCommitTarget(required, optional = {}) {
19
+ const error = repositoryTargetError({ owner: required.owner, repo: required.repo }, optional);
20
+ if (error !== null)
21
+ return error;
22
+ if (optional.branch !== undefined && (!BRANCH_PATTERN.test(optional.branch) || /[\s\x00-\x1f\x7f]/.test(optional.branch)))
23
+ return `invalid branch name '${optional.branch.slice(0, 60)}'`;
24
+ if (required.commitMessage.trim() === '' || required.commitMessage.length > 500)
25
+ return 'commitMessage must be 1-500 characters';
26
+ return null;
27
+ }
28
+ //# sourceMappingURL=repository-target.js.map
@@ -0,0 +1,138 @@
1
+ /** Kinds describe the host's routes; only redirect/not-found/well-known affect writing. */
2
+ export type ManifestRouteKind = string;
3
+ export interface ManifestRoute {
4
+ path: string;
5
+ kind: ManifestRouteKind;
6
+ label: string;
7
+ redirectTarget?: string;
8
+ redirectStatusCode?: number;
9
+ }
10
+ export interface ManifestActiveTheme {
11
+ id: string;
12
+ dir: string;
13
+ apiVersion?: number;
14
+ }
15
+ export interface ManifestSkip {
16
+ reason: string;
17
+ detail: string;
18
+ }
19
+ export interface RouteManifest {
20
+ routes: ManifestRoute[];
21
+ skipped: ManifestSkip[];
22
+ activeTheme?: ManifestActiveTheme;
23
+ }
24
+ export interface RouteManifestPort {
25
+ build(required: Record<string, never>): Promise<RouteManifest>;
26
+ }
27
+ export interface AppSession {
28
+ baseUrl: string;
29
+ close(required: Record<string, never>): Promise<void>;
30
+ }
31
+ export interface AppFactoryPort {
32
+ open(required: Record<string, never>): Promise<AppSession>;
33
+ }
34
+ export interface ArtifactWriterPort {
35
+ prepare(required: {
36
+ outputDir: string;
37
+ }, optional?: {
38
+ clean?: boolean;
39
+ }): Promise<void>;
40
+ /** The runner validates outputFile; an adapter must also protect its storage root/symlink boundary. */
41
+ write(required: {
42
+ outputDir: string;
43
+ outputFile: string;
44
+ data: string | Buffer;
45
+ }): Promise<void>;
46
+ }
47
+ export interface AssetSourcePort {
48
+ listThemeFiles(required: {
49
+ theme: ManifestActiveTheme;
50
+ }): Promise<readonly string[]>;
51
+ }
52
+ export interface ThemeLayoutPort {
53
+ resolve(required: {
54
+ theme: ManifestActiveTheme;
55
+ }): {
56
+ pagesDir: string;
57
+ assetUrlPrefix: string;
58
+ };
59
+ }
60
+ export interface ExportedRoute {
61
+ path: string;
62
+ kind: ManifestRouteKind;
63
+ outputFile: string;
64
+ data: string;
65
+ contentType?: string | null;
66
+ }
67
+ export interface FailedRoute {
68
+ path: string;
69
+ kind: ManifestRouteKind;
70
+ reason: string;
71
+ }
72
+ export interface ExportedAsset {
73
+ url: string;
74
+ outputFile: string;
75
+ data: Buffer;
76
+ contentType?: string | null;
77
+ }
78
+ export interface FailedAsset {
79
+ url: string;
80
+ reason: string;
81
+ }
82
+ export interface ExportReport {
83
+ outputDir: string;
84
+ routes: {
85
+ succeeded: ExportedRoute[];
86
+ failed: FailedRoute[];
87
+ };
88
+ assets: {
89
+ succeeded: ExportedAsset[];
90
+ failed: FailedAsset[];
91
+ };
92
+ skippedManifestEntries: ManifestSkip[];
93
+ unreferencedThemeFiles: string[];
94
+ basePath?: string;
95
+ basePathRewriteWarning?: string;
96
+ }
97
+ /** The host selects the transport; the runner supplies redirect and timeout policy. */
98
+ export type ExportFetchPort = (required: {
99
+ url: string;
100
+ }, optional?: {
101
+ init?: RequestInit;
102
+ }) => Promise<Response>;
103
+ export interface ExportSiteArgs {
104
+ outputDir: string;
105
+ manifest: RouteManifestPort;
106
+ app: AppFactoryPort;
107
+ writer: ArtifactWriterPort;
108
+ fetch: ExportFetchPort;
109
+ assetSource: AssetSourcePort;
110
+ themeLayout: ThemeLayoutPort;
111
+ assetUrlPrefixes: readonly string[];
112
+ requestHeaders: Readonly<Record<string, string>>;
113
+ security: {
114
+ transformHtml(required: {
115
+ html: string;
116
+ }): string;
117
+ };
118
+ errorPage: {
119
+ outputFile: string;
120
+ acceptStatus(required: {
121
+ status: number;
122
+ }): boolean;
123
+ };
124
+ /** Caller-safe error description; used for failed network, body or artifact writes. */
125
+ describeError(required: {
126
+ error: unknown;
127
+ }): string;
128
+ }
129
+ export interface ExportSiteOptions {
130
+ clean?: boolean;
131
+ basePath?: string;
132
+ fetchTimeoutMs?: number;
133
+ }
134
+ export declare class ExportOutputNotEmptyError extends Error {
135
+ }
136
+ export declare class ExportPathError extends Error {
137
+ }
138
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1,5 @@
1
+ export class ExportOutputNotEmptyError extends Error {
2
+ }
3
+ export class ExportPathError extends Error {
4
+ }
5
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1,6 @@
1
+ export * from './contracts.js';
2
+ export * from './fetch-adapter.js';
3
+ export * from './failure-summary.js';
4
+ export * from './transforms.js';
5
+ export * from './runner.js';
6
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from './contracts.js';
2
+ export * from './fetch-adapter.js';
3
+ export * from './failure-summary.js';
4
+ export * from './transforms.js';
5
+ export * from './runner.js';
6
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1,12 @@
1
+ import type { ExportReport } from './contracts.js';
2
+ export interface ExportFailureSummary {
3
+ kind: 'route' | 'asset';
4
+ identifier: string;
5
+ reason: string;
6
+ count: number;
7
+ }
8
+ /** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
9
+ export declare function firstExportFailure(required: {
10
+ report: ExportReport;
11
+ }): ExportFailureSummary | undefined;
12
+ //# sourceMappingURL=failure-summary.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** Runtime-leaf check of routes AND assets. Routes take precedence; the count is per collection. */
2
+ export function firstExportFailure(required) {
3
+ const { report } = required;
4
+ const route = report.routes.failed[0];
5
+ if (route)
6
+ return { kind: 'route', identifier: route.path, reason: route.reason, count: report.routes.failed.length };
7
+ const asset = report.assets.failed[0];
8
+ if (asset)
9
+ return { kind: 'asset', identifier: asset.url, reason: asset.reason, count: report.assets.failed.length };
10
+ return undefined;
11
+ }
12
+ //# sourceMappingURL=failure-summary.js.map
@@ -0,0 +1,6 @@
1
+ import type { ExportFetchPort } from './contracts.js';
2
+ /** Adapt a host-selected native/guarded fetch; no global transport is selected. */
3
+ export declare function createExportFetchAdapter(required: {
4
+ fetch: typeof fetch;
5
+ }): ExportFetchPort;
6
+ //# sourceMappingURL=fetch-adapter.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Adapt a host-selected native/guarded fetch; no global transport is selected. */
2
+ export function createExportFetchAdapter(required) {
3
+ return ({ url }, optional = {}) => required.fetch(url, optional.init);
4
+ }
5
+ //# sourceMappingURL=fetch-adapter.js.map
@@ -0,0 +1,11 @@
1
+ import { type RequestListener } from 'node:http';
2
+ import { type AppFactoryPort, type ArtifactWriterPort, type AssetSourcePort } from './contracts.js';
3
+ /** Caller-owned output directory, explicit clean, and no-follow regular-file writes. */
4
+ export declare function createNodeArtifactWriter(_required: Record<string, never>): ArtifactWriterPort;
5
+ /** Independent Node loopback adapter. The app factory is required and remains owned by the host. */
6
+ export declare function createNodeAppFactory(required: {
7
+ createApp(required: Record<string, never>): RequestListener | Promise<RequestListener>;
8
+ }): AppFactoryPort;
9
+ /** Inventory only regular theme files. Rendering and API-version layout stay injected. */
10
+ export declare function createNodeAssetSource(_required: Record<string, never>): AssetSourcePort;
11
+ //# sourceMappingURL=node-adapters.d.ts.map
@@ -0,0 +1,111 @@
1
+ import { once } from 'node:events';
2
+ import { constants } from 'node:fs';
3
+ import { lstat, mkdir, open, readdir, rm } from 'node:fs/promises';
4
+ import { createServer } from 'node:http';
5
+ import path from 'node:path';
6
+ import { ExportOutputNotEmptyError, ExportPathError } from './contracts.js';
7
+ import { safeRelativeOutputFile } from './transforms.js';
8
+ /** Require regular directories at every ancestor. Hosts must use canonical absolute storage paths.
9
+ * The storage hierarchy must be caller-owned; cross-process hostile ancestor swaps require host isolation.
10
+ */
11
+ async function ensureDirectory({ directory, label }, optional = {}) {
12
+ if (!path.isAbsolute(directory))
13
+ throw new ExportPathError(`${label} path must be absolute.`);
14
+ const resolved = path.resolve(directory);
15
+ const segments = resolved.slice(path.parse(resolved).root.length).split(path.sep).filter(Boolean);
16
+ let current = path.parse(resolved).root;
17
+ for (const segment of segments) {
18
+ current = path.join(current, segment);
19
+ if (optional.create) {
20
+ try {
21
+ await mkdir(current);
22
+ }
23
+ catch (error) {
24
+ if (error.code !== 'EEXIST')
25
+ throw error;
26
+ }
27
+ }
28
+ const info = await lstat(current);
29
+ if (!info.isDirectory() || info.isSymbolicLink())
30
+ throw new ExportPathError(`${label} path must be a regular directory.`);
31
+ }
32
+ }
33
+ /** Caller-owned output directory, explicit clean, and no-follow regular-file writes. */
34
+ export function createNodeArtifactWriter(_required) {
35
+ return {
36
+ async prepare({ outputDir }, optional = {}) {
37
+ await ensureDirectory({ directory: outputDir, label: 'Output' }, { create: true });
38
+ const entries = await readdir(outputDir);
39
+ if (entries.length && !optional.clean)
40
+ throw new ExportOutputNotEmptyError(`export output directory '${outputDir}' is not empty (${entries.length} existing ${entries.length === 1 ? 'entry' : 'entries'}) — pass clean: true to remove its contents first, or select an empty/new directory`);
41
+ if (optional.clean)
42
+ for (const entry of entries)
43
+ await rm(path.join(outputDir, entry), { recursive: true, force: true });
44
+ },
45
+ async write({ outputDir, outputFile, data }) {
46
+ safeRelativeOutputFile({ value: outputFile });
47
+ await ensureDirectory({ directory: outputDir, label: 'Output' }, { create: true });
48
+ const destination = path.join(outputDir, outputFile);
49
+ await ensureDirectory({ directory: path.dirname(destination), label: 'Artifact' }, { create: true });
50
+ try {
51
+ const info = await lstat(destination);
52
+ if (!info.isFile() || info.isSymbolicLink())
53
+ throw new ExportPathError('Artifact output must be a regular file.');
54
+ }
55
+ catch (error) {
56
+ if (error.code !== 'ENOENT')
57
+ throw error;
58
+ }
59
+ const handle = await open(destination, constants.O_WRONLY | constants.O_CREAT | constants.O_NOFOLLOW, 0o600);
60
+ try {
61
+ if (!(await handle.stat()).isFile())
62
+ throw new ExportPathError('Artifact output must be a regular file.');
63
+ await handle.truncate(0);
64
+ await handle.writeFile(data);
65
+ }
66
+ finally {
67
+ await handle.close();
68
+ }
69
+ },
70
+ };
71
+ }
72
+ /** Independent Node loopback adapter. The app factory is required and remains owned by the host. */
73
+ export function createNodeAppFactory(required) {
74
+ return { async open() {
75
+ const server = createServer(await required.createApp({}));
76
+ let closed = false;
77
+ const close = async () => {
78
+ if (closed)
79
+ return;
80
+ closed = true;
81
+ server.closeAllConnections();
82
+ await new Promise(resolve => { server.close(() => resolve()); });
83
+ };
84
+ try {
85
+ server.listen(0, '127.0.0.1');
86
+ await once(server, 'listening');
87
+ const address = server.address();
88
+ return { baseUrl: `http://127.0.0.1:${address.port}`, close };
89
+ }
90
+ catch (error) {
91
+ await close();
92
+ throw error;
93
+ }
94
+ } };
95
+ }
96
+ /** Inventory only regular theme files. Rendering and API-version layout stay injected. */
97
+ export function createNodeAssetSource(_required) {
98
+ async function list(directory, prefix) {
99
+ const files = [];
100
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
101
+ const relative = prefix + entry.name;
102
+ if (entry.isDirectory())
103
+ files.push(...await list(path.join(directory, entry.name), relative + '/'));
104
+ else if (entry.isFile())
105
+ files.push(relative);
106
+ }
107
+ return files;
108
+ }
109
+ return { async listThemeFiles({ theme }) { await ensureDirectory({ directory: theme.dir, label: 'Theme' }); return (await list(theme.dir, '')).sort(); } };
110
+ }
111
+ //# sourceMappingURL=node-adapters.js.map
@@ -0,0 +1,6 @@
1
+ import type { ExportReport, ExportSiteArgs, ExportSiteOptions } from './contracts.js';
2
+ /** Drive the caller's actual app, retaining exact written bytes and reporting each failed item.
3
+ * Startup/output/inventory errors throw; an opened app always closes. No singleton state is used.
4
+ */
5
+ export declare function exportSite(required: ExportSiteArgs, optional?: ExportSiteOptions): Promise<ExportReport>;
6
+ //# sourceMappingURL=runner.d.ts.map