@epsilon-asi/foundation 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Epsilon ASI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # @epsilon-asi/foundation
2
+
3
+ Shared isomorphic utilities intended for both browser and Node.js consumers.
4
+
5
+ ```ts
6
+ import { createPackageName, ok, unwrapOr } from '@epsilon-asi/foundation';
7
+
8
+ const packageName = createPackageName('epsilon-asi', 'SYSTEM');
9
+ const value = unwrapOr(ok(packageName), '@epsilon-asi/unknown');
10
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ // src/result.ts
4
+ function ok(value) {
5
+ return { ok: true, value };
6
+ }
7
+ function err(error) {
8
+ return { ok: false, error };
9
+ }
10
+ function isOk(result) {
11
+ return result.ok;
12
+ }
13
+ function isErr(result) {
14
+ return !result.ok;
15
+ }
16
+ function mapResult(result, mapper) {
17
+ return isOk(result) ? ok(mapper(result.value)) : result;
18
+ }
19
+ function unwrapOr(result, fallback) {
20
+ return isOk(result) ? result.value : fallback;
21
+ }
22
+
23
+ // src/strings.ts
24
+ function toKebabCase(input) {
25
+ return input.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
26
+ }
27
+ function createPackageName(scope, packageName) {
28
+ const normalizedScope = toKebabCase(scope.replace(/^@/, ""));
29
+ const normalizedPackage = toKebabCase(packageName);
30
+ return `@${normalizedScope}/${normalizedPackage}`;
31
+ }
32
+
33
+ // src/versioning.ts
34
+ function createVersionedName(name, version) {
35
+ const normalizedName = toKebabCase(name);
36
+ return `${normalizedName}@${version}`;
37
+ }
38
+
39
+ exports.createPackageName = createPackageName;
40
+ exports.createVersionedName = createVersionedName;
41
+ exports.err = err;
42
+ exports.isErr = isErr;
43
+ exports.isOk = isOk;
44
+ exports.mapResult = mapResult;
45
+ exports.ok = ok;
46
+ exports.toKebabCase = toKebabCase;
47
+ exports.unwrapOr = unwrapOr;
48
+ //# sourceMappingURL=index.cjs.map
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/result.ts","../src/strings.ts","../src/versioning.ts"],"names":[],"mappings":";;;AAYO,SAAS,GAAM,KAAA,EAAiB;AACrC,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,KAAA,EAAM;AAC3B;AAEO,SAAS,IAAqB,KAAA,EAAkB;AACrD,EAAA,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAM;AAC5B;AAEO,SAAS,KAAyB,MAAA,EAAuC;AAC9E,EAAA,OAAO,MAAA,CAAO,EAAA;AAChB;AAEO,SAAS,MAA0B,MAAA,EAAwC;AAChF,EAAA,OAAO,CAAC,MAAA,CAAO,EAAA;AACjB;AAEO,SAAS,SAAA,CACd,QACA,MAAA,EACc;AACd,EAAA,OAAO,IAAA,CAAK,MAAM,CAAA,GAAI,EAAA,CAAG,OAAO,MAAA,CAAO,KAAK,CAAC,CAAA,GAAI,MAAA;AACnD;AAEO,SAAS,QAAA,CAA6B,QAAsB,QAAA,EAAgB;AACjF,EAAA,OAAO,IAAA,CAAK,MAAM,CAAA,GAAI,MAAA,CAAO,KAAA,GAAQ,QAAA;AACvC;;;ACrCO,SAAS,YAAY,KAAA,EAAuB;AACjD,EAAA,OAAO,MACJ,IAAA,EAAK,CACL,QAAQ,oBAAA,EAAsB,OAAO,EACrC,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA,CACtB,OAAA,CAAQ,OAAO,GAAG,CAAA,CAClB,QAAQ,QAAA,EAAU,EAAE,EACpB,WAAA,EAAY;AACjB;AAEO,SAAS,iBAAA,CAAkB,OAAe,WAAA,EAA6C;AAC5F,EAAA,MAAM,kBAAkB,WAAA,CAAY,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAC,CAAA;AAC3D,EAAA,MAAM,iBAAA,GAAoB,YAAY,WAAW,CAAA;AAEjD,EAAA,OAAO,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA,EAAI,iBAAiB,CAAA,CAAA;AACjD;;;ACbO,SAAS,mBAAA,CAAoB,MAAc,OAAA,EAAyB;AACzE,EAAA,MAAM,cAAA,GAAiB,YAAY,IAAI,CAAA;AACvC,EAAA,OAAO,CAAA,EAAG,cAAc,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA;AACrC","file":"index.cjs","sourcesContent":["export type Ok<T> = Readonly<{\n ok: true;\n value: T;\n}>;\n\nexport type Err<E extends Error = Error> = Readonly<{\n ok: false;\n error: E;\n}>;\n\nexport type Result<T, E extends Error = Error> = Ok<T> | Err<E>;\n\nexport function ok<T>(value: T): Ok<T> {\n return { ok: true, value };\n}\n\nexport function err<E extends Error>(error: E): Err<E> {\n return { ok: false, error };\n}\n\nexport function isOk<T, E extends Error>(result: Result<T, E>): result is Ok<T> {\n return result.ok;\n}\n\nexport function isErr<T, E extends Error>(result: Result<T, E>): result is Err<E> {\n return !result.ok;\n}\n\nexport function mapResult<T, U, E extends Error>(\n result: Result<T, E>,\n mapper: (value: T) => U\n): Result<U, E> {\n return isOk(result) ? ok(mapper(result.value)) : result;\n}\n\nexport function unwrapOr<T, E extends Error>(result: Result<T, E>, fallback: T): T {\n return isOk(result) ? result.value : fallback;\n}\n","export function toKebabCase(input: string): string {\n return input\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n .toLowerCase();\n}\n\nexport function createPackageName(scope: string, packageName: string): `@${string}/${string}` {\n const normalizedScope = toKebabCase(scope.replace(/^@/, ''));\n const normalizedPackage = toKebabCase(packageName);\n\n return `@${normalizedScope}/${normalizedPackage}`;\n}\n","import { toKebabCase } from './strings.js';\n\nexport function createVersionedName(name: string, version: string): string {\n const normalizedName = toKebabCase(name);\n return `${normalizedName}@${version}`;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export type { Err, Ok, Result } from './result.js';
2
+ export { err, isErr, isOk, mapResult, ok, unwrapOr } from './result.js';
3
+ export { createPackageName, toKebabCase } from './strings.js';
4
+ export { createVersionedName } from './versioning.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ // src/result.ts
2
+ function ok(value) {
3
+ return { ok: true, value };
4
+ }
5
+ function err(error) {
6
+ return { ok: false, error };
7
+ }
8
+ function isOk(result) {
9
+ return result.ok;
10
+ }
11
+ function isErr(result) {
12
+ return !result.ok;
13
+ }
14
+ function mapResult(result, mapper) {
15
+ return isOk(result) ? ok(mapper(result.value)) : result;
16
+ }
17
+ function unwrapOr(result, fallback) {
18
+ return isOk(result) ? result.value : fallback;
19
+ }
20
+
21
+ // src/strings.ts
22
+ function toKebabCase(input) {
23
+ return input.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
24
+ }
25
+ function createPackageName(scope, packageName) {
26
+ const normalizedScope = toKebabCase(scope.replace(/^@/, ""));
27
+ const normalizedPackage = toKebabCase(packageName);
28
+ return `@${normalizedScope}/${normalizedPackage}`;
29
+ }
30
+
31
+ // src/versioning.ts
32
+ function createVersionedName(name, version) {
33
+ const normalizedName = toKebabCase(name);
34
+ return `${normalizedName}@${version}`;
35
+ }
36
+
37
+ export { createPackageName, createVersionedName, err, isErr, isOk, mapResult, ok, toKebabCase, unwrapOr };
38
+ //# sourceMappingURL=index.js.map
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/result.ts","../src/strings.ts","../src/versioning.ts"],"names":[],"mappings":";AAYO,SAAS,GAAM,KAAA,EAAiB;AACrC,EAAA,OAAO,EAAE,EAAA,EAAI,IAAA,EAAM,KAAA,EAAM;AAC3B;AAEO,SAAS,IAAqB,KAAA,EAAkB;AACrD,EAAA,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,KAAA,EAAM;AAC5B;AAEO,SAAS,KAAyB,MAAA,EAAuC;AAC9E,EAAA,OAAO,MAAA,CAAO,EAAA;AAChB;AAEO,SAAS,MAA0B,MAAA,EAAwC;AAChF,EAAA,OAAO,CAAC,MAAA,CAAO,EAAA;AACjB;AAEO,SAAS,SAAA,CACd,QACA,MAAA,EACc;AACd,EAAA,OAAO,IAAA,CAAK,MAAM,CAAA,GAAI,EAAA,CAAG,OAAO,MAAA,CAAO,KAAK,CAAC,CAAA,GAAI,MAAA;AACnD;AAEO,SAAS,QAAA,CAA6B,QAAsB,QAAA,EAAgB;AACjF,EAAA,OAAO,IAAA,CAAK,MAAM,CAAA,GAAI,MAAA,CAAO,KAAA,GAAQ,QAAA;AACvC;;;ACrCO,SAAS,YAAY,KAAA,EAAuB;AACjD,EAAA,OAAO,MACJ,IAAA,EAAK,CACL,QAAQ,oBAAA,EAAsB,OAAO,EACrC,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA,CACtB,OAAA,CAAQ,OAAO,GAAG,CAAA,CAClB,QAAQ,QAAA,EAAU,EAAE,EACpB,WAAA,EAAY;AACjB;AAEO,SAAS,iBAAA,CAAkB,OAAe,WAAA,EAA6C;AAC5F,EAAA,MAAM,kBAAkB,WAAA,CAAY,KAAA,CAAM,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAC,CAAA;AAC3D,EAAA,MAAM,iBAAA,GAAoB,YAAY,WAAW,CAAA;AAEjD,EAAA,OAAO,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA,EAAI,iBAAiB,CAAA,CAAA;AACjD;;;ACbO,SAAS,mBAAA,CAAoB,MAAc,OAAA,EAAyB;AACzE,EAAA,MAAM,cAAA,GAAiB,YAAY,IAAI,CAAA;AACvC,EAAA,OAAO,CAAA,EAAG,cAAc,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA;AACrC","file":"index.js","sourcesContent":["export type Ok<T> = Readonly<{\n ok: true;\n value: T;\n}>;\n\nexport type Err<E extends Error = Error> = Readonly<{\n ok: false;\n error: E;\n}>;\n\nexport type Result<T, E extends Error = Error> = Ok<T> | Err<E>;\n\nexport function ok<T>(value: T): Ok<T> {\n return { ok: true, value };\n}\n\nexport function err<E extends Error>(error: E): Err<E> {\n return { ok: false, error };\n}\n\nexport function isOk<T, E extends Error>(result: Result<T, E>): result is Ok<T> {\n return result.ok;\n}\n\nexport function isErr<T, E extends Error>(result: Result<T, E>): result is Err<E> {\n return !result.ok;\n}\n\nexport function mapResult<T, U, E extends Error>(\n result: Result<T, E>,\n mapper: (value: T) => U\n): Result<U, E> {\n return isOk(result) ? ok(mapper(result.value)) : result;\n}\n\nexport function unwrapOr<T, E extends Error>(result: Result<T, E>, fallback: T): T {\n return isOk(result) ? result.value : fallback;\n}\n","export function toKebabCase(input: string): string {\n return input\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n .toLowerCase();\n}\n\nexport function createPackageName(scope: string, packageName: string): `@${string}/${string}` {\n const normalizedScope = toKebabCase(scope.replace(/^@/, ''));\n const normalizedPackage = toKebabCase(packageName);\n\n return `@${normalizedScope}/${normalizedPackage}`;\n}\n","import { toKebabCase } from './strings.js';\n\nexport function createVersionedName(name: string, version: string): string {\n const normalizedName = toKebabCase(name);\n return `${normalizedName}@${version}`;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ export type Ok<T> = Readonly<{
2
+ ok: true;
3
+ value: T;
4
+ }>;
5
+ export type Err<E extends Error = Error> = Readonly<{
6
+ ok: false;
7
+ error: E;
8
+ }>;
9
+ export type Result<T, E extends Error = Error> = Ok<T> | Err<E>;
10
+ export declare function ok<T>(value: T): Ok<T>;
11
+ export declare function err<E extends Error>(error: E): Err<E>;
12
+ export declare function isOk<T, E extends Error>(result: Result<T, E>): result is Ok<T>;
13
+ export declare function isErr<T, E extends Error>(result: Result<T, E>): result is Err<E>;
14
+ export declare function mapResult<T, U, E extends Error>(result: Result<T, E>, mapper: (value: T) => U): Result<U, E>;
15
+ export declare function unwrapOr<T, E extends Error>(result: Result<T, E>, fallback: T): T;
16
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI,QAAQ,CAAC;IAC3B,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;CACV,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,IAAI,QAAQ,CAAC;IAClD,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,CAAC,CAAC;CACV,CAAC,CAAC;AAEH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAEhE,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAErC;AAED,wBAAgB,GAAG,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAErD;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAE9E;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAEhF;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,KAAK,EAC7C,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GACtB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAEd;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAEjF"}
@@ -0,0 +1,3 @@
1
+ export declare function toKebabCase(input: string): string;
2
+ export declare function createPackageName(scope: string, packageName: string): `@${string}/${string}`;
3
+ //# sourceMappingURL=strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../src/strings.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,MAAM,IAAI,MAAM,EAAE,CAK5F"}
@@ -0,0 +1,2 @@
1
+ export declare function createVersionedName(name: string, version: string): string;
2
+ //# sourceMappingURL=versioning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGzE"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@epsilon-asi/foundation",
3
+ "version": "0.1.0",
4
+ "description": "Isomorphic shared primitives for Epsilon ASI browser and backend packages.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "build": "tsup && tsc -p tsconfig.build.json",
28
+ "clean": "rimraf dist coverage",
29
+ "typecheck": "tsc --noEmit -p tsconfig.json",
30
+ "test": "vitest run",
31
+ "test:unit": "vitest run test/unit",
32
+ "test:integration": "vitest run test/integration",
33
+ "test:coverage": "vitest run --coverage"
34
+ }
35
+ }