Packages
Packages
Section titled “Packages”Reusable portable modules - Generic packages designed to work independently of ION Flow.
Overview
Section titled “Overview”The packages/ directory contains reusable, self-contained modules that can be used in any Go project. They are designed with modularity and portability in mind.
Design Principles
Section titled “Design Principles”- Self-contained - No dependencies on ION-specific code
- Independent - Works standalone without ION Flow
- Portable - Can be imported by other projects
- Generic - Solves common problems
Available Packages
Section titled “Available Packages”| Package | Description |
|---|---|
| Channel | Authentication engine (OAuth, API Key, Basic) |
| Helpers | Generic utility functions |
Channel Package
Section titled “Channel Package”Authentication engine supporting multiple auth types:
import "gitlab.com/altacrest/flow_binaries/packages/channel/services"
// Authorize a connectionresponse, err := services.Authorize(authType, apiConfig, params, state)
// Get token (OAuth)token, err := services.TokenHandler(config, params)
// Refresh tokennewToken, err := services.RefreshHandler(config, params)
// Get connection infoinfo, err := services.Info(authType, config, params)Supported Auth Types
Section titled “Supported Auth Types”| Type | Description |
|---|---|
oauth2_code | OAuth 2.0 Authorization Code |
oauth2_code_refresh_token | OAuth 2.0 with token refresh |
api_key | API Key authentication |
basic | HTTP Basic authentication |
client_credentials | OAuth 2.0 Client Credentials |
owner_credentials | OAuth 2.0 Resource Owner Password |
Helpers Package
Section titled “Helpers Package”Generic utility functions:
import "gitlab.com/altacrest/flow_binaries/packages/helpers"
// Configuration parsingvalue := helpers.ParseStringWithDefault(input, "default")num := helpers.ParseIntWithDefault(input, 0)flag := helpers.ParseBoolWithDefault(input, false)
// JSONC sanitizationclean := helpers.SanitizeJSONC(jsoncString)data, err := helpers.ParseJSONC(jsoncString)Package Dependencies
Section titled “Package Dependencies”graph TD Channel --> Helpers Channel --> CoreModels[Core Models]
Helpers[Helpers - Independent]When to Use Packages
Section titled “When to Use Packages”Use packages/channel when:
Section titled “Use packages/channel when:”- Implementing OAuth authentication
- Handling API key or Basic auth
- Making authenticated HTTP requests
- Managing connection credentials
Use packages/helpers when:
Section titled “Use packages/helpers when:”- Parsing configuration values with defaults
- Working with JSONC (JSON with comments)
- Need generic string/pointer utilities
Create a new package when:
Section titled “Create a new package when:”- Functionality is completely generic
- Code could be used in other projects
- No ION-specific dependencies needed
Import Paths
Section titled “Import Paths”// Channel packageimport "gitlab.com/altacrest/flow_binaries/packages/channel/services"import "gitlab.com/altacrest/flow_binaries/packages/channel/models"
// Helpers packageimport "gitlab.com/altacrest/flow_binaries/packages/helpers"Related Documentation
Section titled “Related Documentation”- Channel Package - Authentication engine
- Helpers Package - Utility functions