@burdenoff/microfe-cosmicintersection 2026.1108.2 → 2026.1109.2
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/dist/cosmicintersection/api/databricksTransport.d.ts +13 -0
- package/dist/cosmicintersection/api/databricksTransport.d.ts.map +1 -0
- package/dist/cosmicintersection/api/databricksTransport.js +38 -0
- package/dist/cosmicintersection/api/databricksTransport.js.map +1 -0
- package/dist/cosmicintersection/components/ActionMenu.js +17 -17
- package/dist/cosmicintersection/components/DatabricksQueueForm.d.ts +13 -0
- package/dist/cosmicintersection/components/DatabricksQueueForm.d.ts.map +1 -0
- package/dist/cosmicintersection/components/DatabricksQueueForm.js +221 -0
- package/dist/cosmicintersection/components/DatabricksQueueForm.js.map +1 -0
- package/dist/cosmicintersection/components/DatabricksRunPanel.d.ts +6 -0
- package/dist/cosmicintersection/components/DatabricksRunPanel.d.ts.map +1 -0
- package/dist/cosmicintersection/components/DatabricksRunPanel.js +206 -0
- package/dist/cosmicintersection/components/DatabricksRunPanel.js.map +1 -0
- package/dist/cosmicintersection/components/EntityFormShell.js +7 -7
- package/dist/cosmicintersection/components/EntityTagsField.js +8 -8
- package/dist/cosmicintersection/components/ErrorState.js +4 -4
- package/dist/cosmicintersection/components/FileUploadField.js +8 -8
- package/dist/cosmicintersection/components/Pagination.js +6 -6
- package/dist/cosmicintersection/components/ReleaseDraftDialog.js +17 -17
- package/dist/cosmicintersection/components/RunTriageCard.js +12 -12
- package/dist/cosmicintersection/components/SchemaProposalPanel.js +35 -35
- package/dist/cosmicintersection/components/SchemaProposalPanel.js.map +1 -1
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js +12 -12
- package/dist/cosmicintersection/components/index.js +7 -7
- package/dist/cosmicintersection/context/CosmicIntersectionContext.d.ts +2 -0
- package/dist/cosmicintersection/context/CosmicIntersectionContext.d.ts.map +1 -1
- package/dist/cosmicintersection/context/CosmicIntersectionContext.js +17 -13
- package/dist/cosmicintersection/context/CosmicIntersectionContext.js.map +1 -1
- package/dist/cosmicintersection/hooks/useDatabricksExecutions.d.ts +69 -0
- package/dist/cosmicintersection/hooks/useDatabricksExecutions.d.ts.map +1 -0
- package/dist/cosmicintersection/hooks/useDatabricksExecutions.js +89 -0
- package/dist/cosmicintersection/hooks/useDatabricksExecutions.js.map +1 -0
- package/dist/cosmicintersection/hooks/useDatabricksQueueForm.d.ts +59 -0
- package/dist/cosmicintersection/hooks/useDatabricksQueueForm.d.ts.map +1 -0
- package/dist/cosmicintersection/hooks/useDatabricksQueueForm.js +158 -0
- package/dist/cosmicintersection/hooks/useDatabricksQueueForm.js.map +1 -0
- package/dist/cosmicintersection/lib/databricksForm.d.ts +4 -0
- package/dist/cosmicintersection/lib/databricksForm.d.ts.map +1 -0
- package/dist/cosmicintersection/lib/databricksForm.js +31 -0
- package/dist/cosmicintersection/lib/databricksForm.js.map +1 -0
- package/dist/cosmicintersection/lib/databricksIntent.d.ts +19 -0
- package/dist/cosmicintersection/lib/databricksIntent.d.ts.map +1 -0
- package/dist/cosmicintersection/lib/databricksIntent.js +60 -0
- package/dist/cosmicintersection/lib/databricksIntent.js.map +1 -0
- package/dist/cosmicintersection/lib/databricksPresentation.d.ts +5 -0
- package/dist/cosmicintersection/lib/databricksPresentation.d.ts.map +1 -0
- package/dist/cosmicintersection/lib/databricksPresentation.js +27 -0
- package/dist/cosmicintersection/lib/databricksPresentation.js.map +1 -0
- package/dist/cosmicintersection/pages/access/AccessPage.js +62 -62
- package/dist/cosmicintersection/pages/access/AccessPage.js.map +1 -1
- package/dist/cosmicintersection/pages/analyses/AnalysesPage.js +107 -107
- package/dist/cosmicintersection/pages/analyses/AnalysesPage.js.map +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionDetailPage.js +24 -24
- package/dist/cosmicintersection/pages/collections/CollectionsPage.js +12 -12
- package/dist/cosmicintersection/pages/dashboard/DashboardPage.js +18 -18
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js +91 -91
- package/dist/cosmicintersection/pages/datasets/DatasetsPage.js +209 -209
- package/dist/cosmicintersection/pages/datasets/DatasetsPage.js.map +1 -1
- package/dist/cosmicintersection/pages/discovery/DiscoveryPage.js +98 -98
- package/dist/cosmicintersection/pages/discovery/DiscoveryPage.js.map +1 -1
- package/dist/cosmicintersection/pages/lineage/LineagePage.js +15 -15
- package/dist/cosmicintersection/pages/notebooks/NotebookDetailPage.js +139 -139
- package/dist/cosmicintersection/pages/notebooks/NotebookDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebooksPage.js +34 -34
- package/dist/cosmicintersection/pages/pipelines/PipelineDetailPage.js +39 -39
- package/dist/cosmicintersection/pages/pipelines/PipelineDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js +107 -107
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelinesPage.js +32 -32
- package/dist/cosmicintersection/pages/releases/ReleasesPage.js +213 -213
- package/dist/cosmicintersection/pages/releases/ReleasesPage.js.map +1 -1
- package/dist/cosmicintersection/pages/runs/RunDetailPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/runs/RunDetailPage.js +250 -213
- package/dist/cosmicintersection/pages/runs/RunDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/runs/RunsPage.js +31 -31
- package/dist/cosmicintersection/pages/sources/SourceDetailPage.js +41 -41
- package/dist/cosmicintersection/pages/sources/SourcesPage.js +122 -122
- package/dist/cosmicintersection/pages/sources/SourcesPage.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +243 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -0
- package/dist/generated/wspace-operations.js +1472 -0
- package/dist/generated/wspace-operations.js.map +1 -0
- package/dist/generated/wspace-types.d.ts +183281 -30204
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/package.json +10 -7
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { CosDatabricksConnectionsDocument as e, CosDatabricksDatasetsDocument as t, CosQueueDatabricksStepDocument as n, CosResolveExternalComputeRequestDocument as r } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { databricksJobId as i, databricksParameters as a } from "../lib/databricksForm.js";
|
|
3
|
+
import { clearConfirmedDatabricksIntent as o, clearWithdrawnDatabricksIntent as s, confirmDatabricksIntent as c, prepareDatabricksIntent as l, readDatabricksIntent as u } from "../lib/databricksIntent.js";
|
|
4
|
+
import { useRef as d, useState as f } from "react";
|
|
5
|
+
import { clearGraphqlFetchResponseCache as p } from "@burdenoff/fe-libs/shared/graphql";
|
|
6
|
+
//#region src/cosmicintersection/hooks/useDatabricksQueueForm.ts
|
|
7
|
+
function m({ request: m, runId: h, workspaceId: g, intentKey: _, onQueued: v, statusReady: ee, canQueue: y }) {
|
|
8
|
+
let [b, x] = f([]), [S, C] = f([]), [w, T] = f(0), [E, D] = f(0), [O, k] = f(!1), [A, te] = f(!1), [j, ne] = f(""), [M, N] = f(""), [P, F] = f("Databricks job"), [I, L] = f("{}"), [R, z] = f("3600"), [B, V] = f([]), [H, U] = f([]), [W, G] = f(!1), [K, q] = f(!1), [J] = f(() => {
|
|
9
|
+
try {
|
|
10
|
+
return {
|
|
11
|
+
intent: u(window.sessionStorage, _),
|
|
12
|
+
error: null
|
|
13
|
+
};
|
|
14
|
+
} catch {
|
|
15
|
+
return {
|
|
16
|
+
intent: null,
|
|
17
|
+
error: "The saved request is unreadable. Do not submit another job until its status is recovered."
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}), [Y, X] = f(J.error), [re, Z] = f(J.intent), Q = d(!1), $ = () => Z(u(window.sessionStorage, _));
|
|
21
|
+
return {
|
|
22
|
+
connections: b,
|
|
23
|
+
datasets: S,
|
|
24
|
+
connectionOffset: w,
|
|
25
|
+
datasetOffset: E,
|
|
26
|
+
moreConnections: O,
|
|
27
|
+
moreDatasets: A,
|
|
28
|
+
connectionId: j,
|
|
29
|
+
jobId: M,
|
|
30
|
+
name: P,
|
|
31
|
+
parameters: I,
|
|
32
|
+
maximum: R,
|
|
33
|
+
inputs: B,
|
|
34
|
+
outputs: H,
|
|
35
|
+
confirmedCost: W,
|
|
36
|
+
busy: K,
|
|
37
|
+
error: Y,
|
|
38
|
+
intent: re,
|
|
39
|
+
setConnectionId: ne,
|
|
40
|
+
setJobId: N,
|
|
41
|
+
setName: F,
|
|
42
|
+
setParameters: L,
|
|
43
|
+
setMaximum: z,
|
|
44
|
+
setInputs: V,
|
|
45
|
+
setOutputs: U,
|
|
46
|
+
setConfirmedCost: G,
|
|
47
|
+
loadOptions: async (n) => {
|
|
48
|
+
if (!Q.current) {
|
|
49
|
+
Q.current = !0, q(!0), X(null);
|
|
50
|
+
try {
|
|
51
|
+
if (p(), n === "connections") {
|
|
52
|
+
let t = O ? w : 0, n = await m(e, { pagination: {
|
|
53
|
+
limit: 50,
|
|
54
|
+
offset: t
|
|
55
|
+
} });
|
|
56
|
+
x((e) => Array.from(new Map([...t ? e : [], ...n.connections.items].filter((e) => e.workspaceId === g && e.canUse && e.status === "ACTIVE" && e.provider.key === "generic-api-key").map((e) => [e.id, e])).values())), T(t + n.connections.items.length), k(n.connections.hasMore);
|
|
57
|
+
} else {
|
|
58
|
+
let e = A ? E : 0, n = await m(t, { pagination: {
|
|
59
|
+
limit: 50,
|
|
60
|
+
offset: e
|
|
61
|
+
} });
|
|
62
|
+
C((t) => Array.from(new Map([...e ? t : [], ...n.cosListDatasets.items].map((e) => [e.id, e])).values())), D(e + n.cosListDatasets.items.length), te(n.cosListDatasets.pageInfo.hasMore);
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
X("Could not load choices. Retry this read; no job was submitted.");
|
|
66
|
+
} finally {
|
|
67
|
+
Q.current = !1, q(!1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
submit: async (e) => {
|
|
72
|
+
if (e.preventDefault(), Q.current) return;
|
|
73
|
+
Q.current = !0, q(!0), X(null);
|
|
74
|
+
let t = !1, r = !1;
|
|
75
|
+
try {
|
|
76
|
+
if (!y || !ee) throw Error("Refresh and confirm existing job status before submitting a request.");
|
|
77
|
+
if (!W || !b.some((e) => e.id === j)) throw Error("Choose an available existing connection and confirm external usage charges.");
|
|
78
|
+
let e = Number(R);
|
|
79
|
+
if (!Number.isSafeInteger(e) || e < 60 || e > 86400) throw Error("Choose a monitoring deadline between 60 and 86,400 seconds.");
|
|
80
|
+
if (!P.trim() || P.trim().length > 255) throw Error("Enter a job step name of at most 255 characters.");
|
|
81
|
+
if (B.length > 100 || H.length > 100) throw Error("Select at most 100 datasets for each lineage direction.");
|
|
82
|
+
let o = {
|
|
83
|
+
connectionId: j,
|
|
84
|
+
jobId: i(M),
|
|
85
|
+
name: P.trim(),
|
|
86
|
+
parameters: a(I),
|
|
87
|
+
inputDatasetIds: B,
|
|
88
|
+
outputDatasetIds: H,
|
|
89
|
+
maxRuntimeSeconds: e
|
|
90
|
+
}, s = await l(window.sessionStorage, _, o);
|
|
91
|
+
if (s.confirmedExecutionId) throw Error("This request is already confirmed. Explicitly start another job below.");
|
|
92
|
+
Z(s), t = !0;
|
|
93
|
+
let u = await m(n, {
|
|
94
|
+
runId: h,
|
|
95
|
+
input: {
|
|
96
|
+
...o,
|
|
97
|
+
requestId: s.requestId
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (u.cosQueueDatabricksStep.runId !== h || u.cosQueueDatabricksStep.requestId !== s.requestId) throw Error("The returned execution did not match the saved request.");
|
|
101
|
+
r = !0;
|
|
102
|
+
let d = !1;
|
|
103
|
+
try {
|
|
104
|
+
if (!c(window.sessionStorage, _, u.cosQueueDatabricksStep)) throw Error("The acknowledged execution no longer matches local recovery identity.");
|
|
105
|
+
$();
|
|
106
|
+
} catch {
|
|
107
|
+
d = !0;
|
|
108
|
+
}
|
|
109
|
+
await v(), d && X("The job request is confirmed and status was refreshed, but local recovery storage failed. Do not submit another job; recover the original request identity.");
|
|
110
|
+
} catch (e) {
|
|
111
|
+
X(r ? "The job request is confirmed, but its status refresh failed. Refresh job status; do not submit a replacement." : t ? "The queue outcome was not confirmed. Refresh job status. Retrying identical inputs reuses the saved request; changing them is refused until the original is recovered." : e instanceof Error ? e.message : "The request could not be verified. No job was submitted.");
|
|
112
|
+
} finally {
|
|
113
|
+
Q.current = !1, q(!1);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
checkSavedRequest: () => {
|
|
117
|
+
try {
|
|
118
|
+
$();
|
|
119
|
+
} catch {
|
|
120
|
+
X("The saved request could not be verified.");
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
resolveSavedRequest: async () => {
|
|
124
|
+
if (Q.current) return;
|
|
125
|
+
Q.current = !0, q(!0), X(null);
|
|
126
|
+
let e = !1;
|
|
127
|
+
try {
|
|
128
|
+
let t = u(window.sessionStorage, _);
|
|
129
|
+
if (!t || t.confirmedExecutionId) throw Error("Only an unresolved saved request can be recovered here.");
|
|
130
|
+
let n = (await m(r, {
|
|
131
|
+
runId: h,
|
|
132
|
+
requestId: t.requestId
|
|
133
|
+
})).cosResolveExternalComputeRequest;
|
|
134
|
+
if (u(window.sessionStorage, _)?.requestId !== t.requestId) throw Error("The saved request changed while recovery was running.");
|
|
135
|
+
if (n.withdrawn && n.execution === null) s(window.sessionStorage, _, t.requestId), G(!1);
|
|
136
|
+
else if (!n.withdrawn && n.execution?.runId === h && n.execution.requestId === t.requestId) {
|
|
137
|
+
if (!c(window.sessionStorage, _, n.execution)) throw Error("The recovered execution no longer matches local recovery identity.");
|
|
138
|
+
} else throw Error("The response did not resolve this exact saved request.");
|
|
139
|
+
$(), e = !0, await v();
|
|
140
|
+
} catch {
|
|
141
|
+
X(e ? "The saved request was resolved, but status refresh failed. Refresh status before submitting another job." : "The saved request could not be resolved. Keep its identity and retry recovery; do not submit a replacement.");
|
|
142
|
+
} finally {
|
|
143
|
+
Q.current = !1, q(!1);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
startAnotherJob: () => {
|
|
147
|
+
try {
|
|
148
|
+
o(window.sessionStorage, _), Z(null), G(!1);
|
|
149
|
+
} catch {
|
|
150
|
+
X("The prior request is not confirmed. Refresh status before starting another job.");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { m as useDatabricksQueueForm };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=useDatabricksQueueForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDatabricksQueueForm.js","names":[],"sources":["../../../src/cosmicintersection/hooks/useDatabricksQueueForm.ts"],"sourcesContent":["import { useRef, useState, type FormEvent } from 'react';\nimport type { DocumentNode } from 'graphql';\nimport { clearGraphqlFetchResponseCache } from '@burdenoff/fe-libs/shared/graphql';\n\nimport {\n CosDatabricksConnectionsDocument,\n CosDatabricksDatasetsDocument,\n CosQueueDatabricksStepDocument,\n CosResolveExternalComputeRequestDocument,\n type CosDatabricksConnectionsQuery,\n type CosDatabricksDatasetsQuery,\n type CosQueueDatabricksStepMutation,\n type CosResolveExternalComputeRequestMutation,\n} from '../../generated/wspace-operations';\nimport { databricksJobId, databricksParameters } from '../lib/databricksForm';\nimport {\n clearConfirmedDatabricksIntent,\n clearWithdrawnDatabricksIntent,\n confirmDatabricksIntent,\n prepareDatabricksIntent,\n readDatabricksIntent,\n type DatabricksIntent,\n} from '../lib/databricksIntent';\n\ntype Connection = CosDatabricksConnectionsQuery['connections']['items'][number];\ntype Dataset = CosDatabricksDatasetsQuery['cosListDatasets']['items'][number];\ntype Request = <T>(document: DocumentNode, variables: Record<string, unknown>) => Promise<T>;\n\nexport function useDatabricksQueueForm({\n request,\n runId,\n workspaceId,\n intentKey,\n onQueued,\n statusReady,\n canQueue,\n}: {\n request: Request;\n runId: string;\n workspaceId: string;\n intentKey: string;\n onQueued(): Promise<void>;\n statusReady: boolean;\n canQueue: boolean;\n}) {\n const [connections, setConnections] = useState<Connection[]>([]);\n const [datasets, setDatasets] = useState<Dataset[]>([]);\n const [connectionOffset, setConnectionOffset] = useState(0);\n const [datasetOffset, setDatasetOffset] = useState(0);\n const [moreConnections, setMoreConnections] = useState(false);\n const [moreDatasets, setMoreDatasets] = useState(false);\n const [connectionId, setConnectionId] = useState('');\n const [jobId, setJobId] = useState('');\n const [name, setName] = useState('Databricks job');\n const [parameters, setParameters] = useState('{}');\n const [maximum, setMaximum] = useState('3600');\n const [inputs, setInputs] = useState<string[]>([]);\n const [outputs, setOutputs] = useState<string[]>([]);\n const [confirmedCost, setConfirmedCost] = useState(false);\n const [busy, setBusy] = useState(false);\n const [saved] = useState(() => {\n try {\n return { intent: readDatabricksIntent(window.sessionStorage, intentKey), error: null };\n } catch {\n return {\n intent: null,\n error:\n 'The saved request is unreadable. Do not submit another job until its status is recovered.',\n };\n }\n });\n const [error, setError] = useState<string | null>(saved.error);\n const [intent, setIntent] = useState<DatabricksIntent | null>(saved.intent);\n const sending = useRef(false);\n\n const reloadIntent = () => setIntent(readDatabricksIntent(window.sessionStorage, intentKey));\n\n const loadOptions = async (kind: 'connections' | 'datasets') => {\n if (sending.current) return;\n sending.current = true;\n setBusy(true);\n setError(null);\n try {\n // The published FE4 transport has no per-request cache bypass. These\n // explicit choice refreshes must observe current credential eligibility;\n // clearing its shared short-lived read cache may refetch sibling reads.\n clearGraphqlFetchResponseCache();\n if (kind === 'connections') {\n const offset = moreConnections ? connectionOffset : 0;\n const result = await request<CosDatabricksConnectionsQuery>(\n CosDatabricksConnectionsDocument,\n {\n pagination: { limit: 50, offset },\n }\n );\n setConnections((previous) =>\n Array.from(\n new Map(\n [...(offset ? previous : []), ...result.connections.items]\n .filter(\n (item) =>\n item.workspaceId === workspaceId &&\n item.canUse &&\n item.status === 'ACTIVE' &&\n item.provider.key === 'generic-api-key'\n )\n .map((item) => [item.id, item])\n ).values()\n )\n );\n setConnectionOffset(offset + result.connections.items.length);\n setMoreConnections(result.connections.hasMore);\n } else {\n const offset = moreDatasets ? datasetOffset : 0;\n const result = await request<CosDatabricksDatasetsQuery>(CosDatabricksDatasetsDocument, {\n pagination: { limit: 50, offset },\n });\n setDatasets((previous) =>\n Array.from(\n new Map(\n [...(offset ? previous : []), ...result.cosListDatasets.items].map((item) => [\n item.id,\n item,\n ])\n ).values()\n )\n );\n setDatasetOffset(offset + result.cosListDatasets.items.length);\n setMoreDatasets(result.cosListDatasets.pageInfo.hasMore);\n }\n } catch {\n setError('Could not load choices. Retry this read; no job was submitted.');\n } finally {\n sending.current = false;\n setBusy(false);\n }\n };\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n if (sending.current) return;\n sending.current = true;\n setBusy(true);\n setError(null);\n let dispatched = false;\n let serverConfirmed = false;\n try {\n if (!canQueue || !statusReady) {\n throw new Error('Refresh and confirm existing job status before submitting a request.');\n }\n if (!confirmedCost || !connections.some((item) => item.id === connectionId)) {\n throw new Error(\n 'Choose an available existing connection and confirm external usage charges.'\n );\n }\n const maxRuntimeSeconds = Number(maximum);\n if (\n !Number.isSafeInteger(maxRuntimeSeconds) ||\n maxRuntimeSeconds < 60 ||\n maxRuntimeSeconds > 86400\n ) {\n throw new Error('Choose a monitoring deadline between 60 and 86,400 seconds.');\n }\n if (!name.trim() || name.trim().length > 255)\n throw new Error('Enter a job step name of at most 255 characters.');\n if (inputs.length > 100 || outputs.length > 100)\n throw new Error('Select at most 100 datasets for each lineage direction.');\n const input = {\n connectionId,\n jobId: databricksJobId(jobId),\n name: name.trim(),\n parameters: databricksParameters(parameters),\n inputDatasetIds: inputs,\n outputDatasetIds: outputs,\n maxRuntimeSeconds,\n };\n const prepared = await prepareDatabricksIntent(window.sessionStorage, intentKey, input);\n if (prepared.confirmedExecutionId)\n throw new Error('This request is already confirmed. Explicitly start another job below.');\n setIntent(prepared);\n dispatched = true;\n const result = await request<CosQueueDatabricksStepMutation>(CosQueueDatabricksStepDocument, {\n runId,\n input: { ...input, requestId: prepared.requestId },\n });\n if (\n result.cosQueueDatabricksStep.runId !== runId ||\n result.cosQueueDatabricksStep.requestId !== prepared.requestId\n ) {\n throw new Error('The returned execution did not match the saved request.');\n }\n serverConfirmed = true;\n let recoveryStorageFailed = false;\n try {\n if (\n !confirmDatabricksIntent(window.sessionStorage, intentKey, result.cosQueueDatabricksStep)\n )\n throw new Error('The acknowledged execution no longer matches local recovery identity.');\n reloadIntent();\n } catch {\n // A local storage failure cannot undo the acknowledged server execution.\n recoveryStorageFailed = true;\n }\n await onQueued();\n if (recoveryStorageFailed) {\n setError(\n 'The job request is confirmed and status was refreshed, but local recovery storage failed. Do not submit another job; recover the original request identity.'\n );\n }\n } catch (failure) {\n setError(\n serverConfirmed\n ? 'The job request is confirmed, but its status refresh failed. Refresh job status; do not submit a replacement.'\n : dispatched\n ? 'The queue outcome was not confirmed. Refresh job status. Retrying identical inputs reuses the saved request; changing them is refused until the original is recovered.'\n : failure instanceof Error\n ? failure.message\n : 'The request could not be verified. No job was submitted.'\n );\n } finally {\n sending.current = false;\n setBusy(false);\n }\n };\n\n const checkSavedRequest = () => {\n try {\n reloadIntent();\n } catch {\n setError('The saved request could not be verified.');\n }\n };\n const resolveSavedRequest = async () => {\n if (sending.current) return;\n sending.current = true;\n setBusy(true);\n setError(null);\n let resolved = false;\n try {\n const savedRequest = readDatabricksIntent(window.sessionStorage, intentKey);\n if (!savedRequest || savedRequest.confirmedExecutionId) {\n throw new Error('Only an unresolved saved request can be recovered here.');\n }\n const result = await request<CosResolveExternalComputeRequestMutation>(\n CosResolveExternalComputeRequestDocument,\n { runId, requestId: savedRequest.requestId }\n );\n const resolution = result.cosResolveExternalComputeRequest;\n if (\n readDatabricksIntent(window.sessionStorage, intentKey)?.requestId !== savedRequest.requestId\n ) {\n throw new Error('The saved request changed while recovery was running.');\n }\n if (resolution.withdrawn && resolution.execution === null) {\n clearWithdrawnDatabricksIntent(window.sessionStorage, intentKey, savedRequest.requestId);\n setConfirmedCost(false);\n } else if (\n !resolution.withdrawn &&\n resolution.execution?.runId === runId &&\n resolution.execution.requestId === savedRequest.requestId\n ) {\n if (!confirmDatabricksIntent(window.sessionStorage, intentKey, resolution.execution))\n throw new Error('The recovered execution no longer matches local recovery identity.');\n } else {\n throw new Error('The response did not resolve this exact saved request.');\n }\n reloadIntent();\n resolved = true;\n await onQueued();\n } catch {\n setError(\n resolved\n ? 'The saved request was resolved, but status refresh failed. Refresh status before submitting another job.'\n : 'The saved request could not be resolved. Keep its identity and retry recovery; do not submit a replacement.'\n );\n } finally {\n sending.current = false;\n setBusy(false);\n }\n };\n const startAnotherJob = () => {\n try {\n clearConfirmedDatabricksIntent(window.sessionStorage, intentKey);\n setIntent(null);\n setConfirmedCost(false);\n } catch {\n setError('The prior request is not confirmed. Refresh status before starting another job.');\n }\n };\n return {\n connections,\n datasets,\n connectionOffset,\n datasetOffset,\n moreConnections,\n moreDatasets,\n connectionId,\n jobId,\n name,\n parameters,\n maximum,\n inputs,\n outputs,\n confirmedCost,\n busy,\n error,\n intent,\n setConnectionId,\n setJobId,\n setName,\n setParameters,\n setMaximum,\n setInputs,\n setOutputs,\n setConfirmedCost,\n loadOptions,\n submit,\n checkSavedRequest,\n resolveSavedRequest,\n startAnotherJob,\n };\n}\n"],"mappings":";;;;;;AA4BA,SAAgB,EAAuB,EACrC,YACA,UACA,gBACA,cACA,aACA,iBACA,eASC;CACD,IAAM,CAAC,GAAa,KAAkB,EAAuB,CAAC,CAAC,GACzD,CAAC,GAAU,KAAe,EAAoB,CAAC,CAAC,GAChD,CAAC,GAAkB,KAAuB,EAAS,CAAC,GACpD,CAAC,GAAe,KAAoB,EAAS,CAAC,GAC9C,CAAC,GAAiB,KAAsB,EAAS,EAAK,GACtD,CAAC,GAAc,MAAmB,EAAS,EAAK,GAChD,CAAC,GAAc,MAAmB,EAAS,EAAE,GAC7C,CAAC,GAAO,KAAY,EAAS,EAAE,GAC/B,CAAC,GAAM,KAAW,EAAS,gBAAgB,GAC3C,CAAC,GAAY,KAAiB,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gBAAgB,CAAS,CAAC,EAAE,cAAc,EAAa,WAEnF,MAAU,MAAM,uDAAuD;IAEzE,IAAI,EAAW,aAAa,EAAW,cAAc,MAEnD,AADA,EAA+B,OAAO,gBAAgB,GAAW,EAAa,SAAS,GACvF,EAAiB,EAAK;SACjB,IACL,CAAC,EAAW,aACZ,EAAW,WAAW,UAAU,KAChC,EAAW,UAAU,cAAc,EAAa;SAE5C,CAAC,EAAwB,OAAO,gBAAgB,GAAW,EAAW,SAAS,GACjF,MAAU,MAAM,oEAAoE;IAAA,OAEtF,MAAU,MAAM,wDAAwD;IAI1E,AAFA,EAAa,GACb,IAAW,IACX,MAAM,EAAS;GACjB,QAAQ;IACN,EACE,IACI,6GACA,6GACN;GACF,UAAU;IAER,AADA,EAAQ,UAAU,IAClB,EAAQ,EAAK;GACf;EACF;EAwCE,uBAvC4B;GAC5B,IAAI;IAGF,AAFA,EAA+B,OAAO,gBAAgB,CAAS,GAC/D,EAAU,IAAI,GACd,EAAiB,EAAK;GACxB,QAAQ;IACN,EAAS,iFAAiF;GAC5F;EACF;CAgCA;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Browser validation improves feedback; the service remains authoritative. */
|
|
2
|
+
export declare function databricksParameters(text: string): Record<string, string>;
|
|
3
|
+
export declare function databricksJobId(text: string): string;
|
|
4
|
+
//# sourceMappingURL=databricksForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksForm.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/lib/databricksForm.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiCzE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/cosmicintersection/lib/databricksForm.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t;
|
|
4
|
+
try {
|
|
5
|
+
t = JSON.parse(e);
|
|
6
|
+
} catch {
|
|
7
|
+
throw Error("Job parameters must be valid JSON with nonsecret string values.");
|
|
8
|
+
}
|
|
9
|
+
if (!t || typeof t != "object" || Array.isArray(t)) throw Error("Job parameters must be a JSON object with string values.");
|
|
10
|
+
let n = Object.entries(t);
|
|
11
|
+
if (n.length > 50) throw Error("Use at most 50 job parameters.");
|
|
12
|
+
let r = {};
|
|
13
|
+
for (let [e, t] of n) {
|
|
14
|
+
if (!/^[A-Za-z][A-Za-z0-9_.-]{0,99}$/.test(e) || /password|passcode|token|secret|authorization|cookie|credential|api.?key/i.test(e) || [
|
|
15
|
+
"__proto__",
|
|
16
|
+
"constructor",
|
|
17
|
+
"prototype"
|
|
18
|
+
].includes(e) || e.startsWith("cosmicintersection_") || typeof t != "string" || t.length > 4096 || Array.from(t).some((e) => e.charCodeAt(0) < 32)) throw Error("Use nonsecret, non-reserved parameter names and string values of at most 4,096 characters without control characters.");
|
|
19
|
+
r[e] = t;
|
|
20
|
+
}
|
|
21
|
+
if (new TextEncoder().encode(JSON.stringify(r)).byteLength > 16384) throw Error("Encoded job parameters must fit within 16 KiB.");
|
|
22
|
+
return r;
|
|
23
|
+
}
|
|
24
|
+
function t(e) {
|
|
25
|
+
if (!/^[1-9]\d{0,15}$/.test(e) || !Number.isSafeInteger(Number(e))) throw Error("Enter the positive numeric ID of an existing Databricks job.");
|
|
26
|
+
return e;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { t as databricksJobId, e as databricksParameters };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=databricksForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksForm.js","names":[],"sources":["../../../src/cosmicintersection/lib/databricksForm.ts"],"sourcesContent":["/** Browser validation improves feedback; the service remains authoritative. */\nexport function databricksParameters(text: string): Record<string, string> {\n let value: unknown;\n try {\n value = JSON.parse(text);\n } catch {\n throw new Error('Job parameters must be valid JSON with nonsecret string values.');\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error('Job parameters must be a JSON object with string values.');\n }\n const entries = Object.entries(value);\n if (entries.length > 50) throw new Error('Use at most 50 job parameters.');\n const result: Record<string, string> = {};\n for (const [key, item] of entries) {\n if (\n !/^[A-Za-z][A-Za-z0-9_.-]{0,99}$/.test(key) ||\n /password|passcode|token|secret|authorization|cookie|credential|api.?key/i.test(key) ||\n ['__proto__', 'constructor', 'prototype'].includes(key) ||\n key.startsWith('cosmicintersection_') ||\n typeof item !== 'string' ||\n item.length > 4096 ||\n Array.from(item).some((char) => char.charCodeAt(0) < 32)\n ) {\n throw new Error(\n 'Use nonsecret, non-reserved parameter names and string values of at most 4,096 characters without control characters.'\n );\n }\n result[key] = item;\n }\n if (new TextEncoder().encode(JSON.stringify(result)).byteLength > 16_384) {\n throw new Error('Encoded job parameters must fit within 16 KiB.');\n }\n return result;\n}\n\nexport function databricksJobId(text: string): string {\n if (!/^[1-9]\\d{0,15}$/.test(text) || !Number.isSafeInteger(Number(text))) {\n throw new Error('Enter the positive numeric ID of an existing Databricks job.');\n }\n return text;\n}\n"],"mappings":";AACA,SAAgB,EAAqB,GAAsC;CACzE,IAAI;CACJ,IAAI;EACF,IAAQ,KAAK,MAAM,CAAI;CACzB,QAAQ;EACN,MAAU,MAAM,iEAAiE;CACnF;CACA,IAAI,CAAC,KAAS,OAAO,KAAU,YAAY,MAAM,QAAQ,CAAK,GAC5D,MAAU,MAAM,0DAA0D;CAE5E,IAAM,IAAU,OAAO,QAAQ,CAAK;CACpC,IAAI,EAAQ,SAAS,IAAI,MAAU,MAAM,gCAAgC;CACzE,IAAM,IAAiC,CAAC;CACxC,KAAK,IAAM,CAAC,GAAK,MAAS,GAAS;EACjC,IACE,CAAC,iCAAiC,KAAK,CAAG,KAC1C,2EAA2E,KAAK,CAAG,KACnF;GAAC;GAAa;GAAe;EAAW,CAAC,CAAC,SAAS,CAAG,KACtD,EAAI,WAAW,qBAAqB,KACpC,OAAO,KAAS,YAChB,EAAK,SAAS,QACd,MAAM,KAAK,CAAI,CAAC,CAAC,MAAM,MAAS,EAAK,WAAW,CAAC,IAAI,EAAE,GAEvD,MAAU,MACR,uHACF;EAEF,EAAO,KAAO;CAChB;CACA,IAAI,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,CAAM,CAAC,CAAC,CAAC,aAAa,OAChE,MAAU,MAAM,gDAAgD;CAElE,OAAO;AACT;AAEA,SAAgB,EAAgB,GAAsB;CACpD,IAAI,CAAC,kBAAkB,KAAK,CAAI,KAAK,CAAC,OAAO,cAAc,OAAO,CAAI,CAAC,GACrE,MAAU,MAAM,8DAA8D;CAEhF,OAAO;AACT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Durable product intent only: never stores credentials, names or job parameters. */
|
|
2
|
+
export interface DatabricksIntent {
|
|
3
|
+
requestId: string;
|
|
4
|
+
fingerprint: string;
|
|
5
|
+
confirmedExecutionId?: string;
|
|
6
|
+
}
|
|
7
|
+
type IntentStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
8
|
+
export declare function readDatabricksIntent(storage: IntentStorage, key: string): DatabricksIntent | null;
|
|
9
|
+
export declare function prepareDatabricksIntent(storage: IntentStorage, key: string, input: unknown): Promise<DatabricksIntent>;
|
|
10
|
+
export declare function confirmDatabricksIntent(storage: IntentStorage, key: string, execution: {
|
|
11
|
+
requestId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
}): boolean;
|
|
14
|
+
/** Explicit "another job" only after the server returned this exact intent. */
|
|
15
|
+
export declare function clearConfirmedDatabricksIntent(storage: IntentStorage, key: string): void;
|
|
16
|
+
/** Called only after the service durably fenced this exact absent request UUID. */
|
|
17
|
+
export declare function clearWithdrawnDatabricksIntent(storage: IntentStorage, key: string, requestId: string): void;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=databricksIntent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksIntent.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/lib/databricksIntent.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,KAAK,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC;AAIzE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CA8BjG;AAkBD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,gBAAgB,CAAC,CAmB3B;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAMT;AAED,+EAA+E;AAC/E,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAMxF;AAED,mFAAmF;AACnF,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,GAChB,IAAI,CAMN"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/cosmicintersection/lib/databricksIntent.ts
|
|
2
|
+
var e = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = t.getItem(n);
|
|
5
|
+
if (r === null) return null;
|
|
6
|
+
let i;
|
|
7
|
+
try {
|
|
8
|
+
i = JSON.parse(r);
|
|
9
|
+
} catch {
|
|
10
|
+
throw Error("The saved Databricks request cannot be verified. Do not submit another job.");
|
|
11
|
+
}
|
|
12
|
+
if (!i || typeof i != "object" || !("requestId" in i) || typeof i.requestId != "string" || !e.test(i.requestId) || !("fingerprint" in i) || typeof i.fingerprint != "string" || !/^[a-f0-9]{64}$/.test(i.fingerprint) || "confirmedExecutionId" in i && (typeof i.confirmedExecutionId != "string" || !e.test(i.confirmedExecutionId))) throw Error("The saved Databricks request cannot be verified. Do not submit another job.");
|
|
13
|
+
return {
|
|
14
|
+
requestId: i.requestId,
|
|
15
|
+
fingerprint: i.fingerprint,
|
|
16
|
+
..."confirmedExecutionId" in i && typeof i.confirmedExecutionId == "string" ? { confirmedExecutionId: i.confirmedExecutionId } : {}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function n(e) {
|
|
20
|
+
if (Array.isArray(e)) return `[${e.map(n).join(",")}]`;
|
|
21
|
+
if (typeof e == "object" && e) return `{${Object.entries(e).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => `${JSON.stringify(e)}:${n(t)}`).join(",")}}`;
|
|
22
|
+
if (e === void 0 || typeof e == "number" && !Number.isFinite(e)) throw Error("Databricks request contains an unsupported value.");
|
|
23
|
+
let t = JSON.stringify(e);
|
|
24
|
+
if (t === void 0) throw Error("Databricks request contains an unsupported value.");
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
async function r(e, r, i) {
|
|
28
|
+
let a = new TextEncoder().encode(n(i)), o = Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", a))).map((e) => e.toString(16).padStart(2, "0")).join(""), s = t(e, r);
|
|
29
|
+
if (s) {
|
|
30
|
+
if (s.fingerprint !== o) throw Error("A previous request is unresolved. Restore its exact inputs and retry or inspect its status.");
|
|
31
|
+
return s;
|
|
32
|
+
}
|
|
33
|
+
let c = {
|
|
34
|
+
requestId: crypto.randomUUID(),
|
|
35
|
+
fingerprint: o
|
|
36
|
+
};
|
|
37
|
+
return e.setItem(r, JSON.stringify(c)), c;
|
|
38
|
+
}
|
|
39
|
+
function i(n, r, i) {
|
|
40
|
+
let a = t(n, r);
|
|
41
|
+
if (!a || a.requestId !== i.requestId) return !1;
|
|
42
|
+
if (!e.test(i.id)) throw Error("The confirmed execution ID is invalid.");
|
|
43
|
+
return n.setItem(r, JSON.stringify({
|
|
44
|
+
...a,
|
|
45
|
+
confirmedExecutionId: i.id
|
|
46
|
+
})), !0;
|
|
47
|
+
}
|
|
48
|
+
function a(e, n) {
|
|
49
|
+
if (!t(e, n)?.confirmedExecutionId) throw Error("Refresh the existing request status before queuing another job.");
|
|
50
|
+
e.removeItem(n);
|
|
51
|
+
}
|
|
52
|
+
function o(e, n, r) {
|
|
53
|
+
let i = t(e, n);
|
|
54
|
+
if (!i || i.requestId !== r || i.confirmedExecutionId) throw Error("The acknowledged withdrawal does not match the unresolved saved request.");
|
|
55
|
+
e.removeItem(n);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { a as clearConfirmedDatabricksIntent, o as clearWithdrawnDatabricksIntent, i as confirmDatabricksIntent, r as prepareDatabricksIntent, t as readDatabricksIntent };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=databricksIntent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksIntent.js","names":[],"sources":["../../../src/cosmicintersection/lib/databricksIntent.ts"],"sourcesContent":["/** Durable product intent only: never stores credentials, names or job parameters. */\nexport interface DatabricksIntent {\n requestId: string;\n fingerprint: string;\n confirmedExecutionId?: string;\n}\n\ntype IntentStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;\n\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport function readDatabricksIntent(storage: IntentStorage, key: string): DatabricksIntent | null {\n const raw = storage.getItem(key);\n if (raw === null) return null;\n let value: unknown;\n try {\n value = JSON.parse(raw);\n } catch {\n throw new Error('The saved Databricks request cannot be verified. Do not submit another job.');\n }\n if (\n !value ||\n typeof value !== 'object' ||\n !('requestId' in value) ||\n typeof value.requestId !== 'string' ||\n !UUID.test(value.requestId) ||\n !('fingerprint' in value) ||\n typeof value.fingerprint !== 'string' ||\n !/^[a-f0-9]{64}$/.test(value.fingerprint) ||\n ('confirmedExecutionId' in value &&\n (typeof value.confirmedExecutionId !== 'string' || !UUID.test(value.confirmedExecutionId)))\n ) {\n throw new Error('The saved Databricks request cannot be verified. Do not submit another job.');\n }\n return {\n requestId: value.requestId,\n fingerprint: value.fingerprint,\n ...('confirmedExecutionId' in value && typeof value.confirmedExecutionId === 'string'\n ? { confirmedExecutionId: value.confirmedExecutionId }\n : {}),\n };\n}\n\n/** Stable serialization makes reordered parameter keys the same intent. */\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') {\n return `{${Object.entries(value)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n .map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`)\n .join(',')}}`;\n }\n if (value === undefined || (typeof value === 'number' && !Number.isFinite(value)))\n throw new Error('Databricks request contains an unsupported value.');\n const encoded = JSON.stringify(value);\n if (encoded === undefined) throw new Error('Databricks request contains an unsupported value.');\n return encoded;\n}\n\nexport async function prepareDatabricksIntent(\n storage: IntentStorage,\n key: string,\n input: unknown\n): Promise<DatabricksIntent> {\n const bytes = new TextEncoder().encode(canonical(input));\n const fingerprint = Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', bytes)))\n .map((byte) => byte.toString(16).padStart(2, '0'))\n .join('');\n // Read after hashing so a preceding same-tab submission cannot be overwritten.\n const previous = readDatabricksIntent(storage, key);\n if (previous) {\n if (previous.fingerprint !== fingerprint) {\n throw new Error(\n 'A previous request is unresolved. Restore its exact inputs and retry or inspect its status.'\n );\n }\n return previous;\n }\n const intent = { requestId: crypto.randomUUID(), fingerprint };\n // A failed persistence write must prevent the network request entirely.\n storage.setItem(key, JSON.stringify(intent));\n return intent;\n}\n\nexport function confirmDatabricksIntent(\n storage: IntentStorage,\n key: string,\n execution: { requestId: string; id: string }\n): boolean {\n const intent = readDatabricksIntent(storage, key);\n if (!intent || intent.requestId !== execution.requestId) return false;\n if (!UUID.test(execution.id)) throw new Error('The confirmed execution ID is invalid.');\n storage.setItem(key, JSON.stringify({ ...intent, confirmedExecutionId: execution.id }));\n return true;\n}\n\n/** Explicit \"another job\" only after the server returned this exact intent. */\nexport function clearConfirmedDatabricksIntent(storage: IntentStorage, key: string): void {\n const intent = readDatabricksIntent(storage, key);\n if (!intent?.confirmedExecutionId) {\n throw new Error('Refresh the existing request status before queuing another job.');\n }\n storage.removeItem(key);\n}\n\n/** Called only after the service durably fenced this exact absent request UUID. */\nexport function clearWithdrawnDatabricksIntent(\n storage: IntentStorage,\n key: string,\n requestId: string\n): void {\n const intent = readDatabricksIntent(storage, key);\n if (!intent || intent.requestId !== requestId || intent.confirmedExecutionId) {\n throw new Error('The acknowledged withdrawal does not match the unresolved saved request.');\n }\n storage.removeItem(key);\n}\n"],"mappings":";AASA,IAAM,IAAO;AAEb,SAAgB,EAAqB,GAAwB,GAAsC;CACjG,IAAM,IAAM,EAAQ,QAAQ,CAAG;CAC/B,IAAI,MAAQ,MAAM,OAAO;CACzB,IAAI;CACJ,IAAI;EACF,IAAQ,KAAK,MAAM,CAAG;CACxB,QAAQ;EACN,MAAU,MAAM,6EAA6E;CAC/F;CACA,IACE,CAAC,KACD,OAAO,KAAU,YACjB,EAAE,eAAe,MACjB,OAAO,EAAM,aAAc,YAC3B,CAAC,EAAK,KAAK,EAAM,SAAS,KAC1B,EAAE,iBAAiB,MACnB,OAAO,EAAM,eAAgB,YAC7B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AAI,EAAS,gBAAgB,GAC3B,MAAU,MACR,6FACF;EAEF,OAAO;CACT;CACA,IAAM,IAAS;EAAE,WAAW,OAAO,WAAW;EAAG;CAAY;CAG7D,OADA,EAAQ,QAAQ,GAAK,KAAK,UAAU,CAAM,CAAC,GACpC;AACT;AAEA,SAAgB,EACd,GACA,GACA,GACS;CACT,IAAM,IAAS,EAAqB,GAAS,CAAG;CAChD,IAAI,CAAC,KAAU,EAAO,cAAc,EAAU,WAAW,OAAO;CAChE,IAAI,CAAC,EAAK,KAAK,EAAU,EAAE,GAAG,MAAU,MAAM,wCAAwC;CAEtF,OADA,EAAQ,QAAQ,GAAK,KAAK,UAAU;EAAE,GAAG;EAAQ,sBAAsB,EAAU;CAAG,CAAC,CAAC,GAC/E;AACT;AAGA,SAAgB,EAA+B,GAAwB,GAAmB;CAExF,IAAI,CADW,EAAqB,GAAS,CACxC,CAAA,EAAQ,sBACX,MAAU,MAAM,iEAAiE;CAEnF,EAAQ,WAAW,CAAG;AACxB;AAGA,SAAgB,EACd,GACA,GACA,GACM;CACN,IAAM,IAAS,EAAqB,GAAS,CAAG;CAChD,IAAI,CAAC,KAAU,EAAO,cAAc,KAAa,EAAO,sBACtD,MAAU,MAAM,0EAA0E;CAE5F,EAAQ,WAAW,CAAG;AACxB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DatabricksRequestScope } from '../api/databricksTransport';
|
|
2
|
+
/** No bearer or job parameters enter the durable product-intent key. */
|
|
3
|
+
export declare function databricksIntentKey(scope: DatabricksRequestScope, runId: string): string;
|
|
4
|
+
export declare function safeLogsUrl(value: string | null | undefined): string | null;
|
|
5
|
+
//# sourceMappingURL=databricksPresentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksPresentation.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/lib/databricksPresentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBxF;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAa3E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/cosmicintersection/lib/databricksPresentation.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
let n = new URL(e.apiGatewayUrl);
|
|
4
|
+
if (!["http:", "https:"].includes(n.protocol) || n.username || n.password || n.search || n.hash) throw Error("Databricks requires a gateway URL without embedded credentials or query parameters.");
|
|
5
|
+
return "cosmic.databricks.intent.v1:" + JSON.stringify([
|
|
6
|
+
n.origin + n.pathname,
|
|
7
|
+
e.actorId,
|
|
8
|
+
e.tenantId ?? null,
|
|
9
|
+
e.organizationId ?? null,
|
|
10
|
+
e.workspaceId,
|
|
11
|
+
e.projectId ?? null,
|
|
12
|
+
t
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
function t(e) {
|
|
16
|
+
if (!e) return null;
|
|
17
|
+
try {
|
|
18
|
+
let t = new URL(e);
|
|
19
|
+
return t.protocol === "https:" && !t.username && !t.password && t.hostname.endsWith(".cloud.databricks.com") ? t.href : null;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as databricksIntentKey, t as safeLogsUrl };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=databricksPresentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"databricksPresentation.js","names":[],"sources":["../../../src/cosmicintersection/lib/databricksPresentation.ts"],"sourcesContent":["import type { DatabricksRequestScope } from '../api/databricksTransport';\n\n/** No bearer or job parameters enter the durable product-intent key. */\nexport function databricksIntentKey(scope: DatabricksRequestScope, runId: string): string {\n const gateway = new URL(scope.apiGatewayUrl);\n if (\n !['http:', 'https:'].includes(gateway.protocol) ||\n gateway.username ||\n gateway.password ||\n gateway.search ||\n gateway.hash\n ) {\n throw new Error(\n 'Databricks requires a gateway URL without embedded credentials or query parameters.'\n );\n }\n return (\n 'cosmic.databricks.intent.v1:' +\n JSON.stringify([\n gateway.origin + gateway.pathname,\n scope.actorId,\n scope.tenantId ?? null,\n scope.organizationId ?? null,\n scope.workspaceId,\n scope.projectId ?? null,\n runId,\n ])\n );\n}\n\n// Match the backend AWS-only attested origin contract; Azure/GCP are not supported.\nexport function safeLogsUrl(value: string | null | undefined): string | null {\n if (!value) return null;\n try {\n const url = new URL(value);\n return url.protocol === 'https:' &&\n !url.username &&\n !url.password &&\n url.hostname.endsWith('.cloud.databricks.com')\n ? url.href\n : null;\n } catch {\n return null;\n }\n}\n"],"mappings":";AAGA,SAAgB,EAAoB,GAA+B,GAAuB;CACxF,IAAM,IAAU,IAAI,IAAI,EAAM,aAAa;CAC3C,IACE,CAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,SAAS,EAAQ,QAAQ,KAC9C,EAAQ,YACR,EAAQ,YACR,EAAQ,UACR,EAAQ,MAER,MAAU,MACR,qFACF;CAEF,OACE,iCACA,KAAK,UAAU;EACb,EAAQ,SAAS,EAAQ;EACzB,EAAM;EACN,EAAM,YAAY;EAClB,EAAM,kBAAkB;EACxB,EAAM;EACN,EAAM,aAAa;EACnB;CACF,CAAC;AAEL;AAGA,SAAgB,EAAY,GAAiD;CAC3E,IAAI,CAAC,GAAO,OAAO;CACnB,IAAI;EACF,IAAM,IAAM,IAAI,IAAI,CAAK;EACzB,OAAO,EAAI,aAAa,YACtB,CAAC,EAAI,YACL,CAAC,EAAI,YACL,EAAI,SAAS,SAAS,uBAAuB,IAC3C,EAAI,OACJ;CACN,QAAQ;EACN,OAAO;CACT;AACF"}
|