@devcabs/folio-engine 0.1.0 → 0.1.1

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.
@@ -0,0 +1,34 @@
1
+ "use strict";const d=require("./edge-1WCVZ0J7.cjs");function L(e){return e.type==="section"}function p(e){return e.type==="subsection"}function V(e){return e.type==="text"||e.type==="photo"||e.type==="gallery"||e.type==="chart"}function x(e){return e.type==="text"}function y(e){return e.type==="photo"}function K(e){return e.type==="gallery"}function Q(e){return e.type==="chart"}const u=[320,400,600,800,1200,1600],g=800,f=/^[a-zA-Z0-9_-]{10,64}$/;function A(e){if(typeof e!="number"||isNaN(e)||e<=0)return g;if(e<=u[0])return u[0];if(e>=u[u.length-1])return u[u.length-1];let t=g,n=1/0;for(const r of u){const s=Math.abs(r-e);s<=n&&(n=s,t=r)}return t}function m(e){if(!e||typeof e!="string")return null;const t=e.trim();if(f.test(t))return t;const n=t.match(/[?&]id=([a-zA-Z0-9_-]{10,64})/);if(n!=null&&n[1]&&f.test(n[1]))return n[1];const r=t.match(/\/(?:d|folders)\/([a-zA-Z0-9_-]{10,64})/);return r!=null&&r[1]&&f.test(r[1])?r[1]:null}function T(e,t={}){const n=m(e);if(!n)return e||"";const r=A(t.width??g),s=`/api/media/drive/${n}?w=${r}`;return t.format&&t.format!=="auto"?`${s}&fmt=${t.format}`:s}function S(e,t=[400,800,1200,1600]){const n=m(e);return n?t.map(r=>{const s=A(r);return`${T(n,{width:s})} ${s}w`}).join(", "):""}const I=[{chartId:"chart-access-enrolment",title:"Operational Activity Volume",subtitle:"Monthly processed transaction volume across regional units (units)",unit:"units",asOfDate:"2026-Q1",chartType:"bar",nodeId:"access",visualConfig:{unit:"units",excludeSummaryRows:!0,yMin:0,orientation:"vertical",barOrientation:"vertical"},categories:["Unit 1","Unit 2","Unit 3","Unit 4","Unit 5","Unit 6"],series:[{name:"Completed Tasks",data:[420,510,630,590,710,680],color:"#0284c7"},{name:"Pending Tasks",data:[390,480,580,560,670,640],color:"#38bdf8"}],sanitizedCsvContent:`# Title: Operational Activity Volume (units)
2
+ Category,Completed Tasks,Pending Tasks
3
+ Unit 1,420,390
4
+ Unit 2,510,480
5
+ Unit 3,630,580
6
+ Unit 4,590,560
7
+ Unit 5,710,670
8
+ Unit 6,680,640`},{chartId:"chart-equity-assistance",title:"Resource Allocation by Department",subtitle:"Percentage distribution of standard operational expenditure",unit:"%",asOfDate:"2026-Q1",chartType:"donut",nodeId:"equity",visualConfig:{unit:"%",excludeSummaryRows:!0,donutVariant:"donut"},categories:["Operations","Logistics","Administration","Planning","Support"],series:[{name:"Allocation",data:[32,26,20,14,8],color:"#881337"}],sanitizedCsvContent:`# Title: Resource Allocation by Department (%)
9
+ Category,Allocation
10
+ Operations,32
11
+ Logistics,26
12
+ Administration,20
13
+ Planning,14
14
+ Support,8`},{chartId:"chart-quality-mps",title:"Quarterly Performance Index",subtitle:"Standard performance indicators recorded over consecutive quarters",unit:"pts",asOfDate:"2026-Q1",chartType:"line",nodeId:"quality",visualConfig:{unit:"pts",excludeSummaryRows:!0,yMin:0,curveInterpolation:"smooth",showAreaFill:!0},categories:["Q1","Q2","Q3","Q4","Q5"],series:[{name:"Primary Indicator",data:[48,41,33,26,19],color:"#f59e0b"},{name:"Secondary Indicator",data:[82,69,54,42,31],color:"#b45309"}],sanitizedCsvContent:`# Title: Quarterly Performance Index (pts)
15
+ Quarter,Primary Indicator,Secondary Indicator
16
+ Q1,48,82
17
+ Q2,41,69
18
+ Q3,33,54
19
+ Q4,26,42
20
+ Q5,19,31`},{chartId:"chart-resiliency-drrm",title:"Response Time Distribution",subtitle:"Distribution of response completion times across standard requests",unit:"ms",asOfDate:"2026-Q1",chartType:"bar",nodeId:"resiliency",visualConfig:{unit:"ms",excludeSummaryRows:!0,yMin:0},categories:["0-10ms","10-20ms","20-30ms","30-40ms","40-50ms",">50ms"],series:[{name:"Recorded Responses",data:[142,89,45,12,4,1],color:"#15803d"}],sanitizedCsvContent:`# Title: Response Time Distribution (ms)
21
+ Bucket,Recorded Responses
22
+ 0-10ms,142
23
+ 10-20ms,89
24
+ 20-30ms,45
25
+ 30-40ms,12
26
+ 40-50ms,4
27
+ >50ms,1`},{chartId:"chart-governance-mooe",title:"Scheduled Tasks & Administrative Reviews",subtitle:"Weekly completed reviews and administrative filings",unit:"tasks",asOfDate:"2026-Q1",chartType:"bar",nodeId:"governance",visualConfig:{unit:"tasks",excludeSummaryRows:!0,yMin:0},categories:["Week 1","Week 2","Week 3","Week 4","Week 5","Week 6"],series:[{name:"Scheduled Tasks",data:[120,145,160,185,210,230],color:"#d97706"},{name:"Completed Reviews",data:[18,22,28,31,35,42],color:"#b45309"}],sanitizedCsvContent:`# Title: Scheduled Tasks & Administrative Reviews (tasks)
28
+ Week,Scheduled Tasks,Completed Reviews
29
+ Week 1,120,18
30
+ Week 2,145,22
31
+ Week 3,160,28
32
+ Week 4,185,31
33
+ Week 5,210,35
34
+ Week 6,230,42`}],v={},C=[400,800,1600],b="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 800px",k="16/9";function c(e){if(typeof process<"u"&&(process!=null&&process.env))return process.env[e]}function h(e){if(!e||!Array.isArray(e.sections))return e;const t=JSON.parse(JSON.stringify(e));return t.sections=t.sections.map(n=>{if(!n||!Array.isArray(n.elements))return n;const r=n.elements.map(s=>{if(p(s)){const a=s;if(Array.isArray(a.elements)){const i=a.elements.map(o=>y(o)?E(o):o);return{...a,elements:i}}return a}return y(s)?E(s):s});return{...n,elements:r}}),t}function E(e){if(!e.src||typeof e.src!="string")return e;const t=e.src.trim(),n=m(t);if(!n)return e;const r=T(n,{width:800}),s=S(n,C),a=e.sizes||b,i=e.aspectRatio||k;return{...e,src:r,srcSet:s,sizes:a,aspectRatio:i,rawDriveUrl:e.rawDriveUrl||t}}function D(e,t){const n={};if(Array.isArray(I))for(const r of I)r&&r.chartId&&(!r.nodeId||r.nodeId.toLowerCase()===e.toLowerCase())&&(n[r.chartId]=r);if(t)for(const[r,s]of Object.entries(t))n[r]=s;return n}function P(e,t){const n={},r=v;if(r&&typeof r=="object")for(const[s,a]of Object.entries(r))s.toLowerCase().includes(e.toLowerCase())&&(n[s]={pointId:s,folderUrl:a.folderUrl,folderTitle:a.folderTitle,description:a.description,lastSyncedAt:a.lastVerified});if(t)for(const[s,a]of Object.entries(t))n[s]=a;return n}function O(e,t,n){var l;const r=((l=t.canvases)==null?void 0:l[e])||{nodeId:e,version:t.schemaVersion||1,sections:[],updatedAt:t.createdAt},s=h(r),a=D(e,n==null?void 0:n.chartDatasets),i=P(e,n==null?void 0:n.sourceMetadata),o={nodeId:e,snapshotId:t.id,version:t.schemaVersion||1,updatedAt:t.createdAt,canvas:s,chartDatasets:a,sourceMetadata:i};return d.PublicNodePayloadSchema.parse(o),o}function _(e,t){const n=t&&t.length>0?t:e.canvases&&Object.keys(e.canvases).length>0?Object.keys(e.canvases):[...d.VALID_NODES],r={activeSnapshotId:e.id,publishedAt:e.createdAt,nodeIds:n,schemaVersion:e.schemaVersion||1};return d.PublicPortalManifestPayloadSchema.parse(r),r}async function R(e,t){const n=(t==null?void 0:t.accountId)||c("CLOUDFLARE_ACCOUNT_ID")||c("CF_ACCOUNT_ID"),r=(t==null?void 0:t.namespaceId)||c("CLOUDFLARE_KV_NAMESPACE_ID")||c("CF_KV_NAMESPACE_ID")||c("KV_ENGINE_PUBLIC_ID")||c("KV_PUBLIC_ID"),s=(t==null?void 0:t.apiToken)||c("CLOUDFLARE_API_TOKEN")||c("CF_API_TOKEN");if(!n||!r||!s)return{success:!0,deployedCount:0,warning:`Cloudflare KV credentials (${[!n&&"account ID",!r&&"KV namespace ID",!s&&"API token"].filter(Boolean).join(", ")}) not configured. Skipped remote edge deployment (local fallback mode).`};const a=`https://api.cloudflare.com/client/v4/accounts/${n}/storage/kv/namespaces/${r}/bulk`;try{const i=await fetch(a,{method:"PUT",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok){const o=await i.text();return console.warn(`[edgePreBakeService] Cloudflare KV bulk API returned HTTP ${i.status}:`,o),{success:!1,deployedCount:0,error:`Cloudflare KV upload returned HTTP ${i.status}: ${o}`}}return{success:!0,deployedCount:e.length}}catch(i){const o=i instanceof Error?i.message:"Network error during Cloudflare KV bulk deployment";return console.warn("[edgePreBakeService] Cloudflare KV bulk dispatch failure:",o),{success:!1,deployedCount:0,error:o}}}async function M(e,t){const n=[],r=[],s=t!=null&&t.nodeIds&&t.nodeIds.length>0?t.nodeIds:e.canvases&&Object.keys(e.canvases).length>0?Object.keys(e.canvases):[...d.VALID_NODES];for(const o of s){const l=O(o,e,t),w=JSON.stringify(l);n.push({key:`node:${o}`,value:w}),r.push(o);for(const[U,N]of Object.entries(l.chartDatasets))n.push({key:`chart:${U}`,value:JSON.stringify(N)})}const a=_(e,s);n.push({key:"portal:manifest",value:JSON.stringify(a)});const i=await R(n,t==null?void 0:t.credentials);return{success:i.success,snapshotId:e.id,transformedNodes:r,totalKvKeys:n.length,deployResult:i}}exports.ALLOWED_EDGE_WIDTHS=u;exports.DEFAULT_PHOTO_ASPECT_RATIO=k;exports.DEFAULT_SIZES_ATTRIBUTE=b;exports.TRANSFORM_BREAKPOINTS=C;exports.bakedChartsData=I;exports.baselineSourcesRaw=v;exports.buildEdgeMediaUrl=T;exports.buildEdgeSrcSet=S;exports.compileAndDeployToEdgeKV=M;exports.compilePortalManifest=_;exports.compilePublicNodePayload=O;exports.deployPayloadsToCloudflareKV=R;exports.extractDriveFileId=m;exports.gatherIndicatorDatasets=D;exports.gatherSourceMetadata=P;exports.isChartElement=Q;exports.isGalleryElement=K;exports.isLeafElement=V;exports.isPhotoElement=y;exports.isSectionElement=L;exports.isSubsectionElement=p;exports.isTextElement=x;exports.normalizeEdgeWidth=A;exports.transformCanvasAst=h;
@@ -0,0 +1,512 @@
1
+ import { V as v, P as T, d as S } from "./edge-CSjifIhA.js";
2
+ function Q(e) {
3
+ return e.type === "section";
4
+ }
5
+ function h(e) {
6
+ return e.type === "subsection";
7
+ }
8
+ function K(e) {
9
+ return e.type === "text" || e.type === "photo" || e.type === "gallery" || e.type === "chart";
10
+ }
11
+ function $(e) {
12
+ return e.type === "text";
13
+ }
14
+ function y(e) {
15
+ return e.type === "photo";
16
+ }
17
+ function z(e) {
18
+ return e.type === "gallery";
19
+ }
20
+ function W(e) {
21
+ return e.type === "chart";
22
+ }
23
+ const u = [320, 400, 600, 800, 1200, 1600], f = 800, l = /^[a-zA-Z0-9_-]{10,64}$/;
24
+ function I(e) {
25
+ if (typeof e != "number" || isNaN(e) || e <= 0)
26
+ return f;
27
+ if (e <= u[0])
28
+ return u[0];
29
+ if (e >= u[u.length - 1])
30
+ return u[u.length - 1];
31
+ let t = f, n = 1 / 0;
32
+ for (const r of u) {
33
+ const s = Math.abs(r - e);
34
+ s <= n && (n = s, t = r);
35
+ }
36
+ return t;
37
+ }
38
+ function m(e) {
39
+ if (!e || typeof e != "string") return null;
40
+ const t = e.trim();
41
+ if (l.test(t))
42
+ return t;
43
+ const n = t.match(/[?&]id=([a-zA-Z0-9_-]{10,64})/);
44
+ if (n != null && n[1] && l.test(n[1]))
45
+ return n[1];
46
+ const r = t.match(/\/(?:d|folders)\/([a-zA-Z0-9_-]{10,64})/);
47
+ return r != null && r[1] && l.test(r[1]) ? r[1] : null;
48
+ }
49
+ function A(e, t = {}) {
50
+ const n = m(e);
51
+ if (!n) return e || "";
52
+ const r = I(t.width ?? f), s = `/api/media/drive/${n}?w=${r}`;
53
+ return t.format && t.format !== "auto" ? `${s}&fmt=${t.format}` : s;
54
+ }
55
+ function E(e, t = [400, 800, 1200, 1600]) {
56
+ const n = m(e);
57
+ return n ? t.map((r) => {
58
+ const s = I(r);
59
+ return `${A(n, { width: s })} ${s}w`;
60
+ }).join(", ") : "";
61
+ }
62
+ const g = [
63
+ {
64
+ chartId: "chart-access-enrolment",
65
+ title: "Operational Activity Volume",
66
+ subtitle: "Monthly processed transaction volume across regional units (units)",
67
+ unit: "units",
68
+ asOfDate: "2026-Q1",
69
+ chartType: "bar",
70
+ nodeId: "access",
71
+ visualConfig: {
72
+ unit: "units",
73
+ excludeSummaryRows: !0,
74
+ yMin: 0,
75
+ orientation: "vertical",
76
+ barOrientation: "vertical"
77
+ },
78
+ categories: [
79
+ "Unit 1",
80
+ "Unit 2",
81
+ "Unit 3",
82
+ "Unit 4",
83
+ "Unit 5",
84
+ "Unit 6"
85
+ ],
86
+ series: [
87
+ {
88
+ name: "Completed Tasks",
89
+ data: [
90
+ 420,
91
+ 510,
92
+ 630,
93
+ 590,
94
+ 710,
95
+ 680
96
+ ],
97
+ color: "#0284c7"
98
+ },
99
+ {
100
+ name: "Pending Tasks",
101
+ data: [
102
+ 390,
103
+ 480,
104
+ 580,
105
+ 560,
106
+ 670,
107
+ 640
108
+ ],
109
+ color: "#38bdf8"
110
+ }
111
+ ],
112
+ sanitizedCsvContent: `# Title: Operational Activity Volume (units)
113
+ Category,Completed Tasks,Pending Tasks
114
+ Unit 1,420,390
115
+ Unit 2,510,480
116
+ Unit 3,630,580
117
+ Unit 4,590,560
118
+ Unit 5,710,670
119
+ Unit 6,680,640`
120
+ },
121
+ {
122
+ chartId: "chart-equity-assistance",
123
+ title: "Resource Allocation by Department",
124
+ subtitle: "Percentage distribution of standard operational expenditure",
125
+ unit: "%",
126
+ asOfDate: "2026-Q1",
127
+ chartType: "donut",
128
+ nodeId: "equity",
129
+ visualConfig: {
130
+ unit: "%",
131
+ excludeSummaryRows: !0,
132
+ donutVariant: "donut"
133
+ },
134
+ categories: [
135
+ "Operations",
136
+ "Logistics",
137
+ "Administration",
138
+ "Planning",
139
+ "Support"
140
+ ],
141
+ series: [
142
+ {
143
+ name: "Allocation",
144
+ data: [
145
+ 32,
146
+ 26,
147
+ 20,
148
+ 14,
149
+ 8
150
+ ],
151
+ color: "#881337"
152
+ }
153
+ ],
154
+ sanitizedCsvContent: `# Title: Resource Allocation by Department (%)
155
+ Category,Allocation
156
+ Operations,32
157
+ Logistics,26
158
+ Administration,20
159
+ Planning,14
160
+ Support,8`
161
+ },
162
+ {
163
+ chartId: "chart-quality-mps",
164
+ title: "Quarterly Performance Index",
165
+ subtitle: "Standard performance indicators recorded over consecutive quarters",
166
+ unit: "pts",
167
+ asOfDate: "2026-Q1",
168
+ chartType: "line",
169
+ nodeId: "quality",
170
+ visualConfig: {
171
+ unit: "pts",
172
+ excludeSummaryRows: !0,
173
+ yMin: 0,
174
+ curveInterpolation: "smooth",
175
+ showAreaFill: !0
176
+ },
177
+ categories: [
178
+ "Q1",
179
+ "Q2",
180
+ "Q3",
181
+ "Q4",
182
+ "Q5"
183
+ ],
184
+ series: [
185
+ {
186
+ name: "Primary Indicator",
187
+ data: [
188
+ 48,
189
+ 41,
190
+ 33,
191
+ 26,
192
+ 19
193
+ ],
194
+ color: "#f59e0b"
195
+ },
196
+ {
197
+ name: "Secondary Indicator",
198
+ data: [
199
+ 82,
200
+ 69,
201
+ 54,
202
+ 42,
203
+ 31
204
+ ],
205
+ color: "#b45309"
206
+ }
207
+ ],
208
+ sanitizedCsvContent: `# Title: Quarterly Performance Index (pts)
209
+ Quarter,Primary Indicator,Secondary Indicator
210
+ Q1,48,82
211
+ Q2,41,69
212
+ Q3,33,54
213
+ Q4,26,42
214
+ Q5,19,31`
215
+ },
216
+ {
217
+ chartId: "chart-resiliency-drrm",
218
+ title: "Response Time Distribution",
219
+ subtitle: "Distribution of response completion times across standard requests",
220
+ unit: "ms",
221
+ asOfDate: "2026-Q1",
222
+ chartType: "bar",
223
+ nodeId: "resiliency",
224
+ visualConfig: {
225
+ unit: "ms",
226
+ excludeSummaryRows: !0,
227
+ yMin: 0
228
+ },
229
+ categories: [
230
+ "0-10ms",
231
+ "10-20ms",
232
+ "20-30ms",
233
+ "30-40ms",
234
+ "40-50ms",
235
+ ">50ms"
236
+ ],
237
+ series: [
238
+ {
239
+ name: "Recorded Responses",
240
+ data: [
241
+ 142,
242
+ 89,
243
+ 45,
244
+ 12,
245
+ 4,
246
+ 1
247
+ ],
248
+ color: "#15803d"
249
+ }
250
+ ],
251
+ sanitizedCsvContent: `# Title: Response Time Distribution (ms)
252
+ Bucket,Recorded Responses
253
+ 0-10ms,142
254
+ 10-20ms,89
255
+ 20-30ms,45
256
+ 30-40ms,12
257
+ 40-50ms,4
258
+ >50ms,1`
259
+ },
260
+ {
261
+ chartId: "chart-governance-mooe",
262
+ title: "Scheduled Tasks & Administrative Reviews",
263
+ subtitle: "Weekly completed reviews and administrative filings",
264
+ unit: "tasks",
265
+ asOfDate: "2026-Q1",
266
+ chartType: "bar",
267
+ nodeId: "governance",
268
+ visualConfig: {
269
+ unit: "tasks",
270
+ excludeSummaryRows: !0,
271
+ yMin: 0
272
+ },
273
+ categories: [
274
+ "Week 1",
275
+ "Week 2",
276
+ "Week 3",
277
+ "Week 4",
278
+ "Week 5",
279
+ "Week 6"
280
+ ],
281
+ series: [
282
+ {
283
+ name: "Scheduled Tasks",
284
+ data: [
285
+ 120,
286
+ 145,
287
+ 160,
288
+ 185,
289
+ 210,
290
+ 230
291
+ ],
292
+ color: "#d97706"
293
+ },
294
+ {
295
+ name: "Completed Reviews",
296
+ data: [
297
+ 18,
298
+ 22,
299
+ 28,
300
+ 31,
301
+ 35,
302
+ 42
303
+ ],
304
+ color: "#b45309"
305
+ }
306
+ ],
307
+ sanitizedCsvContent: `# Title: Scheduled Tasks & Administrative Reviews (tasks)
308
+ Week,Scheduled Tasks,Completed Reviews
309
+ Week 1,120,18
310
+ Week 2,145,22
311
+ Week 3,160,28
312
+ Week 4,185,31
313
+ Week 5,210,35
314
+ Week 6,230,42`
315
+ }
316
+ ], D = {}, P = [400, 800, 1600], O = "(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 800px", _ = "16/9";
317
+ function c(e) {
318
+ if (typeof process < "u" && (process != null && process.env))
319
+ return process.env[e];
320
+ }
321
+ function w(e) {
322
+ if (!e || !Array.isArray(e.sections))
323
+ return e;
324
+ const t = JSON.parse(JSON.stringify(e));
325
+ return t.sections = t.sections.map((n) => {
326
+ if (!n || !Array.isArray(n.elements)) return n;
327
+ const r = n.elements.map((s) => {
328
+ if (h(s)) {
329
+ const a = s;
330
+ if (Array.isArray(a.elements)) {
331
+ const i = a.elements.map((o) => y(o) ? p(o) : o);
332
+ return {
333
+ ...a,
334
+ elements: i
335
+ };
336
+ }
337
+ return a;
338
+ }
339
+ return y(s) ? p(s) : s;
340
+ });
341
+ return {
342
+ ...n,
343
+ elements: r
344
+ };
345
+ }), t;
346
+ }
347
+ function p(e) {
348
+ if (!e.src || typeof e.src != "string")
349
+ return e;
350
+ const t = e.src.trim(), n = m(t);
351
+ if (!n)
352
+ return e;
353
+ const r = A(n, { width: 800 }), s = E(n, P), a = e.sizes || O, i = e.aspectRatio || _;
354
+ return {
355
+ ...e,
356
+ src: r,
357
+ srcSet: s,
358
+ sizes: a,
359
+ aspectRatio: i,
360
+ rawDriveUrl: e.rawDriveUrl || t
361
+ };
362
+ }
363
+ function R(e, t) {
364
+ const n = {};
365
+ if (Array.isArray(g))
366
+ for (const r of g)
367
+ r && r.chartId && (!r.nodeId || r.nodeId.toLowerCase() === e.toLowerCase()) && (n[r.chartId] = r);
368
+ if (t)
369
+ for (const [r, s] of Object.entries(t))
370
+ n[r] = s;
371
+ return n;
372
+ }
373
+ function U(e, t) {
374
+ const n = {}, r = D;
375
+ if (r && typeof r == "object")
376
+ for (const [s, a] of Object.entries(r))
377
+ s.toLowerCase().includes(e.toLowerCase()) && (n[s] = {
378
+ pointId: s,
379
+ folderUrl: a.folderUrl,
380
+ folderTitle: a.folderTitle,
381
+ description: a.description,
382
+ lastSyncedAt: a.lastVerified
383
+ });
384
+ if (t)
385
+ for (const [s, a] of Object.entries(t))
386
+ n[s] = a;
387
+ return n;
388
+ }
389
+ function N(e, t, n) {
390
+ var d;
391
+ const r = ((d = t.canvases) == null ? void 0 : d[e]) || {
392
+ nodeId: e,
393
+ version: t.schemaVersion || 1,
394
+ sections: [],
395
+ updatedAt: t.createdAt
396
+ }, s = w(r), a = R(e, n == null ? void 0 : n.chartDatasets), i = U(e, n == null ? void 0 : n.sourceMetadata), o = {
397
+ nodeId: e,
398
+ snapshotId: t.id,
399
+ version: t.schemaVersion || 1,
400
+ updatedAt: t.createdAt,
401
+ canvas: s,
402
+ chartDatasets: a,
403
+ sourceMetadata: i
404
+ };
405
+ return T.parse(o), o;
406
+ }
407
+ function V(e, t) {
408
+ const n = t && t.length > 0 ? t : e.canvases && Object.keys(e.canvases).length > 0 ? Object.keys(e.canvases) : [...v], r = {
409
+ activeSnapshotId: e.id,
410
+ publishedAt: e.createdAt,
411
+ nodeIds: n,
412
+ schemaVersion: e.schemaVersion || 1
413
+ };
414
+ return S.parse(r), r;
415
+ }
416
+ async function L(e, t) {
417
+ const n = (t == null ? void 0 : t.accountId) || c("CLOUDFLARE_ACCOUNT_ID") || c("CF_ACCOUNT_ID"), r = (t == null ? void 0 : t.namespaceId) || c("CLOUDFLARE_KV_NAMESPACE_ID") || c("CF_KV_NAMESPACE_ID") || c("KV_ENGINE_PUBLIC_ID") || c("KV_PUBLIC_ID"), s = (t == null ? void 0 : t.apiToken) || c("CLOUDFLARE_API_TOKEN") || c("CF_API_TOKEN");
418
+ if (!n || !r || !s)
419
+ return {
420
+ success: !0,
421
+ deployedCount: 0,
422
+ warning: `Cloudflare KV credentials (${[
423
+ !n && "account ID",
424
+ !r && "KV namespace ID",
425
+ !s && "API token"
426
+ ].filter(Boolean).join(", ")}) not configured. Skipped remote edge deployment (local fallback mode).`
427
+ };
428
+ const a = `https://api.cloudflare.com/client/v4/accounts/${n}/storage/kv/namespaces/${r}/bulk`;
429
+ try {
430
+ const i = await fetch(a, {
431
+ method: "PUT",
432
+ headers: {
433
+ Authorization: `Bearer ${s}`,
434
+ "Content-Type": "application/json"
435
+ },
436
+ body: JSON.stringify(e)
437
+ });
438
+ if (!i.ok) {
439
+ const o = await i.text();
440
+ return console.warn(`[edgePreBakeService] Cloudflare KV bulk API returned HTTP ${i.status}:`, o), {
441
+ success: !1,
442
+ deployedCount: 0,
443
+ error: `Cloudflare KV upload returned HTTP ${i.status}: ${o}`
444
+ };
445
+ }
446
+ return {
447
+ success: !0,
448
+ deployedCount: e.length
449
+ };
450
+ } catch (i) {
451
+ const o = i instanceof Error ? i.message : "Network error during Cloudflare KV bulk deployment";
452
+ return console.warn("[edgePreBakeService] Cloudflare KV bulk dispatch failure:", o), {
453
+ success: !1,
454
+ deployedCount: 0,
455
+ error: o
456
+ };
457
+ }
458
+ }
459
+ async function j(e, t) {
460
+ const n = [], r = [], s = t != null && t.nodeIds && t.nodeIds.length > 0 ? t.nodeIds : e.canvases && Object.keys(e.canvases).length > 0 ? Object.keys(e.canvases) : [...v];
461
+ for (const o of s) {
462
+ const d = N(o, e, t), C = JSON.stringify(d);
463
+ n.push({
464
+ key: `node:${o}`,
465
+ value: C
466
+ }), r.push(o);
467
+ for (const [k, b] of Object.entries(d.chartDatasets))
468
+ n.push({
469
+ key: `chart:${k}`,
470
+ value: JSON.stringify(b)
471
+ });
472
+ }
473
+ const a = V(e, s);
474
+ n.push({
475
+ key: "portal:manifest",
476
+ value: JSON.stringify(a)
477
+ });
478
+ const i = await L(n, t == null ? void 0 : t.credentials);
479
+ return {
480
+ success: i.success,
481
+ snapshotId: e.id,
482
+ transformedNodes: r,
483
+ totalKvKeys: n.length,
484
+ deployResult: i
485
+ };
486
+ }
487
+ export {
488
+ u as A,
489
+ _ as D,
490
+ P as T,
491
+ A as a,
492
+ g as b,
493
+ j as c,
494
+ D as d,
495
+ m as e,
496
+ E as f,
497
+ z as g,
498
+ K as h,
499
+ W as i,
500
+ y as j,
501
+ Q as k,
502
+ h as l,
503
+ $ as m,
504
+ O as n,
505
+ V as o,
506
+ N as p,
507
+ L as q,
508
+ R as r,
509
+ U as s,
510
+ I as t,
511
+ w as u
512
+ };
package/dist/edge.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./edge-1WCVZ0J7.cjs"),e=require("./edge-Dr41JdrQ.cjs");exports.CachedIndicatorDatasetSchema=a.CachedIndicatorDatasetSchema;exports.NodeCanvasDocumentSchema=a.NodeCanvasDocumentSchema;exports.PublicNodePayloadSchema=a.PublicNodePayloadSchema;exports.PublicPortalManifestPayloadSchema=a.PublicPortalManifestPayloadSchema;exports.SyncedSourceMetadataSchema=a.SyncedSourceMetadataSchema;exports.VALID_NODES=a.VALID_NODES;exports.computeWeakEtag=a.computeWeakEtag;exports.ALLOWED_EDGE_WIDTHS=e.ALLOWED_EDGE_WIDTHS;exports.DEFAULT_PHOTO_ASPECT_RATIO=e.DEFAULT_PHOTO_ASPECT_RATIO;exports.DEFAULT_SIZES_ATTRIBUTE=e.DEFAULT_SIZES_ATTRIBUTE;exports.TRANSFORM_BREAKPOINTS=e.TRANSFORM_BREAKPOINTS;exports.buildEdgeMediaUrl=e.buildEdgeMediaUrl;exports.buildEdgeSrcSet=e.buildEdgeSrcSet;exports.compileAndDeployToEdgeKV=e.compileAndDeployToEdgeKV;exports.compilePortalManifest=e.compilePortalManifest;exports.compilePublicNodePayload=e.compilePublicNodePayload;exports.deployPayloadsToCloudflareKV=e.deployPayloadsToCloudflareKV;exports.extractDriveFileId=e.extractDriveFileId;exports.gatherIndicatorDatasets=e.gatherIndicatorDatasets;exports.gatherSourceMetadata=e.gatherSourceMetadata;exports.normalizeEdgeWidth=e.normalizeEdgeWidth;exports.transformCanvasAst=e.transformCanvasAst;
package/dist/edge.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Folio Engine — Edge & Cloudflare Worker Entry Point
3
+ * Location: src/edge.ts
4
+ *
5
+ * Dedicated zero-DOM, zero-React entry point for Cloudflare Pages Functions,
6
+ * Workers, and Node.js prebake scripts.
7
+ */
8
+ export * from './types/edge';
9
+ export * from './services/edgePreBakeService';
10
+ export * from './utils/mediaUrl';
package/dist/edge.js ADDED
@@ -0,0 +1,26 @@
1
+ import { C as s, N as o, P as t, d, S as c, V as l, e as r } from "./edge-CSjifIhA.js";
2
+ import { A as i, D as E, n as m, T, a as D, f as P, c as n, o as A, p as u, q as h, e as p, r as I, s as _, t as f, u as g } from "./edge-h_ge9f1E.js";
3
+ export {
4
+ i as ALLOWED_EDGE_WIDTHS,
5
+ s as CachedIndicatorDatasetSchema,
6
+ E as DEFAULT_PHOTO_ASPECT_RATIO,
7
+ m as DEFAULT_SIZES_ATTRIBUTE,
8
+ o as NodeCanvasDocumentSchema,
9
+ t as PublicNodePayloadSchema,
10
+ d as PublicPortalManifestPayloadSchema,
11
+ c as SyncedSourceMetadataSchema,
12
+ T as TRANSFORM_BREAKPOINTS,
13
+ l as VALID_NODES,
14
+ D as buildEdgeMediaUrl,
15
+ P as buildEdgeSrcSet,
16
+ n as compileAndDeployToEdgeKV,
17
+ A as compilePortalManifest,
18
+ u as compilePublicNodePayload,
19
+ r as computeWeakEtag,
20
+ h as deployPayloadsToCloudflareKV,
21
+ p as extractDriveFileId,
22
+ I as gatherIndicatorDatasets,
23
+ _ as gatherSourceMetadata,
24
+ f as normalizeEdgeWidth,
25
+ g as transformCanvasAst
26
+ };