UNPKG

yini-parser

Version:

Readable configuration without YAML foot-guns or JSON noise. The official Node.js parser for YINI config format — An INI-inspired configuration format with clear nesting, explicit types, and predictable parsing.

22 lines (21 loc) 10.8 kB
/** * Development-only YINI samples. * * These inputs are used for quick manual testing during development * via src/dev/quick-test-samples/main.ts. They are NOT part of the automated test suite. * * All real testing belongs in /tests/. */ export declare const validConfigShort = "\n^ App\nname = 'Hello'\n"; export declare const validConfigBasic = "\n^ App\nname = \"My Application\"\nversion = 1.0\nfeatures = [\"search\", \"logging\"]\n\n // Nested sub-section under App\n ^^ Database\n host = \"localhost\"\n port = 5432\n"; export declare const validConfigWithObjects = "\n^ App\n name = \"Demo\"\n version = \"1.0.0\"\n features = [ \"search\", \"dark-mode\" ]\n\n^ Database\n host = \"localhost\"\n port = 5432\n auth = { user: \"admin\", pass: \"secret\" }\n"; /** * Covers booleans, nulls, number formats, and deeper nesting */ export declare const validConfigAdvanced = "\n^ Server\n enabled = ON\n timeout = 3.5\n retries = 5\n threshold = 1e-3\n fallback = null\n\n ^^ Logging\n level = \"info\"\n output = { file: \"app.log\", rotate: true }\n"; /** * Covers arrays of objects and realistic structure */ export declare const validConfigComplex = "\n^ App\n services = [\n { name: \"api\", port: 8080 },\n { name: \"web\", port: 3000 },\n { name: \"auth\", port: 9000 }\n ]\n\n^ Security\n roles = [\"admin\", \"user\", \"guest\"]\n enabled = true\n"; export declare const validConfigComplexBigA = "\n@YINI\n\n// Example A: Corporate SaaS Platform.\n\n^ App\nname = \"Acme Platform\" // Example Platform\ndescription = \"The word \u201CAcme\u201D has been used for over 100 years in technical and business examples.\"\nmeaning = \"It comes from Greek akm\u1E17 (\u1F00\u03BA\u03BC\u03AE), meaning \u201Cthe highest point\u201D or \u201Cbest\u201D.\"\nversion = \"2.3.1\"\ndebug = OFF\nenvironment = \"production\"\nmaintainers = [\"ops@acme.com\", \"dev@acme.com\"]\n\n ^^ Features\n enableSearch = true\n enablePayments = true\n enableAnalytics = false\n experimental = [\"new-ui\", \"streaming-api\"]\n\n ^^ Limits\n maxUsers = 50000\n requestTimeoutMs = 3500\n retryPolicy = { maxRetries: 5, backoff: \"exponential\" }\n\n ^^ Database\n engine = \"postgres\"\n host = \"db.internal.acme.com\"\n port = 5432\n ssl = true\n pool = { min: 5, max: 50 }\n\n ^^^ Credentials\n username = \"app_user\"\n password = \"****\"\n rotateEveryDays = 90\n\n ^^ API\n baseUrl = \"https://api.acme.com\"\n publicEndpoints = [\"/health\", \"/status\"]\n internalEndpoints = [\"/admin\", \"/metrics\"]\n\n ^^^ Auth\n provider = \"oauth2\"\n tokenTTLSeconds = 3600\n scopes = [\"read\", \"write\", \"admin\"]\n\n ^^^^ Clients\n web = { clientId: \"web-123\", redirectUri: \"https://acme.com/callback\" }\n mobile = { clientId: \"mob-456\", redirectUri: \"acme://auth\" }\n\n^ Logging\nlevel = \"info\"\nformat = \"json\"\noutputs = [\"stdout\", \"file\"]\n\n ^^ File\n path = \"/var/log/acme/app.log\"\n maxSizeMB = 100\n rotate = true\n keepFiles = 10\n\n ^^ Metrics\n enabled = true\n endpoint = \"/metrics\"\n sampleRate = 0.25\n\n^ Services\nenabled = true\n\n ^^ Email\n provider = \"smtp\"\n host = \"smtp.acme.com\"\n port = 587\n secure = false\n from = \"no-reply@acme.com\"\n\n ^^^ Credentials\n user = \"mailer\"\n pass = \"mailer-secret\"\n\n ^^ Cache\n type = \"redis\"\n host = \"cache.internal.acme.com\"\n port = 6379\n ttlSeconds = 600\n\n ^^^ Cluster\n nodes = [\n { host: \"cache-1.internal\", port: 6379 },\n { host: \"cache-2.internal\", port: 6379 },\n { host: \"cache-3.internal\", port: 6379 }\n ]\n\n^ Observability\ntracing = true\ntracingProvider = \"opentelemetry\"\ntraceSampleRate = 0.1\n\n ^^ Exporters\n jaeger = { enabled: true, endpoint: \"http://jaeger:14268/api/traces\" }\n prometheus = { enabled: true, endpoint: \"http://prom:9090\" }\n\n^ Security\nallowedIPs = [\"10.0.0.0/8\", \"192.168.0.0/16\"]\nblockedCountries = [\"KP\", \"SD\"]\n\n ^^ Policies\n passwordMinLength = 14\n require2FA = true\n sessionTTLMinutes = 120\n\n ^^^ Lockout\n maxAttempts = 5\n lockoutMinutes = 30\n"; export declare const validConfigComplexBigB = "\n@YINI\n\n// Example B: High-Security Distributed Control System.\n\n^ App\nname = 'Nebula Control Suite'\ndescription = 'A distributed operations platform for autonomous systems and edge analytics.'\nmeaning = 'Nebula comes from Latin \"nebula\" meaning mist or cloud.'\nversion = '5.0.0-rc.4'\ndebug = ON\nenvironment = 'staging'\nmaintainers = ['infra@nebula.io', 'platform@nebula.io', 'secops@nebula.io']\n\n ^^ Features\n enableSearch = false\n enablePayments = false\n enableAnalytics = true\n experimental = ['vector-engine', 'adaptive-ui', 'ai-routing']\n\n ^^ Limits\n maxUsers = 120000\n requestTimeoutMs = 7200\n retryPolicy = {\n maxRetries: 9,\n backoff: 'fibonacci',\n retryOn: ['timeout', '5xx', 'throttle'],\n schedule: [\n { attempt: 1, delayMs: 80 },\n { attempt: 2, delayMs: 160 },\n { attempt: 3, delayMs: 320 },\n { attempt: 4, delayMs: 640 },\n { attempt: 5, delayMs: 1280 }\n ]\n }\n\n ^^ Database\n engine = 'cockroachdb'\n host = 'cluster.db.nebula.io'\n port = 26257\n ssl = true\n pool = {\n min: 12,\n max: 120,\n warmup: {\n enabled: true,\n strategy: 'aggressive',\n steps: [10, 25, 50, 75, 100],\n healthChecks: [\n { name: 'connectivity', timeoutMs: 300 },\n { name: 'replication', maxLagMs: 200 },\n { name: 'quorum', minNodes: 3 }\n ]\n }\n }\n\n ^^^ Credentials\n username = 'nebula_app'\n password = '****'\n rotateEveryDays = 45\n history = [\n { rotatedAt: '2025-05-10', reason: 'scheduled' },\n { rotatedAt: '2025-03-02', reason: 'key-compromise' },\n { rotatedAt: '2024-12-15', reason: 'policy-change' }\n ]\n\n ^^ API\n baseUrl = 'https://api.nebula.io'\n publicEndpoints = ['/health', '/status', '/version']\n internalEndpoints = ['/admin', '/metrics', '/orchestrator', '/scheduler']\n\n ^^^ Auth\n provider = 'oidc'\n tokenTTLSeconds = 5400\n scopes = ['read', 'write', 'deploy', 'audit']\n\n ^^^^ Clients\n web = {\n clientId: 'nebula-web-prod',\n redirectUri: 'https://nebula.io/auth/callback',\n allowedOrigins: ['https://nebula.io', 'https://console.nebula.io'],\n secrets: [\n { id: 'alpha', value: 'QX7faP9', active: true },\n { id: 'beta', value: 'LM8KdW2', active: true },\n { id: 'legacy', value: 'OLD-KEY-DO-NOT-USE', active: false }\n ]\n }\n\n mobile = {\n clientId: 'nebula-mobile',\n redirectUri: 'nebula://auth',\n platforms: [\n { name: 'ios', minVersion: '15.2', enabled: true },\n { name: 'android', minVersion: '11', enabled: true },\n { name: 'harmonyos', minVersion: '4', enabled: false }\n ],\n refreshPolicy: {\n enabled: true,\n limits: { perHour: 60, perDay: 600 },\n audit: [\n { event: 'refresh', severity: 'info' },\n { event: 'suspicious-location', severity: 'warning' },\n { event: 'credential-stuffing', severity: 'critical' }\n ]\n }\n }\n\n^ Logging\nlevel = 'debug'\nformat = 'ndjson'\noutputs = ['stdout', 'file', 'syslog']\n\n ^^ File\n path = '/srv/log/nebula/nebula.log'\n maxSizeMB = 250\n rotate = true\n keepFiles = 30\n\n ^^ Metrics\n enabled = true\n endpoint = '/internal/metrics'\n sampleRate = 0.75\n\n^ Services\nenabled = true\n\n ^^ Email\n provider = 'ses'\n host = 'email.nebula.io'\n port = 465\n secure = true\n from = 'system@nebula.io'\n\n ^^^ Credentials\n user = 'mailer-nebula'\n pass = 'MAIL-SEC-9921'\n\n ^^ Cache\n type = 'keydb'\n host = 'cache.nebula.internal'\n port = 6380\n ttlSeconds = 1800\n\n ^^^ Cluster\n nodes = [\n { host: 'cache-a.nebula', port: 6380, role: 'primary', zones: ['eu-north-1a'] },\n { host: 'cache-b.nebula', port: 6380, role: 'replica', zones: ['eu-north-1b'] },\n { host: 'cache-c.nebula', port: 6380, role: 'replica', zones: ['eu-north-1c'] },\n { host: 'cache-d.nebula', port: 6380, role: 'observer', zones: ['eu-north-1a'] }\n ]\n\n ^^^ Failover\n strategy = {\n mode: 'predictive',\n thresholds: { errorRate: 0.08, latencyMs: 180 },\n actions: [\n { step: 'drain-traffic', timeoutMs: 1500 },\n { step: 'promote-replica', timeoutMs: 2000 },\n { step: 'resync', propagate: true },\n { step: 'notify', channels: ['pagerduty', 'slack', 'email'] }\n ]\n }\n\n^ Observability\ntracing = true\ntracingProvider = 'tempo'\ntraceSampleRate = 0.35\n\n ^^ Exporters\n jaeger = {\n enabled: false,\n endpoint: 'http://jaeger.internal/api/traces',\n tags: {\n region: 'eu-north',\n environment: 'staging',\n build: { version: '5.0.0-rc.4', commit: 'c8f91d2', dirty: true }\n }\n }\n\n prometheus = {\n enabled: true,\n endpoint: 'http://prometheus.nebula:9090',\n scrapeIntervals: [2, 5, 10, 30],\n retention: { days: 90, maxSeries: 3500000 }\n }\n\n^ Security\nallowedIPs = ['172.16.0.0/12', '100.64.0.0/10']\nblockedCountries = ['KP', 'NG', 'BY']\n\n ^^ Policies\n passwordMinLength = 18\n require2FA = true\n sessionTTLMinutes = 45\n\n ^^^ Lockout\n maxAttempts = 4\n lockoutMinutes = 60\n escalation = {\n enabled: true,\n notify: ['security@nebula.io', 'ciso@nebula.io'],\n rules: [\n { attempts: 3, action: 'captcha' },\n { attempts: 4, action: 'temporary-block', minutes: 120 },\n { attempts: 6, action: 'account-freeze' },\n { attempts: 9, action: 'permanent-block' }\n ]\n }\n";