@walkeros/server-transformer-file 3.4.2 → 4.0.0-next-1777463920154
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/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +4 -10
- package/package.json +4 -4
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i=(e,r)=>{for(var a in r)t(e,a,{get:r[a],enumerable:!0})},s={};i(s,{examples:()=>v,schemas:()=>n}),module.exports=(e=s,((e,i,s,n)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let p of a(i))o.call(e,p)||p===s||t(e,p,{get:()=>i[p],enumerable:!(n=r(i,p))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};i(n,{SettingsSchema:()=>l,settings:()=>d});var p=require("@walkeros/core/dev"),c=require("@walkeros/core/dev"),l=c.z.object({prefix:c.z.string().optional().describe('URL prefix to strip before store lookup. E.g., "/static" → /static/walker.js looks up "walker.js"'),headers:c.z.record(c.z.string(),c.z.string()).optional().describe("Default response headers (e.g., Cache-Control, X-Frame-Options)"),mimeTypes:c.z.record(c.z.string(),c.z.string()).optional().describe('Extension → Content-Type overrides. Keys include dot: { ".wasm": "application/wasm" }')}).describe("File transformer: serves static files via pluggable Store backend"),d=(0,p.zodToSchema)(l),v={};i(v,{env:()=>g,step:()=>m});var m={};i(m,{serveStaticFile:()=>u});var u={title:"Serve static file",description:'Serve a static JavaScript file from store. Config: prefix: "/static", headers: { "Cache-Control": "public, max-age=3600" }',in:{name:"page view",data:{path:"/static/walker.js"},id:"ev-1700000600",trigger:"load",entity:"page",action:"view",timestamp:1700000600,source:{type:"express",platform:"server"}},out:[["respond",{status:200,headers:{"Content-Type":"application/javascript","Cache-Control":"public, max-age=3600"}}]]},g={};i(g,{init:()=>f,push:()=>b,simulation:()=>h});var f=void 0,b={store:void 0,respond:void 0},h=["call:respond"];//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/env.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * File transformer settings schema.\n *\n * Mirrors: types.ts FileSettings\n */\nexport const SettingsSchema = z\n .object({\n prefix: z\n .string()\n .optional()\n .describe(\n 'URL prefix to strip before store lookup. E.g., \"/static\" → /static/walker.js looks up \"walker.js\"',\n ),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Default response headers (e.g., Cache-Control, X-Frame-Options)',\n ),\n mimeTypes: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Extension → Content-Type overrides. Keys include dot: { \".wasm\": \"application/wasm\" }',\n ),\n })\n .describe(\n 'File transformer: serves static files via pluggable Store backend',\n );\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as step from './step';\nexport * as env from './env';\n","import type { Flow } from '@walkeros/core';\n\nexport const serveStaticFile: Flow.StepExample = {\n title: 'Serve static file',\n description:\n 'Serve a static JavaScript file from store. ' +\n 'Config: prefix: \"/static\", headers: { \"Cache-Control\": \"public, max-age=3600\" }',\n in: {\n name: 'page view',\n data: { path: '/static/walker.js' },\n id: '1700000600
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/env.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * File transformer settings schema.\n *\n * Mirrors: types.ts FileSettings\n */\nexport const SettingsSchema = z\n .object({\n prefix: z\n .string()\n .optional()\n .describe(\n 'URL prefix to strip before store lookup. E.g., \"/static\" → /static/walker.js looks up \"walker.js\"',\n ),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Default response headers (e.g., Cache-Control, X-Frame-Options)',\n ),\n mimeTypes: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Extension → Content-Type overrides. Keys include dot: { \".wasm\": \"application/wasm\" }',\n ),\n })\n .describe(\n 'File transformer: serves static files via pluggable Store backend',\n );\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as step from './step';\nexport * as env from './env';\n","import type { Flow } from '@walkeros/core';\n\nexport const serveStaticFile: Flow.StepExample = {\n title: 'Serve static file',\n description:\n 'Serve a static JavaScript file from store. ' +\n 'Config: prefix: \"/static\", headers: { \"Cache-Control\": \"public, max-age=3600\" }',\n in: {\n name: 'page view',\n data: { path: '/static/walker.js' },\n id: 'ev-1700000600',\n trigger: 'load',\n entity: 'page',\n action: 'view',\n timestamp: 1700000600,\n source: { type: 'express', platform: 'server' },\n },\n out: [\n [\n 'respond',\n {\n status: 200,\n headers: {\n 'Content-Type': 'application/javascript',\n 'Cache-Control': 'public, max-age=3600',\n },\n },\n ],\n ],\n};\n","import type { FileEnv } from '../types';\n\nexport const init: FileEnv | undefined = undefined;\n\nexport const push: FileEnv = {\n store: undefined,\n respond: undefined,\n};\n\nexport const simulation = ['call:respond'];\n"],"mappings":";;;;;;;;;;;;;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,r=(r,t)=>{for(var
|
|
1
|
+
var e=Object.defineProperty,r=(r,t)=>{for(var a in t)e(r,a,{get:t[a],enumerable:!0})},t={};r(t,{SettingsSchema:()=>s,settings:()=>o});import{zodToSchema as a}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";var s=i.object({prefix:i.string().optional().describe('URL prefix to strip before store lookup. E.g., "/static" → /static/walker.js looks up "walker.js"'),headers:i.record(i.string(),i.string()).optional().describe("Default response headers (e.g., Cache-Control, X-Frame-Options)"),mimeTypes:i.record(i.string(),i.string()).optional().describe('Extension → Content-Type overrides. Keys include dot: { ".wasm": "application/wasm" }')}).describe("File transformer: serves static files via pluggable Store backend"),o=a(s),n={};r(n,{env:()=>l,step:()=>p});var p={};r(p,{serveStaticFile:()=>c});var c={title:"Serve static file",description:'Serve a static JavaScript file from store. Config: prefix: "/static", headers: { "Cache-Control": "public, max-age=3600" }',in:{name:"page view",data:{path:"/static/walker.js"},id:"ev-1700000600",trigger:"load",entity:"page",action:"view",timestamp:1700000600,source:{type:"express",platform:"server"}},out:[["respond",{status:200,headers:{"Content-Type":"application/javascript","Cache-Control":"public, max-age=3600"}}]]},l={};r(l,{init:()=>d,push:()=>v,simulation:()=>m});var d=void 0,v={store:void 0,respond:void 0},m=["call:respond"];export{n as examples,t as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/env.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * File transformer settings schema.\n *\n * Mirrors: types.ts FileSettings\n */\nexport const SettingsSchema = z\n .object({\n prefix: z\n .string()\n .optional()\n .describe(\n 'URL prefix to strip before store lookup. E.g., \"/static\" → /static/walker.js looks up \"walker.js\"',\n ),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Default response headers (e.g., Cache-Control, X-Frame-Options)',\n ),\n mimeTypes: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Extension → Content-Type overrides. Keys include dot: { \".wasm\": \"application/wasm\" }',\n ),\n })\n .describe(\n 'File transformer: serves static files via pluggable Store backend',\n );\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as step from './step';\nexport * as env from './env';\n","import type { Flow } from '@walkeros/core';\n\nexport const serveStaticFile: Flow.StepExample = {\n title: 'Serve static file',\n description:\n 'Serve a static JavaScript file from store. ' +\n 'Config: prefix: \"/static\", headers: { \"Cache-Control\": \"public, max-age=3600\" }',\n in: {\n name: 'page view',\n data: { path: '/static/walker.js' },\n id: '1700000600
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/env.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * File transformer settings schema.\n *\n * Mirrors: types.ts FileSettings\n */\nexport const SettingsSchema = z\n .object({\n prefix: z\n .string()\n .optional()\n .describe(\n 'URL prefix to strip before store lookup. E.g., \"/static\" → /static/walker.js looks up \"walker.js\"',\n ),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Default response headers (e.g., Cache-Control, X-Frame-Options)',\n ),\n mimeTypes: z\n .record(z.string(), z.string())\n .optional()\n .describe(\n 'Extension → Content-Type overrides. Keys include dot: { \".wasm\": \"application/wasm\" }',\n ),\n })\n .describe(\n 'File transformer: serves static files via pluggable Store backend',\n );\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as step from './step';\nexport * as env from './env';\n","import type { Flow } from '@walkeros/core';\n\nexport const serveStaticFile: Flow.StepExample = {\n title: 'Serve static file',\n description:\n 'Serve a static JavaScript file from store. ' +\n 'Config: prefix: \"/static\", headers: { \"Cache-Control\": \"public, max-age=3600\" }',\n in: {\n name: 'page view',\n data: { path: '/static/walker.js' },\n id: 'ev-1700000600',\n trigger: 'load',\n entity: 'page',\n action: 'view',\n timestamp: 1700000600,\n source: { type: 'express', platform: 'server' },\n },\n out: [\n [\n 'respond',\n {\n status: 200,\n headers: {\n 'Content-Type': 'application/javascript',\n 'Cache-Control': 'public, max-age=3600',\n },\n },\n ],\n ],\n};\n","import type { FileEnv } from '../types';\n\nexport const init: FileEnv | undefined = undefined;\n\nexport const push: FileEnv = {\n store: undefined,\n respond: undefined,\n};\n\nexport const simulation = ['call:respond'];\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAOX,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,QAAQ,EACL,OAAO,EACP,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,EACN,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,EACR,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC,EACA;AAAA,EACC;AACF;;;AD1BK,IAAM,WAAW,YAAY,cAAc;;;AEJlD;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAEO,IAAM,kBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EAEF,IAAI;AAAA,IACF,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,oBAAoB;AAAA,IAClC,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,QAAQ,EAAE,MAAM,WAAW,UAAU,SAAS;AAAA,EAChD;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,iBAAiB;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;AC7BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,OAA4B;AAElC,IAAM,OAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,SAAS;AACX;AAEO,IAAM,aAAa,CAAC,cAAc;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(o,{default:()=>p,getMimeType:()=>s,transformerFile:()=>p}),module.exports=(e=o,((e,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let p of r(o))i.call(e,p)||p===a||t(e,p,{get:()=>o[p],enumerable:!(s=n(o,p))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".html":"text/html",".htm":"text/html",".json":"application/json",".wasm":"application/wasm",".map":"application/json",".txt":"text/plain",".xml":"application/xml",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".ico":"image/x-icon",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};function s(e,t){const n=e.lastIndexOf(".");if(-1===n)return"application/octet-stream";const r=e.slice(n).toLowerCase();return t?.[r]||a[r]||"application/octet-stream"}var p=e=>{const{config:t}=e,n=t.settings||{},r=n.prefix,i=n.headers,o=n.mimeTypes,a=e.env.store;return{type:"file",config:t,async push(e,t){const{logger:n}=t,p=t.ingest||{},f=t.env.respond,c=p.path;if(!c)return;if(!a)return void n.warn("No store provided to file transformer");let l=c;if(r){if(!l.startsWith(r))return;l=l.slice(r.length)}if(l.startsWith("/")&&(l=l.slice(1)),!l)return;const g=await a.get(l);if(null==g)return;const m=s(l,o),u=g instanceof Buffer?g.length:"string"==typeof g?Buffer.byteLength(g):void 0,j={"Content-Type":m,...i};return void 0!==u&&(j["Content-Length"]=String(u)),f?.({body:g,status:200,headers:j}),!1}}};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/mime.ts","../src/transformer.ts"],"sourcesContent":["export { transformerFile } from './transformer';\nexport { getMimeType } from './mime';\nexport type { FileSettings, FileEnv, Types } from './types';\nexport { transformerFile as default } from './transformer';\n","const DEFAULT_MIME_TYPES: Record<string, string> = {\n '.js': 'application/javascript',\n '.mjs': 'application/javascript',\n '.css': 'text/css',\n '.html': 'text/html',\n '.htm': 'text/html',\n '.json': 'application/json',\n '.wasm': 'application/wasm',\n '.map': 'application/json',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.ico': 'image/x-icon',\n '.webp': 'image/webp',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n};\n\nexport function getMimeType(\n filePath: string,\n overrides?: Record<string, string>,\n): string {\n const lastDot = filePath.lastIndexOf('.');\n if (lastDot === -1) return 'application/octet-stream';\n const ext = filePath.slice(lastDot).toLowerCase();\n return (\n overrides?.[ext] || DEFAULT_MIME_TYPES[ext] || 'application/octet-stream'\n );\n}\n","import type { Transformer } from '@walkeros/core';\nimport type { RespondFn } from '@walkeros/core';\nimport { getMimeType } from './mime';\nimport type { FileSettings, FileEnv, Types } from './types';\n\nexport const transformerFile: Transformer.Init<Types> = (context) => {\n const { config } = context;\n const settings = (config.settings || {}) as Partial<FileSettings>;\n const prefix = settings.prefix;\n const defaultHeaders = settings.headers;\n const mimeOverrides = settings.mimeTypes;\n\n const store = (context.env as FileEnv).store;\n\n return {\n type: 'file',\n config: config as Transformer.Config<Types>,\n\n async push(event, context) {\n const { logger } = context;\n const ingest = (context.ingest || {}) as Record<string, unknown>;\n const envRespond = context.env.respond as RespondFn | undefined;\n\n const rawPath = ingest.path as string | undefined;\n if (!rawPath) return;\n\n if (!store) {\n logger.warn('No store provided to file transformer');\n return;\n }\n\n // Apply prefix stripping\n let filePath = rawPath;\n if (prefix) {\n if (!filePath.startsWith(prefix)) return; // Not our path\n filePath = filePath.slice(prefix.length);\n }\n\n // Strip leading slash for store key\n if (filePath.startsWith('/')) filePath = filePath.slice(1);\n if (!filePath) return;\n\n // Fetch from store\n const content = await store.get(filePath);\n if (content == null) return;\n\n // Derive Content-Type\n const contentType = getMimeType(filePath, mimeOverrides);\n const contentLength =\n content instanceof Buffer\n ? content.length\n : typeof content === 'string'\n ? Buffer.byteLength(content)\n : undefined;\n\n const headers: Record<string, string> = {\n 'Content-Type': contentType,\n ...defaultHeaders,\n };\n if (contentLength !== undefined) {\n headers['Content-Length'] = String(contentLength);\n }\n\n envRespond?.({\n body: content,\n status: 200,\n headers,\n });\n\n return false;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,qBAA6C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AACZ;AAEO,SAAS,YACd,UACA,WACQ;AACR,QAAM,UAAU,SAAS,YAAY,GAAG;AACxC,MAAI,YAAY,GAAI,QAAO;AAC3B,QAAM,MAAM,SAAS,MAAM,OAAO,EAAE,YAAY;AAChD,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/mime.ts","../src/transformer.ts"],"sourcesContent":["export { transformerFile } from './transformer';\nexport { getMimeType } from './mime';\nexport type { FileSettings, FileEnv, Types } from './types';\nexport { transformerFile as default } from './transformer';\n","const DEFAULT_MIME_TYPES: Record<string, string> = {\n '.js': 'application/javascript',\n '.mjs': 'application/javascript',\n '.css': 'text/css',\n '.html': 'text/html',\n '.htm': 'text/html',\n '.json': 'application/json',\n '.wasm': 'application/wasm',\n '.map': 'application/json',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.ico': 'image/x-icon',\n '.webp': 'image/webp',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n};\n\nexport function getMimeType(\n filePath: string,\n overrides?: Record<string, string>,\n): string {\n const lastDot = filePath.lastIndexOf('.');\n if (lastDot === -1) return 'application/octet-stream';\n const ext = filePath.slice(lastDot).toLowerCase();\n return (\n overrides?.[ext] || DEFAULT_MIME_TYPES[ext] || 'application/octet-stream'\n );\n}\n","import type { Transformer } from '@walkeros/core';\nimport type { RespondFn } from '@walkeros/core';\nimport { getMimeType } from './mime';\nimport type { FileSettings, FileEnv, Types } from './types';\n\nexport const transformerFile: Transformer.Init<Types> = (context) => {\n const { config } = context;\n const settings = (config.settings || {}) as Partial<FileSettings>;\n const prefix = settings.prefix;\n const defaultHeaders = settings.headers;\n const mimeOverrides = settings.mimeTypes;\n\n const store = (context.env as FileEnv).store;\n\n return {\n type: 'file',\n config: config as Transformer.Config<Types>,\n\n async push(event, context) {\n const { logger } = context;\n const ingest = (context.ingest || {}) as Record<string, unknown>;\n const envRespond = context.env.respond as RespondFn | undefined;\n\n const rawPath = ingest.path as string | undefined;\n if (!rawPath) return;\n\n if (!store) {\n logger.warn('No store provided to file transformer');\n return;\n }\n\n // Apply prefix stripping\n let filePath = rawPath;\n if (prefix) {\n if (!filePath.startsWith(prefix)) return; // Not our path\n filePath = filePath.slice(prefix.length);\n }\n\n // Strip leading slash for store key\n if (filePath.startsWith('/')) filePath = filePath.slice(1);\n if (!filePath) return;\n\n // Fetch from store\n const content = await store.get(filePath);\n if (content == null) return;\n\n // Derive Content-Type\n const contentType = getMimeType(filePath, mimeOverrides);\n const contentLength =\n content instanceof Buffer\n ? content.length\n : typeof content === 'string'\n ? Buffer.byteLength(content)\n : undefined;\n\n const headers: Record<string, string> = {\n 'Content-Type': contentType,\n ...defaultHeaders,\n };\n if (contentLength !== undefined) {\n headers['Content-Length'] = String(contentLength);\n }\n\n envRespond?.({\n body: content,\n status: 200,\n headers,\n });\n\n return false;\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,qBAA6C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AACZ;AAEO,SAAS,YACd,UACA,WACQ;AACR,QAAM,UAAU,SAAS,YAAY,GAAG;AACxC,MAAI,YAAY,GAAI,QAAO;AAC3B,QAAM,MAAM,SAAS,MAAM,OAAO,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F;AACF;","names":["context"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".html":"text/html",".htm":"text/html",".json":"application/json",".wasm":"application/wasm",".map":"application/json",".txt":"text/plain",".xml":"application/xml",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".ico":"image/x-icon",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};function e(e,i){const n=e.lastIndexOf(".");if(-1===n)return"application/octet-stream";const a=e.slice(n).toLowerCase();return
|
|
1
|
+
var t={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".html":"text/html",".htm":"text/html",".json":"application/json",".wasm":"application/wasm",".map":"application/json",".txt":"text/plain",".xml":"application/xml",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".ico":"image/x-icon",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};function e(e,i){const n=e.lastIndexOf(".");if(-1===n)return"application/octet-stream";const a=e.slice(n).toLowerCase();return i?.[a]||t[a]||"application/octet-stream"}var i=t=>{const{config:i}=t,n=i.settings||{},a=n.prefix,o=n.headers,s=n.mimeTypes,r=t.env.store;return{type:"file",config:i,async push(t,i){const{logger:n}=i,p=i.ingest||{},f=i.env.respond,c=p.path;if(!c)return;if(!r)return void n.warn("No store provided to file transformer");let g=c;if(a){if(!g.startsWith(a))return;g=g.slice(a.length)}if(g.startsWith("/")&&(g=g.slice(1)),!g)return;const l=await r.get(g);if(null==l)return;const m=e(g,s),u=l instanceof Buffer?l.length:"string"==typeof l?Buffer.byteLength(l):void 0,h={"Content-Type":m,...o};return void 0!==u&&(h["Content-Length"]=String(u)),f?.({body:l,status:200,headers:h}),!1}}};export{i as default,e as getMimeType,i as transformerFile};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mime.ts","../src/transformer.ts"],"sourcesContent":["const DEFAULT_MIME_TYPES: Record<string, string> = {\n '.js': 'application/javascript',\n '.mjs': 'application/javascript',\n '.css': 'text/css',\n '.html': 'text/html',\n '.htm': 'text/html',\n '.json': 'application/json',\n '.wasm': 'application/wasm',\n '.map': 'application/json',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.ico': 'image/x-icon',\n '.webp': 'image/webp',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n};\n\nexport function getMimeType(\n filePath: string,\n overrides?: Record<string, string>,\n): string {\n const lastDot = filePath.lastIndexOf('.');\n if (lastDot === -1) return 'application/octet-stream';\n const ext = filePath.slice(lastDot).toLowerCase();\n return (\n overrides?.[ext] || DEFAULT_MIME_TYPES[ext] || 'application/octet-stream'\n );\n}\n","import type { Transformer } from '@walkeros/core';\nimport type { RespondFn } from '@walkeros/core';\nimport { getMimeType } from './mime';\nimport type { FileSettings, FileEnv, Types } from './types';\n\nexport const transformerFile: Transformer.Init<Types> = (context) => {\n const { config } = context;\n const settings = (config.settings || {}) as Partial<FileSettings>;\n const prefix = settings.prefix;\n const defaultHeaders = settings.headers;\n const mimeOverrides = settings.mimeTypes;\n\n const store = (context.env as FileEnv).store;\n\n return {\n type: 'file',\n config: config as Transformer.Config<Types>,\n\n async push(event, context) {\n const { logger } = context;\n const ingest = (context.ingest || {}) as Record<string, unknown>;\n const envRespond = context.env.respond as RespondFn | undefined;\n\n const rawPath = ingest.path as string | undefined;\n if (!rawPath) return;\n\n if (!store) {\n logger.warn('No store provided to file transformer');\n return;\n }\n\n // Apply prefix stripping\n let filePath = rawPath;\n if (prefix) {\n if (!filePath.startsWith(prefix)) return; // Not our path\n filePath = filePath.slice(prefix.length);\n }\n\n // Strip leading slash for store key\n if (filePath.startsWith('/')) filePath = filePath.slice(1);\n if (!filePath) return;\n\n // Fetch from store\n const content = await store.get(filePath);\n if (content == null) return;\n\n // Derive Content-Type\n const contentType = getMimeType(filePath, mimeOverrides);\n const contentLength =\n content instanceof Buffer\n ? content.length\n : typeof content === 'string'\n ? Buffer.byteLength(content)\n : undefined;\n\n const headers: Record<string, string> = {\n 'Content-Type': contentType,\n ...defaultHeaders,\n };\n if (contentLength !== undefined) {\n headers['Content-Length'] = String(contentLength);\n }\n\n envRespond?.({\n body: content,\n status: 200,\n headers,\n });\n\n return false;\n },\n };\n};\n"],"mappings":";AAAA,IAAM,qBAA6C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AACZ;AAEO,SAAS,YACd,UACA,WACQ;AACR,QAAM,UAAU,SAAS,YAAY,GAAG;AACxC,MAAI,YAAY,GAAI,QAAO;AAC3B,QAAM,MAAM,SAAS,MAAM,OAAO,EAAE,YAAY;AAChD,
|
|
1
|
+
{"version":3,"sources":["../src/mime.ts","../src/transformer.ts"],"sourcesContent":["const DEFAULT_MIME_TYPES: Record<string, string> = {\n '.js': 'application/javascript',\n '.mjs': 'application/javascript',\n '.css': 'text/css',\n '.html': 'text/html',\n '.htm': 'text/html',\n '.json': 'application/json',\n '.wasm': 'application/wasm',\n '.map': 'application/json',\n '.txt': 'text/plain',\n '.xml': 'application/xml',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.ico': 'image/x-icon',\n '.webp': 'image/webp',\n '.woff': 'font/woff',\n '.woff2': 'font/woff2',\n};\n\nexport function getMimeType(\n filePath: string,\n overrides?: Record<string, string>,\n): string {\n const lastDot = filePath.lastIndexOf('.');\n if (lastDot === -1) return 'application/octet-stream';\n const ext = filePath.slice(lastDot).toLowerCase();\n return (\n overrides?.[ext] || DEFAULT_MIME_TYPES[ext] || 'application/octet-stream'\n );\n}\n","import type { Transformer } from '@walkeros/core';\nimport type { RespondFn } from '@walkeros/core';\nimport { getMimeType } from './mime';\nimport type { FileSettings, FileEnv, Types } from './types';\n\nexport const transformerFile: Transformer.Init<Types> = (context) => {\n const { config } = context;\n const settings = (config.settings || {}) as Partial<FileSettings>;\n const prefix = settings.prefix;\n const defaultHeaders = settings.headers;\n const mimeOverrides = settings.mimeTypes;\n\n const store = (context.env as FileEnv).store;\n\n return {\n type: 'file',\n config: config as Transformer.Config<Types>,\n\n async push(event, context) {\n const { logger } = context;\n const ingest = (context.ingest || {}) as Record<string, unknown>;\n const envRespond = context.env.respond as RespondFn | undefined;\n\n const rawPath = ingest.path as string | undefined;\n if (!rawPath) return;\n\n if (!store) {\n logger.warn('No store provided to file transformer');\n return;\n }\n\n // Apply prefix stripping\n let filePath = rawPath;\n if (prefix) {\n if (!filePath.startsWith(prefix)) return; // Not our path\n filePath = filePath.slice(prefix.length);\n }\n\n // Strip leading slash for store key\n if (filePath.startsWith('/')) filePath = filePath.slice(1);\n if (!filePath) return;\n\n // Fetch from store\n const content = await store.get(filePath);\n if (content == null) return;\n\n // Derive Content-Type\n const contentType = getMimeType(filePath, mimeOverrides);\n const contentLength =\n content instanceof Buffer\n ? content.length\n : typeof content === 'string'\n ? Buffer.byteLength(content)\n : undefined;\n\n const headers: Record<string, string> = {\n 'Content-Type': contentType,\n ...defaultHeaders,\n };\n if (contentLength !== undefined) {\n headers['Content-Length'] = String(contentLength);\n }\n\n envRespond?.({\n body: content,\n status: 200,\n headers,\n });\n\n return false;\n },\n };\n};\n"],"m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AG,YAAW,SAAS,MAAM,CAAC;AACzD,UAAI,CAAC,SAAU;AAGf,YAAM,UAAU,MAAM,MAAM,IAAI,QAAQ;AACxC,UAAI,WAAW,KAAM;AAGrB,YAAM,cAAc,YAAY,UAAU,aAAa;AACvD,YAAM,gBACJ,mBAAmB,SACf,QAAQ,SACR,OAAO,YAAY,WACjB,OAAO,WAAW,OAAO,IACzB;AAER,YAAM,UAAkC;AAAA,QACtC,gBAAgB;AAAA,QAChB,GAAG;AAAA,MACL;AACA,UAAI,kBAAkB,QAAW;AAC/B,gBAAQ,gBAAgB,IAAI,OAAO,aAAa;AAAA,MAClD;AAEA,mBAAa;AAAA,QACX,MAAM;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["context"]}
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-transformer-file",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-next-1777463920154",
|
|
5
5
|
"type": "transformer",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -59,20 +59,14 @@
|
|
|
59
59
|
"data": {
|
|
60
60
|
"path": "/static/walker.js"
|
|
61
61
|
},
|
|
62
|
-
"id": "1700000600
|
|
62
|
+
"id": "ev-1700000600",
|
|
63
63
|
"trigger": "load",
|
|
64
64
|
"entity": "page",
|
|
65
65
|
"action": "view",
|
|
66
66
|
"timestamp": 1700000600,
|
|
67
|
-
"group": "gr0up",
|
|
68
|
-
"count": 1,
|
|
69
|
-
"version": {
|
|
70
|
-
"tagging": 1
|
|
71
|
-
},
|
|
72
67
|
"source": {
|
|
73
|
-
"type": "
|
|
74
|
-
"
|
|
75
|
-
"previous_id": ""
|
|
68
|
+
"type": "express",
|
|
69
|
+
"platform": "server"
|
|
76
70
|
}
|
|
77
71
|
},
|
|
78
72
|
"out": [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-transformer-file",
|
|
3
3
|
"description": "File serving transformer for walkerOS - serves static files via pluggable Store backend",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-next-1777463920154",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"update": "npx npm-check-updates -u && npm update"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@walkeros/core": "
|
|
30
|
+
"@walkeros/core": "4.0.0-next-1777463920154"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@walkeros/core": "
|
|
34
|
-
"@walkeros/store-memory": "
|
|
33
|
+
"@walkeros/core": "4.0.0-next-1777463920154",
|
|
34
|
+
"@walkeros/store-memory": "4.0.0-next-1777463920154"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|