@fabrika/operations-contract 0.4.1 → 0.4.3
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/package.json +2 -2
- package/src/release-schemas.ts +12 -0
- package/src/releases.ts +44 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/operations-contract",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"zod": "^3.25.76",
|
|
63
|
-
"@fabrika/app": "^0.4.
|
|
63
|
+
"@fabrika/app": "^0.4.3"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/release-schemas.ts
CHANGED
|
@@ -49,6 +49,18 @@ export const operationsReleasePayloadSchema = z.object({
|
|
|
49
49
|
observedAt,
|
|
50
50
|
}))
|
|
51
51
|
|
|
52
|
+
export const operationsSourceMapBuildUploadSchema = z.object({
|
|
53
|
+
destination: z.object({
|
|
54
|
+
url: z.string().url(),
|
|
55
|
+
appId: z.string().min(1),
|
|
56
|
+
environment: z.string().min(1),
|
|
57
|
+
serviceKey: z.string().min(1),
|
|
58
|
+
release: z.string().min(1),
|
|
59
|
+
runId: z.string().min(1),
|
|
60
|
+
}),
|
|
61
|
+
assetRoots: z.array(z.object({ prefix: z.string().startsWith('/'), dir: z.string().min(1) })).max(64),
|
|
62
|
+
})
|
|
63
|
+
|
|
52
64
|
const releaseRequestHeaderSchema = z.object({ revision: z.number().int().safe().min(1) }).passthrough()
|
|
53
65
|
|
|
54
66
|
export const operationsReleaseRequestSchema = releaseRequestHeaderSchema.transform((value, ctx) => {
|
package/src/releases.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/** Private Delivery → Operations release and artifact protocol; both services ship together. */
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_OPERATIONS_SERVICE_KEY } from './catalog.js'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
operationsReleaseIssueMessage,
|
|
6
|
+
operationsReleasePayloadSchema,
|
|
7
|
+
operationsReleaseRequestSchema,
|
|
8
|
+
operationsSourceMapBuildUploadSchema,
|
|
9
|
+
} from './release-schemas.js'
|
|
5
10
|
|
|
6
11
|
export {
|
|
7
12
|
operationsArtifactUploadCredentialSchema,
|
|
@@ -9,6 +14,7 @@ export {
|
|
|
9
14
|
operationsReleaseCoordinateSchema,
|
|
10
15
|
operationsReleasePayloadSchema,
|
|
11
16
|
operationsReleaseRequestSchema,
|
|
17
|
+
operationsSourceMapBuildUploadSchema,
|
|
12
18
|
} from './release-schemas.js'
|
|
13
19
|
|
|
14
20
|
export const FABRIKA_RELEASE = 'FABRIKA_RELEASE'
|
|
@@ -99,6 +105,43 @@ export interface OperationsArtifactUploadConfiguration {
|
|
|
99
105
|
runId: string
|
|
100
106
|
}
|
|
101
107
|
|
|
108
|
+
/** A directory of a build's public assets and the URL path its files are served under: `{ prefix: '/', dir: 'dist/web' }`. */
|
|
109
|
+
export interface OperationsAssetRoot {
|
|
110
|
+
prefix: string
|
|
111
|
+
dir: string
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* What a platform build reads to upload its source maps: the destination without its bearer, which travels apart, and
|
|
116
|
+
* the asset roots whose maps it uploads. A map's logical path is the URL path of the file it maps.
|
|
117
|
+
*/
|
|
118
|
+
export interface OperationsSourceMapBuildUpload {
|
|
119
|
+
destination: Omit<OperationsArtifactUploadConfiguration, 'bearer'>
|
|
120
|
+
assetRoots: OperationsAssetRoot[]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Throws on any other value. */
|
|
124
|
+
export function parseOperationsSourceMapBuildUpload(value: unknown): OperationsSourceMapBuildUpload {
|
|
125
|
+
return operationsSourceMapBuildUploadSchema.parse(value)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Whether every source map a build found reached Operations. */
|
|
129
|
+
export type OperationsSourceMapUploadState = 'complete' | 'incomplete'
|
|
130
|
+
|
|
131
|
+
const SOURCE_MAP_REPORT_PREFIX = 'fabrika-source-maps:'
|
|
132
|
+
const SOURCE_MAP_REPORT = /fabrika-source-maps: \d+ uploaded, state=(complete|incomplete)\s*$/
|
|
133
|
+
|
|
134
|
+
/** The one line a build prints after its upload; the provider reads the state back from the build log. */
|
|
135
|
+
export function sourceMapUploadReport(uploaded: number, state: OperationsSourceMapUploadState): string {
|
|
136
|
+
return `${SOURCE_MAP_REPORT_PREFIX} ${uploaded} uploaded, state=${state}`
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The state a build-log line reports, or `null` for any other line. */
|
|
140
|
+
export function readSourceMapUploadReport(line: string): OperationsSourceMapUploadState | null {
|
|
141
|
+
const state = SOURCE_MAP_REPORT.exec(line)?.[1]
|
|
142
|
+
return state === 'complete' || state === 'incomplete' ? state : null
|
|
143
|
+
}
|
|
144
|
+
|
|
102
145
|
const COMMIT_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/
|
|
103
146
|
|
|
104
147
|
export function normalizeOperationsCommit(value: string | null | undefined): string | null {
|