@ultrst-armada/kloks 2.0.1 → 2.0.3

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/packages/backend/dist/api/index.js +1 -1
  3. package/packages/backend/dist/api/middleware.test.d.ts +1 -0
  4. package/packages/backend/dist/chunk-GYSZ6CAX.js +19 -0
  5. package/packages/backend/dist/{chunk-WC6EPW3A.js → chunk-POLVHTHJ.js} +16 -6
  6. package/packages/backend/dist/development/wasmRuntimeService.d.ts +1 -1
  7. package/packages/backend/dist/index.d.ts +1 -0
  8. package/packages/backend/dist/index.js +7 -1
  9. package/packages/backend/dist/node.js +9 -20
  10. package/packages/backend/dist/resolver/index.d.ts +1 -0
  11. package/packages/client/dist/auth.js +1 -1
  12. package/packages/client/dist/{chunk-5JMYSB7L.js → chunk-ATLIA7AJ.js} +11 -1
  13. package/packages/client/dist/index.js +1 -1
  14. package/packages/functions/dist/async.d.ts +36 -0
  15. package/packages/functions/dist/base.d.ts +31 -1
  16. package/packages/functions/dist/cache.d.ts +27 -0
  17. package/packages/functions/dist/env-node.d.ts +8 -0
  18. package/packages/functions/dist/env.d.ts +19 -0
  19. package/packages/functions/dist/events.d.ts +32 -0
  20. package/packages/functions/dist/fileCache.d.ts +9 -0
  21. package/packages/functions/dist/fs-lock.d.ts +9 -0
  22. package/packages/functions/dist/fs.d.ts +35 -0
  23. package/packages/functions/dist/http.d.ts +36 -0
  24. package/packages/functions/dist/index.d.ts +14 -16
  25. package/packages/functions/dist/node.d.ts +7 -110
  26. package/packages/functions/dist/object.d.ts +32 -0
  27. package/packages/functions/dist/portable.d.ts +12 -206
  28. package/packages/functions/dist/shell.d.ts +37 -0
  29. package/packages/functions/dist/string.d.ts +14 -0
  30. package/packages/functions/dist/types.d.ts +31 -0
  31. package/packages/functions/package.json +1 -1
  32. package/packages/wasm-runtime/dist/index.d.ts +4 -3
  33. package/packages/wasm-runtime/dist/index.js +1 -3
  34. package/packages/wasm-runtime/vendor/forge/browser/dist/index.js +2 -2
  35. package/packages/functions/dist/base-DDYO-DzM.d.ts +0 -64
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/kloks",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -3,7 +3,7 @@ import {
3
3
  createSSEResponse,
4
4
  withAuth,
5
5
  withCors
