@almadar/operators 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 +72 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +99 -0
- package/operators.json +1406 -0
- package/package.json +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: Almadar FZE
|
|
6
|
+
Licensed Work: KFlow Builder / Almadar
|
|
7
|
+
The Licensed Work is (c) 2025-2026 Almadar FZE.
|
|
8
|
+
Additional Use Grant: You may make production use of the Licensed Work for
|
|
9
|
+
non-commercial purposes and for internal evaluation.
|
|
10
|
+
Production use for commercial purposes requires a
|
|
11
|
+
commercial license from the Licensor.
|
|
12
|
+
Change Date: 2030-02-01
|
|
13
|
+
Change License: Apache License, Version 2.0
|
|
14
|
+
|
|
15
|
+
Terms
|
|
16
|
+
|
|
17
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
18
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
19
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
20
|
+
production use.
|
|
21
|
+
|
|
22
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
23
|
+
available distribution of a specific version of the Licensed Work under this
|
|
24
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
25
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
26
|
+
above terminate.
|
|
27
|
+
|
|
28
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
29
|
+
currently in effect as described in this License, you must purchase a
|
|
30
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
31
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
32
|
+
|
|
33
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
34
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
35
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
36
|
+
for each version of the Licensed Work released by Licensor.
|
|
37
|
+
|
|
38
|
+
You must conspicuously display this License on each original or modified copy
|
|
39
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
40
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
41
|
+
License apply to your use of that work.
|
|
42
|
+
|
|
43
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
44
|
+
terminate your rights under this License for the current and all other
|
|
45
|
+
versions of the Licensed Work.
|
|
46
|
+
|
|
47
|
+
This License does not grant you any right in any trademark or logo of
|
|
48
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
49
|
+
Licensor as expressly required by this License).
|
|
50
|
+
|
|
51
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
52
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
53
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
54
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
55
|
+
TITLE.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
60
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
61
|
+
|
|
62
|
+
ADDITIONAL TERMS:
|
|
63
|
+
|
|
64
|
+
Documentation (builder/packages/website/docs/) is licensed under CC BY 4.0.
|
|
65
|
+
|
|
66
|
+
TRADEMARKS:
|
|
67
|
+
|
|
68
|
+
"Orbital", "KFlow", "Almadar", and the Almadar logo are trademarks of
|
|
69
|
+
Almadar FZE. You may not use these trademarks without prior written
|
|
70
|
+
permission from Almadar FZE.
|
|
71
|
+
|
|
72
|
+
For licensing inquiries: licensing@almadar.io
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Almadar Operators - Single Source of Truth
|
|
3
|
+
*
|
|
4
|
+
* This package defines all S-expression operators used across:
|
|
5
|
+
* - almadar-core (TypeScript types)
|
|
6
|
+
* - almadar-evaluator (TypeScript runtime)
|
|
7
|
+
* - almadar-std (TypeScript metadata)
|
|
8
|
+
* - orbital-rust (Rust evaluator)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export type OperatorCategory = 'arithmetic' | 'comparison' | 'logic' | 'control' | 'effect' | 'collection' | 'std-math' | 'std-str' | 'std-array' | 'std-object' | 'std-time' | 'std-validate' | 'std-format' | 'std-async' | 'std-nn' | 'std-tensor' | 'std-train';
|
|
13
|
+
export type TargetPlatform = 'ts' | 'rust' | 'python';
|
|
14
|
+
export interface CategoryMeta {
|
|
15
|
+
description: string;
|
|
16
|
+
target: TargetPlatform[];
|
|
17
|
+
}
|
|
18
|
+
export interface OperatorMeta {
|
|
19
|
+
category: OperatorCategory;
|
|
20
|
+
minArity: number;
|
|
21
|
+
maxArity: number | null;
|
|
22
|
+
returnType: string;
|
|
23
|
+
description: string;
|
|
24
|
+
hasSideEffects?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface OperatorsSchema {
|
|
27
|
+
version: string;
|
|
28
|
+
description: string;
|
|
29
|
+
categories: Record<string, CategoryMeta>;
|
|
30
|
+
operators: Record<string, OperatorMeta>;
|
|
31
|
+
}
|
|
32
|
+
/** The canonical operators schema */
|
|
33
|
+
export declare const OPERATORS_SCHEMA: OperatorsSchema;
|
|
34
|
+
/** All operator definitions */
|
|
35
|
+
export declare const OPERATORS: Record<string, OperatorMeta>;
|
|
36
|
+
/** All category definitions */
|
|
37
|
+
export declare const CATEGORIES: Record<string, CategoryMeta>;
|
|
38
|
+
/** All operator names */
|
|
39
|
+
export declare const OPERATOR_NAMES: string[];
|
|
40
|
+
/** Get operator metadata */
|
|
41
|
+
export declare function getOperatorMeta(name: string): OperatorMeta | undefined;
|
|
42
|
+
/** Check if operator exists */
|
|
43
|
+
export declare function isKnownOperator(name: string): boolean;
|
|
44
|
+
/** Check if operator has side effects */
|
|
45
|
+
export declare function isEffectOperator(name: string): boolean;
|
|
46
|
+
/** Check if operator can be used in guards (no side effects) */
|
|
47
|
+
export declare function isGuardOperator(name: string): boolean;
|
|
48
|
+
/** Get all operators in a category */
|
|
49
|
+
export declare function getOperatorsByCategory(category: OperatorCategory): string[];
|
|
50
|
+
/** Get operators for a target platform */
|
|
51
|
+
export declare function getOperatorsForTarget(target: TargetPlatform): string[];
|
|
52
|
+
/** Validate operator arity */
|
|
53
|
+
export declare function validateOperatorArity(name: string, argCount: number): string | null;
|
|
54
|
+
export interface OperatorStats {
|
|
55
|
+
total: number;
|
|
56
|
+
byCategory: Record<string, number>;
|
|
57
|
+
byTarget: Record<TargetPlatform, number>;
|
|
58
|
+
withSideEffects: number;
|
|
59
|
+
}
|
|
60
|
+
export declare function getOperatorStats(): OperatorStats;
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH,MAAM,MAAM,gBAAgB,GACtB,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,UAAU,GACV,SAAS,GACT,WAAW,GACX,YAAY,GACZ,UAAU,GACV,cAAc,GACd,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,WAAW,CAAC;AAElB,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,MAAM,WAAW,YAAY;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC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,GACjB,MAAM,GAAG,IAAI,CAaf;AAMD,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACzC,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CA2BhD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Almadar Operators - Single Source of Truth
|
|
3
|
+
*
|
|
4
|
+
* This package defines all S-expression operators used across:
|
|
5
|
+
* - almadar-core (TypeScript types)
|
|
6
|
+
* - almadar-evaluator (TypeScript runtime)
|
|
7
|
+
* - almadar-std (TypeScript metadata)
|
|
8
|
+
* - orbital-rust (Rust evaluator)
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync } from 'fs';
|
|
13
|
+
import { dirname, join } from 'path';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const operatorsPath = join(__dirname, '..', 'operators.json');
|
|
17
|
+
const operators = JSON.parse(readFileSync(operatorsPath, 'utf-8'));
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Exports
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/** The canonical operators schema */
|
|
22
|
+
export const OPERATORS_SCHEMA = operators;
|
|
23
|
+
/** All operator definitions */
|
|
24
|
+
export const OPERATORS = OPERATORS_SCHEMA.operators;
|
|
25
|
+
/** All category definitions */
|
|
26
|
+
export const CATEGORIES = OPERATORS_SCHEMA.categories;
|
|
27
|
+
/** All operator names */
|
|
28
|
+
export const OPERATOR_NAMES = Object.keys(OPERATORS);
|
|
29
|
+
/** Get operator metadata */
|
|
30
|
+
export function getOperatorMeta(name) {
|
|
31
|
+
return OPERATORS[name];
|
|
32
|
+
}
|
|
33
|
+
/** Check if operator exists */
|
|
34
|
+
export function isKnownOperator(name) {
|
|
35
|
+
return name in OPERATORS;
|
|
36
|
+
}
|
|
37
|
+
/** Check if operator has side effects */
|
|
38
|
+
export function isEffectOperator(name) {
|
|
39
|
+
const meta = OPERATORS[name];
|
|
40
|
+
return meta?.hasSideEffects === true;
|
|
41
|
+
}
|
|
42
|
+
/** Check if operator can be used in guards (no side effects) */
|
|
43
|
+
export function isGuardOperator(name) {
|
|
44
|
+
const meta = OPERATORS[name];
|
|
45
|
+
return meta !== undefined && !meta.hasSideEffects;
|
|
46
|
+
}
|
|
47
|
+
/** Get all operators in a category */
|
|
48
|
+
export function getOperatorsByCategory(category) {
|
|
49
|
+
return Object.entries(OPERATORS)
|
|
50
|
+
.filter(([_, meta]) => meta.category === category)
|
|
51
|
+
.map(([name]) => name);
|
|
52
|
+
}
|
|
53
|
+
/** Get operators for a target platform */
|
|
54
|
+
export function getOperatorsForTarget(target) {
|
|
55
|
+
return Object.entries(OPERATORS)
|
|
56
|
+
.filter(([_, meta]) => {
|
|
57
|
+
const cat = CATEGORIES[meta.category];
|
|
58
|
+
return cat?.target.includes(target);
|
|
59
|
+
})
|
|
60
|
+
.map(([name]) => name);
|
|
61
|
+
}
|
|
62
|
+
/** Validate operator arity */
|
|
63
|
+
export function validateOperatorArity(name, argCount) {
|
|
64
|
+
const meta = OPERATORS[name];
|
|
65
|
+
if (!meta)
|
|
66
|
+
return `Unknown operator: ${name}`;
|
|
67
|
+
if (argCount < meta.minArity) {
|
|
68
|
+
return `Operator '${name}' requires at least ${meta.minArity} argument(s), got ${argCount}`;
|
|
69
|
+
}
|
|
70
|
+
if (meta.maxArity !== null && argCount > meta.maxArity) {
|
|
71
|
+
return `Operator '${name}' accepts at most ${meta.maxArity} argument(s), got ${argCount}`;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
export function getOperatorStats() {
|
|
76
|
+
const byCategory = {};
|
|
77
|
+
const byTarget = { ts: 0, rust: 0, python: 0 };
|
|
78
|
+
let withSideEffects = 0;
|
|
79
|
+
for (const [name, meta] of Object.entries(OPERATORS)) {
|
|
80
|
+
// By category
|
|
81
|
+
byCategory[meta.category] = (byCategory[meta.category] || 0) + 1;
|
|
82
|
+
// By target
|
|
83
|
+
const cat = CATEGORIES[meta.category];
|
|
84
|
+
if (cat) {
|
|
85
|
+
for (const target of cat.target) {
|
|
86
|
+
byTarget[target]++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Side effects
|
|
90
|
+
if (meta.hasSideEffects)
|
|
91
|
+
withSideEffects++;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
total: OPERATOR_NAMES.length,
|
|
95
|
+
byCategory,
|
|
96
|
+
byTarget,
|
|
97
|
+
withSideEffects,
|
|
98
|
+
};
|
|
99
|
+
}
|