PageSourceSearch

https://www.fluvio.io/assets/js/fb411491.84e25926.js

js fluvio.io collected 2026-10-04 00:32:04 UTC 5,282 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkfluvio_docs=self.webpackChunkfluvio_docs||[]).push([[5867],{15418:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>r,default:()=>d,frontMatter:()=>i,metadata:()=>c,toc:()=>l});var t=s(74848),o=s(28453);const i={title:"Imports",description:":Package imports",sidebar_position:400},r="Importing Functions",c={id:"composition/imports",title:"Imports",description:":Package imports",source:"@site/sdf_versioned_docs/version-sdf-beta6/composition/imports.mdx",sourceDirName:"composition",slug:"/composition/imports",permalink:"/sdf/sdf-beta6/composition/imports",draft:!1,unlisted:!1,tags:[],version:"sdf-beta6",sidebarPosition:400,frontMatter:{title:"Imports",description:":Package imports",sidebar_position:400},sidebar:"sdf",previous:{title:"sdf-package.yaml",permalink:"/sdf/sdf-beta6/composition/sdf-package-yaml"},next:{title:"Deployment",permalink:"/sdf/sdf-beta6/deployment"}},a={},l=[];function p(e){const n={code:"code",h1:"h1",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.p,{children:"Dataflows and packages can import function and types from other packages.  This hierarchical import structure allows you to reuse code and types across multiple projects."}),"\n",(0,t.jsx)(n.p,{children:"Importing a package involves these steps:"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:"specifying the package to import"}),"\n",(0,t.jsx)(n.li,{children:"specifying the functions"}),"\n",(0,t.jsx)(n.li,{children:"specifying the types to import"}),"\n"]}),"\n",(0,t.jsx)(n.p,{children:"You can either import functions or types or both."}),"\n",(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"importing-functions",children:"Importing Functions"})}),"\n",(0,t.jsxs)(n.p,{children:["Use keyword: ",(0,t.jsx)(n.code,{children:"functions"})," in a ",(0,t.jsx)(n.code,{children:"imports"})," sections to import functions."]}),"\n",(0,t.jsx)(n.p,{children:"Syntax:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"imports:\n  - pkg: <package-namespace>/<package-name>@<package-version>\n    functions:\n      - name: <function-name>\n        alias: <alias-name>\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Here is sample config to  imports a function ",(0,t.jsx)(n.code,{children:"my-hello-fn"})," from the package ",(0,t.jsx)(n.code,{children:"sdf-test/hello"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"imports:\n  - pkg: sdf-test/[email protected]\n    functions:\n      - name: my-hello-fn\n        alias: hello-fn\n"})}),"\n",(0,t.jsxs)(n.p,{children:["The function can be alias to a different name. In this case, the function ",(0,t.jsx)(n.code,{children:"my-hello-fn"})," is imported as ",(0,t.jsx)(n.code,{children:"hello-fn"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["After import, you can reference the function with the ",(0,t.jsx)(n.code,{children:"uses"})," keyword."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"  transforms:\n      - operator: filter-map\n        uses: hello-fn\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Since ",(0,t.jsx)(n.code,{children:"hello-fn"})," is filter-map function, It can only be used in the ",(0,t.jsx)(n.code,{children:"filter-map"})," operator."]}),"\n",(0,t.jsx)(n.h1,{id:"importing-types",children:"Importing Types"}),"\n",(0,t.jsx)(n.p,{children:"Similar to functions, you can also import types from other packages."}),"\n",(0,t.jsx)(n.p,{children:"Syntax:"}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"imports:\n  - pkg: <package-namespace>/<package-name>@<package-version>\n    types:\n      - name: <type-name>\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Here is sample config that imports a type ",(0,t.jsx)(n.code,{children:"my-hello-type"})," from the package ",(0,t.jsx)(n.code,{children:"sdf-test/hello"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"imports:\n  - pkg: sdf-test/[email protected]\n    types:\n      - name: my-hello-type\n"})}),"\n",(0,t.jsxs)(n.p,{children:["Of course you can mix and match functions and types in the same ",(0,t.jsx)(n.code,{children:"imports"})," section."]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",children:"imports:\n  - pkg: sdf-test/[email protected]\n    functions:\n      - name: my-hello-fn\n    types:\n      - name: my-hello-type\n"})}),"\n",(0,t.jsx)(n.h1,{id:"recursive-imports",children:"Recursive Imports"}),"\n",(0,t.jsx)(n.p,{children:"Recursive imports are also supported.  You can import functions and types from packages that themselves import functions and types from other packages."})]})}function d(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(p,{...e})}):p(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>r,x:()=>c});var t=s(96540);const o={},i=t.createContext(o);function r(e){const n=t.useContext(i);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),t.createElement(i.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.