6
- } from "../chunk-WC6EPW3A.js";
6
+ } from "../chunk-POLVHTHJ.js";
7
7
  export {
8
8
  BaseApiRoute,
9
9
  createSSEResponse,
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ // src/resolver/systemDatabaseUrl.ts
2
+ function resolveSystemDatabaseUrl(env = typeof process !== "undefined" ? process.env : {}) {
3
+ const url = env["SYSTEM_DATABASE_URL"] && env["SYSTEM_DATABASE_URL"].trim() || env["SYSTEM_DATABASE_URL_1"] && env["SYSTEM_DATABASE_URL_1"].trim() || env["SYSTEM_DATABASE_URL_2"] && env["SYSTEM_DATABASE_URL_2"].trim() || env["SYSTEM_DATABASE_URL_3"] && env["SYSTEM_DATABASE_URL_3"].trim();
4
+ if (!url) {
5
+ throw new Error(
6
+ "[SKIPO DATABASE_INVARIANT] Missing system database configuration.\n Set SYSTEM_DATABASE_URL (primary), SYSTEM_DATABASE_URL_2 (fallback #1),\n or SYSTEM_DATABASE_URL_3 (fallback #2).\n Generic DATABASE_URL is obsolete and strictly forbidden in this architecture."
7
+ );
8
+ }
9
+ return url;
10
+ }
11
+ function tryResolveSystemDatabaseUrl(env = typeof process !== "undefined" ? process.env : {}) {
12
+ const url = env["SYSTEM_DATABASE_URL"] && env["SYSTEM_DATABASE_URL"].trim() || env["SYSTEM_DATABASE_URL_1"] && env["SYSTEM_DATABASE_URL_1"].trim() || env["SYSTEM_DATABASE_URL_2"] && env["SYSTEM_DATABASE_URL_2"].trim() || env["SYSTEM_DATABASE_URL_3"] && env["SYSTEM_DATABASE_URL_3"].trim();
13
+ return url || null;
14
+ }
15
+
16
+ export {
17
+ resolveSystemDatabaseUrl,
18
+ tryResolveSystemDatabaseUrl
19
+ };
@@ -23,22 +23,32 @@ var BaseApiRoute = class extends SkipoBase {
23
23
  // src/api/middleware.ts
24
24
  function withAuth(verifyToken) {
25
25
  return async (req) => {
26
- const authHeader = req.headers.get("Authorization");
27
- if (!authHeader || !authHeader.startsWith("Bearer ")) {
26
+ const authHeader = req.headers.get("authorization") ?? req.headers.get("Authorization");
27
+ if (!authHeader) {
28
28
  return new Response(JSON.stringify({ error: "Unauthorized", status: 401 }), { status: 401 });
29
29
  }
30
- const token = authHeader.split(" ")[1];
31
- const isValid = await verifyToken(token);
32
- if (!isValid) {
30
+ const trimmed = authHeader.trim();
31
+ const parts = trimmed.split(/\s+/);
32
+ if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer" || !parts[1]) {
33
33
  return new Response(JSON.stringify({ error: "Unauthorized", status: 401 }), { status: 401 });
34
34
  }
35
- return null;
35
+ const token = parts[1];
36
+ try {
37
+ const isValid = await verifyToken(token);
38
+ if (!isValid) {
39
+ return new Response(JSON.stringify({ error: "Unauthorized", status: 401 }), { status: 401 });
40
+ }
41
+ return null;
42
+ } catch {
43
+ return new Response(JSON.stringify({ error: "Service Unavailable", status: 503 }), { status: 503 });
44
+ }
36
45
  };
37
46
  }
38
47
  function withCors(allowedOrigin = "*") {
39
48
  return async (req) => {
40
49
  if (req.method === "OPTIONS") {
41
50
  return new Response(null, {
51
+ status: 204,
42
52
  headers: {
43
53
  "Access-Control-Allow-Origin": allowedOrigin,
44
54
  "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
@@ -1,4 +1,4 @@
1
- import { type RuntimeExecuteRequest, type RuntimeResult } from "@ultrst-armada/kloks/wasm-runtime";
1
+ import type { RuntimeExecuteRequest, RuntimeResult } from "@ultrst-armada/kloks/wasm-runtime";
2
2
  import { type IService, type ServiceDefinition } from "@ultrst-armada/krnl";
3
3
  export declare const WasmRuntimeServiceDefinition: ServiceDefinition;
4
4
  export interface WasmRuntimeServiceFacade {
@@ -5,4 +5,5 @@ export * from './storage/index.js';
5
5
  export * from './workspace/index.js';
6
6
  export * from './connectivity/index.js';
7
7
  export * from './services/index.js';
8
+ export * from './resolver/index.js';
8
9
  export type { Runtime, Deployment, FunctionSet, ServiceFacade, OrchestrationFn, BackendFacade, ServiceRegistryRecord, } from './architecture/types.js';
@@ -1,5 +1,9 @@
1
1
  import "./chunk-RABSY2JU.js";
2
2
  import "./chunk-2Y2EXYDK.js";
3
+ import {
4
+ resolveSystemDatabaseUrl,
5
+ tryResolveSystemDatabaseUrl
6
+ } from "./chunk-GYSZ6CAX.js";
3
7
  import "./chunk-DAG2L4RN.js";
4
8
  import {
5
9
  WorkspaceCloneSyncEngine
@@ -9,7 +13,7 @@ import {
9
13
  createSSEResponse,
10
14
  withAuth,
11
15
  withCors
12
- } from "./chunk-WC6EPW3A.js";
16
+ } from "./chunk-POLVHTHJ.js";
13
17
  import {
14
18
  LuthAuthClient,
15
19
  LuthAuthClient2,
@@ -98,6 +102,8 @@ export {
98
102
  resolveBackblazeEndpoint,
99
103
  resolveClientEnvironment,
100
104
  resolveClientOrigin,
105
+ resolveSystemDatabaseUrl,
106
+ tryResolveSystemDatabaseUrl,
101
107
  withAuth,
102
108
  withCors
103
109
  };
@@ -65,6 +65,10 @@ import {
65
65
  getSystemDatabaseUrls,
66
66
  resolveSystemDatabaseClusterNodes
67
67
  } from "./chunk-ZBNSK26X.js";
68
+ import {
69
+ resolveSystemDatabaseUrl,
70
+ tryResolveSystemDatabaseUrl
71
+ } from "./chunk-GYSZ6CAX.js";
68
72
  import "./chunk-DAG2L4RN.js";
69
73
  import {
70
74
  WorkspaceCloneSyncEngine
@@ -74,7 +78,7 @@ import {
74
78
  createSSEResponse,
75
79
  withAuth,
76
80
  withCors
77
- } from "./chunk-WC6EPW3A.js";
81
+ } from "./chunk-POLVHTHJ.js";
78
82
  import {
79
83
  LuthAuthClient,
80
84
  LuthAuthClient2,
@@ -4358,32 +4362,17 @@ async function deleteWorkspaceGraph(workspaceIdOrSlug, graphIdOrName) {
4358
4362
  return false;
4359
4363
  }
4360
4364
 
4361
- // src/resolver/systemDatabaseUrl.ts
4362
- function resolveSystemDatabaseUrl(env = typeof process !== "undefined" ? process.env : {}) {
4363
- const url = env["SYSTEM_DATABASE_URL"] && env["SYSTEM_DATABASE_URL"].trim() || env["SYSTEM_DATABASE_URL_1"] && env["SYSTEM_DATABASE_URL_1"].trim() || env["SYSTEM_DATABASE_URL_2"] && env["SYSTEM_DATABASE_URL_2"].trim() || env["SYSTEM_DATABASE_URL_3"] && env["SYSTEM_DATABASE_URL_3"].trim();
4364
- if (!url) {
4365
- throw new Error(
4366
- "[SKIPO DATABASE_INVARIANT] Missing system database configuration.\n Set SYSTEM_DATABASE_URL (primary), SYSTEM_DATABASE_URL_2 (fallback #1),\n or SYSTEM_DATABASE_URL_3 (fallback #2).\n Generic DATABASE_URL is obsolete and strictly forbidden in this architecture."
4367
- );
4368
- }
4369
- return url;
4370
- }
4371
- function tryResolveSystemDatabaseUrl(env = typeof process !== "undefined" ? process.env : {}) {
4372
- const url = env["SYSTEM_DATABASE_URL"] && env["SYSTEM_DATABASE_URL"].trim() || env["SYSTEM_DATABASE_URL_1"] && env["SYSTEM_DATABASE_URL_1"].trim() || env["SYSTEM_DATABASE_URL_2"] && env["SYSTEM_DATABASE_URL_2"].trim() || env["SYSTEM_DATABASE_URL_3"] && env["SYSTEM_DATABASE_URL_3"].trim();
4373
- return url || null;
4374
- }
4375
-
4376
4365
  // src/development/wasmRuntimeService.ts
4377
- import {
4378
- createWasmRuntime
4379
- } from "@ultrst-armada/kloks/wasm-runtime";
4380
4366
  import {
4381
4367
  createService,
4382
4368
  createServiceDefinition
4383
4369
  } from "@ultrst-armada/krnl";
4384
4370
  var runtime;
4385
4371
  async function getRuntime(options = {}) {
4386
- runtime ??= await createWasmRuntime(options);
4372
+ if (!runtime) {
4373
+ const { createWasmRuntime } = await import("@ultrst-armada/kloks/wasm-runtime");
4374
+ runtime = await createWasmRuntime(options);
4375
+ }
4387
4376
  return runtime;
4388
4377
  }
4389
4378
  var WasmRuntimeServiceDefinition = createServiceDefinition({
@@ -0,0 +1 @@
1
+ export * from './systemDatabaseUrl.js';
@@ -13,7 +13,7 @@ import {
13
13
  resolveClientEnvironment,
14
14
  resolveClientOrigin,
15
15
  verifyLuthRequest
16
- } from "./chunk-5JMYSB7L.js";
16
+ } from "./chunk-ATLIA7AJ.js";
17
17
  export {
18
18
  CANONICAL_PUBLIC_ROUTES,
19
19
  LuthAuthClient2 as CanonicalAuthClient,
@@ -103,7 +103,17 @@ async function verifyLuthRequest(request, options) {
103
103
  // src/auth.ts
104
104
  function createUniversalAuthFetch(authClient) {
105
105
  return async function universalAuthFetch(input, init = {}) {
106
- const headers = new Headers(init.headers);
106
+ const headers = new Headers();
107
+ if (typeof input === "object" && input !== null && "headers" in input && input.headers) {
108
+ new Headers(input.headers).forEach((value, key) => {
109
+ headers.set(key, value);
110
+ });
111
+ }
112
+ if (init.headers) {
113
+ new Headers(init.headers).forEach((value, key) => {
114
+ headers.set(key, value);
115
+ });
116
+ }
107
117
  new Headers(authClient.getAuthHeaders()).forEach((value, key) => {
108
118
  if (!headers.has(key)) headers.set(key, value);
109
119
  });
@@ -13,7 +13,7 @@ import {
13
13
  resolveClientEnvironment,
14
14
  resolveClientOrigin,
15
15
  verifyLuthRequest
16
- } from "./chunk-5JMYSB7L.js";
16
+ } from "./chunk-ATLIA7AJ.js";
17
17
 
18
18
  // src/browserExecutionClient.ts
19
19
  var BrowserExecutionClient = class {
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file async.ts
3
+ * @description sleep, withTimeout, retry, pLimit, debounce, throttle, once, and memoize primitives.
4
+ */
5
+ /**
6
+ * Classic sleep/delay.
7
+ */
8
+ export declare function sleep(ms: number): Promise<void>;
9
+ /**
10
+ * Rejects if the task does not finish within ms.
11
+ */
12
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, label?: string): Promise<T>;
13
+ /**
14
+ * Retries an async execution up to maxAttempts times.
15
+ */
16
+ export declare function retry<T>(fn: () => Promise<T>, maxAttempts: number, delayMs?: number): Promise<T>;
17
+ /**
18
+ * Limits concurrent async task execution.
19
+ */
20
+ export declare function pLimit<T>(tasks: (() => Promise<T>)[], concurrency: number): Promise<T[]>;
21
+ /**
22
+ * Debounces a function.
23
+ */
24
+ export declare function debounce<T extends (...args: any[]) => any>(fn: T, ms: number): (...args: Parameters<T>) => void;
25
+ /**
26
+ * Throttles a function.
27
+ */
28
+ export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number): (...args: Parameters<T>) => void;
29
+ /**
30
+ * Wraps a function to run only once and cache its outcome.
31
+ */
32
+ export declare function once<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
33
+ /**
34
+ * Computational memoization cache helper.
35
+ */
36
+ export declare function memoize<T extends (...args: any[]) => any>(fn: T, keyFn?: (...args: Parameters<T>) => string): (...args: Parameters<T>) => ReturnType<T>;
@@ -1 +1,31 @@
1
- export { S as SkipoBase } from './base-DDYO-DzM.js';
1
+ import type { Disposable, Logger, SkipoConfig } from './types.js';
2
+ /**
3
+ * SkipoBase — Abstract foundation class for all Skipo components.
4
+ * Provides lifecycle management, logging, and unique identification.
5
+ * All @skipo/* classes should extend this.
6
+ */
7
+ export declare abstract class SkipoBase implements Disposable {
8
+ /** Unique instance identifier */
9
+ readonly instanceId: string;
10
+ /** Human-readable component name */
11
+ readonly name: string;
12
+ /** Logger instance */
13
+ protected readonly logger: Logger;
14
+ /** Whether this component has been initialized */
15
+ protected initialized: boolean;
16
+ /** Whether this component has been disposed */
17
+ protected disposed: boolean;
18
+ constructor(config?: SkipoConfig);
19
+ /** Initialize the component. Call before use. */
20
+ initialize(): Promise<void>;
21
+ /** Override to add custom initialization logic */
22
+ protected onInitialize(): Promise<void>;
23
+ /** Dispose the component and release resources */
24
+ dispose(): Promise<void>;
25
+ /** Override to add custom cleanup logic */
26
+ protected onDispose(): Promise<void>;
27
+ /** Guard: throws if not initialized */
28
+ protected ensureInitialized(): void;
29
+ /** Guard: throws if already disposed */
30
+ protected ensureNotDisposed(): void;
31
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @file cache.ts
3
+ * @description Portable LRU cache, TTL cache, and Stale-While-Revalidate utilities.
4
+ */
5
+ export declare class LRUCache<K, V> {
6
+ private maxSize;
7
+ private cache;
8
+ constructor(maxSize: number);
9
+ get(key: K): V | undefined;
10
+ set(key: K, value: V): void;
11
+ delete(key: K): boolean;
12
+ clear(): void;
13
+ size(): number;
14
+ }
15
+ export declare class TTLCache<K, V> {
16
+ private ttlMs;
17
+ private cache;
18
+ constructor(ttlMs: number);
19
+ get(key: K): V | null;
20
+ set(key: K, value: V): void;
21
+ delete(key: K): boolean;
22
+ clear(): void;
23
+ }
24
+ /**
25
+ * Stale-While-Revalidate utility.
26
+ */
27
+ export declare function swr<K, V>(cache: TTLCache<K, V>, key: K, fetchFn: () => Promise<V>): Promise<V>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @file env-node.ts
3
+ * @description Node-only .env file loading.
4
+ */
5
+ /**
6
+ * Loads a .env file and injects variables into process.env.
7
+ */
8
+ export declare function loadEnv(filePath?: string): void;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @file env.ts
3
+ * @description Runtime-neutral environment value parsing and validation.
4
+ */
5
+ import type { ZodTypeAny } from 'zod';
6
+ export type EnvironmentValues = Record<string, string | undefined>;
7
+ /**
8
+ * Reads an environment value with type coercion and defaults.
9
+ * Worker and browser callers should pass their environment bindings explicitly.
10
+ */
11
+ export declare function getEnv<T>(key: string, defaultValue?: T, env?: EnvironmentValues): T;
12
+ /** Asserts an environment value is set and returns its string value. */
13
+ export declare function requireEnv(key: string, env?: EnvironmentValues): string;
14
+ /** Validates an environment object using a Zod schema. */
15
+ export declare function validateEnvSchema<T extends ZodTypeAny>(zodSchema: T, env?: EnvironmentValues): T['_output'];
16
+ /** Checks if a connection string is a placeholder or template value. */
17
+ export declare function isPlaceholderConnection(url?: string): boolean;
18
+ /** Sanitizes a database URL, returning undefined if it is empty or a placeholder. */
19
+ export declare function sanitizeDatabaseUrl(url?: string): string | undefined;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file events.ts
3
+ * @description Skipo Universal Real-Time Event Bus. Facilitates real-time event broadcasting and streaming.
4
+ */
5
+ export interface RealtimeWorkspaceEvent {
6
+ id: string;
7
+ timestamp: number;
8
+ userId?: string;
9
+ workspaceId?: string;
10
+ source: 'api' | 'ui';
11
+ method?: string;
12
+ endpoint?: string;
13
+ action: 'DOCUMENT_CREATED' | 'DOCUMENT_UPDATED' | 'DOCUMENT_DELETED' | 'CATEGORY_CREATED' | 'CATEGORY_UPDATED' | 'CATEGORY_DELETED' | 'GRAPH_UPDATED' | 'BIOME_CHANGED' | 'WORKSPACE_UPDATED' | 'WORKSPACE_SWITCHED' | 'GENERIC_ACTION' | string;
14
+ details?: string;
15
+ payload?: any;
16
+ }
17
+ export type EventListener = (event: RealtimeWorkspaceEvent) => void;
18
+ /**
19
+ * Publish a new event to all active real-time subscribers and store in buffer.
20
+ */
21
+ export declare function publishRealtimeEvent(eventInput: Omit<RealtimeWorkspaceEvent, 'id' | 'timestamp'> & {
22
+ id?: string;
23
+ timestamp?: number;
24
+ }): RealtimeWorkspaceEvent;
25
+ /**
26
+ * Subscribe to real-time events. Returns an unsubscribe function.
27
+ */
28
+ export declare function subscribeRealtimeEvents(listener: EventListener): () => void;
29
+ /**
30
+ * Retrieve recent events since a specified timestamp, optionally filtered by workspaceId or userId.
31
+ */
32
+ export declare function getRecentEvents(sinceTimestamp?: number, workspaceId?: string, userId?: string): RealtimeWorkspaceEvent[];
@@ -0,0 +1,9 @@
1
+ export declare class FileCache<T> {
2
+ private cacheDir;
3
+ constructor(cacheDir: string);
4
+ private getFilePath;
5
+ get(key: string): T | null;
6
+ set(key: string, value: T): void;
7
+ delete(key: string): void;
8
+ clear(): void;
9
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @file fs-lock.ts
3
+ * @description File locking primitive for atomic file operations.
4
+ */
5
+ export type ReleaseFn = () => void;
6
+ export declare class FileLock {
7
+ private static locks;
8
+ static acquire(filePath: string): Promise<ReleaseFn>;
9
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file fs.ts
3
+ * @description Robust cross-platform filesystem abstraction layer.
4
+ */
5
+ import fs from "fs";
6
+ export declare function readFile(filePath: string, encoding?: BufferEncoding): Promise<string>;
7
+ export declare function writeFile(filePath: string, content: string | Buffer): Promise<void>;
8
+ /**
9
+ * Atomic file writing via temp files.
10
+ */
11
+ export declare function writeFileAtomic(filePath: string, content: string | Buffer): Promise<void>;
12
+ export declare function appendFile(filePath: string, content: string | Buffer): Promise<void>;
13
+ export declare function deleteFile(filePath: string): Promise<void>;
14
+ export declare function fileExists(filePath: string): Promise<boolean>;
15
+ export declare function getFileStat(filePath: string): Promise<{
16
+ size: number;
17
+ createdAt: Date;
18
+ modifiedAt: Date;
19
+ isDir: boolean;
20
+ }>;
21
+ export declare function readJSON<T>(filePath: string): Promise<T | null>;
22
+ export declare function writeJSON(filePath: string, data: unknown, indent?: number): Promise<void>;
23
+ export declare function updateJSON<T>(filePath: string, patch: Partial<T>): Promise<T>;
24
+ export declare function ensureDir(dirPath: string): Promise<void>;
25
+ export declare function deleteDir(dirPath: string, recursive?: boolean): Promise<void>;
26
+ export declare function listDir(dirPath: string): Promise<string[]>;
27
+ export declare function walkDir(dirPath: string, filter?: (file: string) => boolean): AsyncIterable<string>;
28
+ export declare function dirExists(dirPath: string): Promise<boolean>;
29
+ export declare function copyDir(src: string, dest: string): Promise<void>;
30
+ export declare function firstExisting(candidates: string[]): Promise<string | null>;
31
+ export declare function watchFile(filePath: string, handler: (event: string) => void, debounceMs?: number): fs.FSWatcher;
32
+ export declare function watchDir(dirPath: string, handler: (event: string, filename: string | null) => void, debounceMs?: number): fs.FSWatcher;
33
+ export declare function createTempFile(prefix?: string): string;
34
+ export declare function createTempDir(prefix?: string): string;
35
+ export declare function withTempDir<T>(fn: (tempDir: string) => Promise<T>, prefix?: string): Promise<T>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @file http.ts
3
+ * @description Safe, type-safe HTTP client wrapper.
4
+ */
5
+ export interface SkipoHTTPOptions extends RequestInit {
6
+ timeout?: number;
7
+ retries?: number;
8
+ }
9
+ export interface SkipoHTTPResult<T> {
10
+ status: "success" | "error";
11
+ data?: T;
12
+ message?: string;
13
+ code?: number;
14
+ }
15
+ /**
16
+ * Helper to perform fetch with timeout and retries.
17
+ */
18
+ export declare function requestRaw(url: string, opts?: SkipoHTTPOptions): Promise<Response>;
19
+ export declare function request<T>(url: string, opts?: SkipoHTTPOptions): Promise<SkipoHTTPResult<T>>;
20
+ export declare function get<T>(url: string, opts?: SkipoHTTPOptions): Promise<SkipoHTTPResult<T>>;
21
+ export declare function post<T>(url: string, body: any, opts?: SkipoHTTPOptions): Promise<SkipoHTTPResult<T>>;
22
+ export declare function put<T>(url: string, body: any, opts?: SkipoHTTPOptions): Promise<SkipoHTTPResult<T>>;
23
+ export declare function del<T>(url: string, opts?: SkipoHTTPOptions): Promise<SkipoHTTPResult<T>>;
24
+ /**
25
+ * Creates a client instance.
26
+ */
27
+ export declare function createClient(baseUrl: string, defaultHeaders?: Record<string, string>): {
28
+ get: <T>(path: string, opts?: SkipoHTTPOptions) => Promise<SkipoHTTPResult<T>>;
29
+ post: <T>(path: string, body: any, opts?: SkipoHTTPOptions) => Promise<SkipoHTTPResult<T>>;
30
+ put: <T>(path: string, body: any, opts?: SkipoHTTPOptions) => Promise<SkipoHTTPResult<T>>;
31
+ del: <T>(path: string, opts?: SkipoHTTPOptions) => Promise<SkipoHTTPResult<T>>;
32
+ };
33
+ /**
34
+ * Streaming SSE / Chunk response.
35
+ */
36
+ export declare function streamResponse(url: string, opts?: SkipoHTTPOptions): AsyncIterable<string>;
@@ -1,32 +1,30 @@
1
- import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
2
- import { ServiceDefinition } from '@ultrst-armada/krnl';
3
- export { D as Disposable, L as Logger, P as Provider, R as Result, S as SkipoBase, a as SkipoConfig } from './base-DDYO-DzM.js';
4
- export { EnvironmentValues, EventListener, LRUCache, RealtimeWorkspaceEvent, SkipoHTTPOptions, SkipoHTTPResult, TTLCache, createClient, debounce, deepClone, deepEqual, deepMerge, del, get, getEnv, getPath, getRecentEvents, interpolate, isPlaceholderConnection, memoize, objectDiff, once, pLimit, post, prefixedId, publishRealtimeEvent, put, request, requestRaw, requireEnv, retry, sanitizeDatabaseUrl, setPath, shortId, sleep, streamResponse, subscribeRealtimeEvents, swr, throttle, toCamelCase, toKebabCase, toPascalCase, toScreamingSnake, toSlug, toSnakeCase, uuid, validateEnvSchema, withTimeout } from './portable.js';
5
- import 'zod';
6
-
7
- declare const FunctionsServiceDefinition: ServiceDefinition;
8
- declare const FunctionsServiceFacade: {
1
+ /**
2
+ * @file index.ts
3
+ * @description KrnlTS FunctionsServiceFacade plus the portable function library.
4
+ */
5
+ import { type ServiceDefinition } from '@ultrst-armada/krnl';
6
+ export * from './portable.js';
7
+ export declare const FunctionsServiceDefinition: ServiceDefinition;
8
+ export declare const FunctionsServiceFacade: {
9
9
  id: string;
10
10
  name: string;
11
11
  version: string;
12
12
  runtime: "server";
13
13
  deployment: "local";
14
14
  definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
15
- readonly telemetry: _ultrst_armada_krnl.TelemetryController;
16
- createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
15
+ readonly telemetry: import("@ultrst-armada/krnl").TelemetryController;
16
+ createInstance: () => import("@ultrst-armada/krnl").ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
17
17
  execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
18
18
  };
19
- declare const krnlFunctionsServiceDefinition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
20
- declare const krnlFunctionsServiceFacade: {
19
+ export declare const krnlFunctionsServiceDefinition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
20
+ export declare const krnlFunctionsServiceFacade: {
21
21
  id: string;
22
22
  name: string;
23
23
  version: string;
24
24
  runtime: "server";
25
25
  deployment: "local";
26
26
  definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
27
- readonly telemetry: _ultrst_armada_krnl.TelemetryController;
28
- createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
27
+ readonly telemetry: import("@ultrst-armada/krnl").TelemetryController;
28
+ createInstance: () => import("@ultrst-armada/krnl").ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
29
29
  execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
30
30
  };
31
-
32
- export { FunctionsServiceDefinition, FunctionsServiceFacade, krnlFunctionsServiceDefinition, krnlFunctionsServiceFacade };
@@ -1,110 +1,7 @@
1
- export { D as Disposable, L as Logger, P as Provider, R as Result, S as SkipoBase, a as SkipoConfig } from './base-DDYO-DzM.js';
2
- export { EnvironmentValues, EventListener, LRUCache, RealtimeWorkspaceEvent, SkipoHTTPOptions, SkipoHTTPResult, TTLCache, createClient, debounce, deepClone, deepEqual, deepMerge, del, get, getEnv, getPath, getRecentEvents, interpolate, isPlaceholderConnection, memoize, objectDiff, once, pLimit, post, prefixedId, publishRealtimeEvent, put, request, requestRaw, requireEnv, retry, sanitizeDatabaseUrl, setPath, shortId, sleep, streamResponse, subscribeRealtimeEvents, swr, throttle, toCamelCase, toKebabCase, toPascalCase, toScreamingSnake, toSlug, toSnakeCase, uuid, validateEnvSchema, withTimeout } from './portable.js';
3
- import fs from 'fs';
4
- import { ExecOptions, SpawnOptions } from 'child_process';
5
- import 'zod';
6
-
7
- /**
8
- * @file fs-lock.ts
9
- * @description File locking primitive for atomic file operations.
10
- */
11
- type ReleaseFn = () => void;
12
- declare class FileLock {
13
- private static locks;
14
- static acquire(filePath: string): Promise<ReleaseFn>;
15
- }
16
-
17
- /**
18
- * @file fs.ts
19
- * @description Robust cross-platform filesystem abstraction layer.
20
- */
21
-
22
- declare function readFile(filePath: string, encoding?: BufferEncoding): Promise<string>;
23
- declare function writeFile(filePath: string, content: string | Buffer): Promise<void>;
24
- /**
25
- * Atomic file writing via temp files.
26
- */
27
- declare function writeFileAtomic(filePath: string, content: string | Buffer): Promise<void>;
28
- declare function appendFile(filePath: string, content: string | Buffer): Promise<void>;
29
- declare function deleteFile(filePath: string): Promise<void>;
30
- declare function fileExists(filePath: string): Promise<boolean>;
31
- declare function getFileStat(filePath: string): Promise<{
32
- size: number;
33
- createdAt: Date;
34
- modifiedAt: Date;
35
- isDir: boolean;
36
- }>;
37
- declare function readJSON<T>(filePath: string): Promise<T | null>;
38
- declare function writeJSON(filePath: string, data: unknown, indent?: number): Promise<void>;
39
- declare function updateJSON<T>(filePath: string, patch: Partial<T>): Promise<T>;
40
- declare function ensureDir(dirPath: string): Promise<void>;
41
- declare function deleteDir(dirPath: string, recursive?: boolean): Promise<void>;
42
- declare function listDir(dirPath: string): Promise<string[]>;
43
- declare function walkDir(dirPath: string, filter?: (file: string) => boolean): AsyncIterable<string>;
44
- declare function dirExists(dirPath: string): Promise<boolean>;
45
- declare function copyDir(src: string, dest: string): Promise<void>;
46
- declare function firstExisting(candidates: string[]): Promise<string | null>;
47
- declare function watchFile(filePath: string, handler: (event: string) => void, debounceMs?: number): fs.FSWatcher;
48
- declare function watchDir(dirPath: string, handler: (event: string, filename: string | null) => void, debounceMs?: number): fs.FSWatcher;
49
- declare function createTempFile(prefix?: string): string;
50
- declare function createTempDir(prefix?: string): string;
51
- declare function withTempDir<T>(fn: (tempDir: string) => Promise<T>, prefix?: string): Promise<T>;
52
-
53
- /**
54
- * @file shell.ts
55
- * @description Safe promise-based exec and spawn wrappers with cross-platform command routing.
56
- */
57
-
58
- interface SpawnHandle {
59
- pid?: number;
60
- kill: (signal?: NodeJS.Signals | number) => boolean;
61
- promise: Promise<{
62
- code: number | null;
63
- signal: NodeJS.Signals | null;
64
- }>;
65
- }
66
- /**
67
- * Promisified command execution.
68
- */
69
- declare function execCmd(cmd: string, opts?: ExecOptions & {
70
- timeout?: number;
71
- }): Promise<{
72
- stdout: string;
73
- stderr: string;
74
- }>;
75
- /**
76
- * Streaming command execution.
77
- */
78
- declare function spawnCmd(cmd: string, args: string[], opts?: SpawnOptions): SpawnHandle;
79
- /**
80
- * Defines posix vs win32 specific commands.
81
- */
82
- declare function platform<T>(routing: {
83
- posix: T;
84
- win32: T;
85
- }): T;
86
- /**
87
- * Resolves the full path of a binary.
88
- */
89
- declare function which(cmd: string): string | null;
90
-
91
- declare class FileCache<T> {
92
- private cacheDir;
93
- constructor(cacheDir: string);
94
- private getFilePath;
95
- get(key: string): T | null;
96
- set(key: string, value: T): void;
97
- delete(key: string): void;
98
- clear(): void;
99
- }
100
-
101
- /**
102
- * @file env-node.ts
103
- * @description Node-only .env file loading.
104
- */
105
- /**
106
- * Loads a .env file and injects variables into process.env.
107
- */
108
- declare function loadEnv(filePath?: string): void;
109
-
110
- export { FileCache, FileLock, type ReleaseFn, type SpawnHandle, appendFile, copyDir, createTempDir, createTempFile, deleteDir, deleteFile, dirExists, ensureDir, execCmd, fileExists, firstExisting, getFileStat, listDir, loadEnv, platform, readFile, readJSON, spawnCmd, updateJSON, walkDir, watchDir, watchFile, which, withTempDir, writeFile, writeFileAtomic, writeJSON };
1
+ /** Node-only filesystem and process utilities for @ultrst-armada/kloks/functions. */
2
+ export * from './portable.js';
3
+ export * from './fs-lock.js';
4
+ export * from './fs.js';
5
+ export * from './shell.js';
6
+ export * from './fileCache.js';
7
+ export * from './env-node.js';