@niscorp/prism 0.2.0 → 0.2.1
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/CHANGELOG.md +28 -0
- package/DESIGN.md +2 -1
- package/DOCS.md +29 -0
- package/README.md +49 -3
- package/dist/agent.js +2 -2
- package/dist/{chunk-BRIXDNJQ.js → chunk-O3OJAQWA.js} +3 -3
- package/dist/chunk-O3OJAQWA.js.map +1 -0
- package/dist/{chunk-3GAYBBNH.js → chunk-VC4PRB4H.js} +21 -4
- package/dist/chunk-VC4PRB4H.js.map +1 -0
- package/dist/{chunk-3PYQITGE.js → chunk-XRK55NPE.js} +3 -3
- package/dist/{chunk-3PYQITGE.js.map → chunk-XRK55NPE.js.map} +1 -1
- package/dist/examples/index.cjs +1543 -0
- package/dist/examples/index.cjs.map +1 -0
- package/dist/examples/index.d.cts +26 -0
- package/dist/examples/index.d.ts +26 -0
- package/dist/examples/index.js +1540 -0
- package/dist/examples/index.js.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -82
- package/dist/index.d.ts +5 -82
- package/dist/index.js +5 -5
- package/dist/migrations/index.cjs +17 -15
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/migrations/index.d.cts +3 -2
- package/dist/migrations/index.d.ts +3 -2
- package/dist/migrations/index.js +3 -18
- package/dist/migrations/index.js.map +1 -1
- package/dist/profiles-C6r-x-Vj.d.cts +83 -0
- package/dist/profiles-C6r-x-Vj.d.ts +83 -0
- package/dist/transform-DcVcOBzQ.d.cts +3 -0
- package/dist/transform-DcVcOBzQ.d.ts +3 -0
- package/package.json +19 -8
- package/dist/chunk-3GAYBBNH.js.map +0 -1
- package/dist/chunk-BRIXDNJQ.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,80 +1,9 @@
|
|
|
1
|
+
import { J as JsonValue, L as Limits, R as Result, C as CompileOptions, a as CompiledIr, b as JsonObject, V as ValidationResult, O as OpKey } from './profiles-C6r-x-Vj.cjs';
|
|
2
|
+
export { D as DEFAULT_LIMITS, E as EvalContext, c as JsonPrimitive, M as MAPPING_OPS, N as NodeSchema, d as OP_KEYS, e as OptimizationStats, f as ValidationIssue } from './profiles-C6r-x-Vj.cjs';
|
|
1
3
|
import { C as Config } from './config.schema-vy-_YxHP.cjs';
|
|
2
4
|
export { a as ConfigSchema } from './config.schema-vy-_YxHP.cjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type Limits = {
|
|
6
|
-
maxSteps: number;
|
|
7
|
-
maxStringLength: number;
|
|
8
|
-
maxValues: number;
|
|
9
|
-
};
|
|
10
|
-
declare const DEFAULT_LIMITS: Limits;
|
|
11
|
-
type Budget = {
|
|
12
|
-
readonly limits: Limits;
|
|
13
|
-
steps: number;
|
|
14
|
-
readonly sizes: WeakMap<object, number>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
18
|
-
type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
19
|
-
type JsonObject = {
|
|
20
|
-
[key: string]: JsonValue;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type EvalContext = {
|
|
24
|
-
readonly source: JsonValue;
|
|
25
|
-
readonly vars: Record<string, JsonValue>;
|
|
26
|
-
readonly budget?: Budget;
|
|
27
|
-
};
|
|
28
|
-
type Result<T> = {
|
|
29
|
-
ok: true;
|
|
30
|
-
data: T;
|
|
31
|
-
} | {
|
|
32
|
-
ok: false;
|
|
33
|
-
error: Error;
|
|
34
|
-
};
|
|
35
|
-
type CompileOptions = {
|
|
36
|
-
name?: string;
|
|
37
|
-
version?: string;
|
|
38
|
-
};
|
|
39
|
-
type OptimizationStats = {
|
|
40
|
-
refsInlined: number;
|
|
41
|
-
handlersAttached: number;
|
|
42
|
-
constantsFolded: number;
|
|
43
|
-
};
|
|
44
|
-
type CompiledIr = {
|
|
45
|
-
irVersion: 1;
|
|
46
|
-
compiler: {
|
|
47
|
-
name: string;
|
|
48
|
-
version: string;
|
|
49
|
-
};
|
|
50
|
-
meta: {
|
|
51
|
-
name?: string;
|
|
52
|
-
createdAt: string;
|
|
53
|
-
fingerprint: string;
|
|
54
|
-
stats: {
|
|
55
|
-
nodeCount: number;
|
|
56
|
-
opCount: Record<string, number>;
|
|
57
|
-
maxDepth: number;
|
|
58
|
-
optimizations: OptimizationStats;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
tables: {
|
|
62
|
-
paths: string[];
|
|
63
|
-
strings: string[];
|
|
64
|
-
};
|
|
65
|
-
core: unknown;
|
|
66
|
-
};
|
|
67
|
-
type ValidationIssue = {
|
|
68
|
-
path: (string | number)[];
|
|
69
|
-
message: string;
|
|
70
|
-
};
|
|
71
|
-
type ValidationResult = {
|
|
72
|
-
ok: true;
|
|
73
|
-
data: unknown;
|
|
74
|
-
} | {
|
|
75
|
-
ok: false;
|
|
76
|
-
issues: ValidationIssue[];
|
|
77
|
-
};
|
|
5
|
+
export { p as prismTransform } from './transform-DcVcOBzQ.cjs';
|
|
6
|
+
import 'zod';
|
|
78
7
|
|
|
79
8
|
declare const evaluate: (config: Config, source: JsonValue, limits?: Partial<Limits>) => JsonValue;
|
|
80
9
|
declare const evaluateSafe: (config: Config, source: JsonValue, limits?: Partial<Limits>) => Result<JsonValue>;
|
|
@@ -85,12 +14,6 @@ declare const execute: (ir: CompiledIr, source: JsonObject, limits?: Partial<Lim
|
|
|
85
14
|
|
|
86
15
|
declare const validate: (config: unknown) => ValidationResult;
|
|
87
16
|
|
|
88
|
-
declare const OP_KEYS: readonly ["$ref", "$const", "$var", "$get", "$with", "$map", "$filter", "$reduce", "$slice", "$flatten", "$unique", "$sortBy", "$add", "$sub", "$mul", "$div", "$round", "$fill", "$join", "$toString", "$interpolate", "$trim", "$lower", "$upper", "$split", "$replace", "$eq", "$neq", "$gt", "$gte", "$lt", "$lte", "$empty", "$startsWith", "$endsWith", "$contains", "$not", "$and", "$or", "$merge", "$coalesce", "$case", "$entriesOf", "$keyBy", "$groupBy", "$keys", "$values", "$fromEntries", "$pick", "$omit", "$type", "$length", "$date", "$dateAdd", "$dateDiff", "$localeDate", "$localeMoney", "$localeNumber", "$sum", "$avg", "$count", "$min", "$max", "$pluck", "$take", "$drop", "$match", "$flatMap", "$has", "$renameKeys", "$update", "$assert", "$walk"];
|
|
89
|
-
declare const NodeSchema: z.ZodType<unknown>;
|
|
90
|
-
|
|
91
|
-
type OpKey = (typeof OP_KEYS)[number];
|
|
92
|
-
declare const MAPPING_OPS: readonly OpKey[];
|
|
93
|
-
|
|
94
17
|
type JsonSchemaTarget = 'draft-2020-12' | 'draft-7' | 'draft-4';
|
|
95
18
|
declare const getNodeJsonSchema: (target?: JsonSchemaTarget) => object;
|
|
96
19
|
declare const getConfigJsonSchema: (target?: JsonSchemaTarget) => object;
|
|
@@ -119,4 +42,4 @@ declare class PrismError extends Error {
|
|
|
119
42
|
constructor(message: string, code: ErrorCode, context?: PrismErrorContext);
|
|
120
43
|
}
|
|
121
44
|
|
|
122
|
-
export {
|
|
45
|
+
export { CompileOptions, CompiledIr, Config, ErrorCode, JsonObject, type JsonSchemaTarget, JsonValue, Limits, OpKey, PrismError, type PrismErrorContext, Result, ValidationResult, compile, evaluate, evaluateSafe, execute, getConfigJsonSchema, getNodeJsonSchema, getProfileJsonSchema, validate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,80 +1,9 @@
|
|
|
1
|
+
import { J as JsonValue, L as Limits, R as Result, C as CompileOptions, a as CompiledIr, b as JsonObject, V as ValidationResult, O as OpKey } from './profiles-C6r-x-Vj.js';
|
|
2
|
+
export { D as DEFAULT_LIMITS, E as EvalContext, c as JsonPrimitive, M as MAPPING_OPS, N as NodeSchema, d as OP_KEYS, e as OptimizationStats, f as ValidationIssue } from './profiles-C6r-x-Vj.js';
|
|
1
3
|
import { C as Config } from './config.schema-vy-_YxHP.js';
|
|
2
4
|
export { a as ConfigSchema } from './config.schema-vy-_YxHP.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type Limits = {
|
|
6
|
-
maxSteps: number;
|
|
7
|
-
maxStringLength: number;
|
|
8
|
-
maxValues: number;
|
|
9
|
-
};
|
|
10
|
-
declare const DEFAULT_LIMITS: Limits;
|
|
11
|
-
type Budget = {
|
|
12
|
-
readonly limits: Limits;
|
|
13
|
-
steps: number;
|
|
14
|
-
readonly sizes: WeakMap<object, number>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
18
|
-
type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
19
|
-
type JsonObject = {
|
|
20
|
-
[key: string]: JsonValue;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type EvalContext = {
|
|
24
|
-
readonly source: JsonValue;
|
|
25
|
-
readonly vars: Record<string, JsonValue>;
|
|
26
|
-
readonly budget?: Budget;
|
|
27
|
-
};
|
|
28
|
-
type Result<T> = {
|
|
29
|
-
ok: true;
|
|
30
|
-
data: T;
|
|
31
|
-
} | {
|
|
32
|
-
ok: false;
|
|
33
|
-
error: Error;
|
|
34
|
-
};
|
|
35
|
-
type CompileOptions = {
|
|
36
|
-
name?: string;
|
|
37
|
-
version?: string;
|
|
38
|
-
};
|
|
39
|
-
type OptimizationStats = {
|
|
40
|
-
refsInlined: number;
|
|
41
|
-
handlersAttached: number;
|
|
42
|
-
constantsFolded: number;
|
|
43
|
-
};
|
|
44
|
-
type CompiledIr = {
|
|
45
|
-
irVersion: 1;
|
|
46
|
-
compiler: {
|
|
47
|
-
name: string;
|
|
48
|
-
version: string;
|
|
49
|
-
};
|
|
50
|
-
meta: {
|
|
51
|
-
name?: string;
|
|
52
|
-
createdAt: string;
|
|
53
|
-
fingerprint: string;
|
|
54
|
-
stats: {
|
|
55
|
-
nodeCount: number;
|
|
56
|
-
opCount: Record<string, number>;
|
|
57
|
-
maxDepth: number;
|
|
58
|
-
optimizations: OptimizationStats;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
tables: {
|
|
62
|
-
paths: string[];
|
|
63
|
-
strings: string[];
|
|
64
|
-
};
|
|
65
|
-
core: unknown;
|
|
66
|
-
};
|
|
67
|
-
type ValidationIssue = {
|
|
68
|
-
path: (string | number)[];
|
|
69
|
-
message: string;
|
|
70
|
-
};
|
|
71
|
-
type ValidationResult = {
|
|
72
|
-
ok: true;
|
|
73
|
-
data: unknown;
|
|
74
|
-
} | {
|
|
75
|
-
ok: false;
|
|
76
|
-
issues: ValidationIssue[];
|
|
77
|
-
};
|
|
5
|
+
export { p as prismTransform } from './transform-DcVcOBzQ.js';
|
|
6
|
+
import 'zod';
|
|
78
7
|
|
|
79
8
|
declare const evaluate: (config: Config, source: JsonValue, limits?: Partial<Limits>) => JsonValue;
|
|
80
9
|
declare const evaluateSafe: (config: Config, source: JsonValue, limits?: Partial<Limits>) => Result<JsonValue>;
|
|
@@ -85,12 +14,6 @@ declare const execute: (ir: CompiledIr, source: JsonObject, limits?: Partial<Lim
|
|
|
85
14
|
|
|
86
15
|
declare const validate: (config: unknown) => ValidationResult;
|
|
87
16
|
|
|
88
|
-
declare const OP_KEYS: readonly ["$ref", "$const", "$var", "$get", "$with", "$map", "$filter", "$reduce", "$slice", "$flatten", "$unique", "$sortBy", "$add", "$sub", "$mul", "$div", "$round", "$fill", "$join", "$toString", "$interpolate", "$trim", "$lower", "$upper", "$split", "$replace", "$eq", "$neq", "$gt", "$gte", "$lt", "$lte", "$empty", "$startsWith", "$endsWith", "$contains", "$not", "$and", "$or", "$merge", "$coalesce", "$case", "$entriesOf", "$keyBy", "$groupBy", "$keys", "$values", "$fromEntries", "$pick", "$omit", "$type", "$length", "$date", "$dateAdd", "$dateDiff", "$localeDate", "$localeMoney", "$localeNumber", "$sum", "$avg", "$count", "$min", "$max", "$pluck", "$take", "$drop", "$match", "$flatMap", "$has", "$renameKeys", "$update", "$assert", "$walk"];
|
|
89
|
-
declare const NodeSchema: z.ZodType<unknown>;
|
|
90
|
-
|
|
91
|
-
type OpKey = (typeof OP_KEYS)[number];
|
|
92
|
-
declare const MAPPING_OPS: readonly OpKey[];
|
|
93
|
-
|
|
94
17
|
type JsonSchemaTarget = 'draft-2020-12' | 'draft-7' | 'draft-4';
|
|
95
18
|
declare const getNodeJsonSchema: (target?: JsonSchemaTarget) => object;
|
|
96
19
|
declare const getConfigJsonSchema: (target?: JsonSchemaTarget) => object;
|
|
@@ -119,4 +42,4 @@ declare class PrismError extends Error {
|
|
|
119
42
|
constructor(message: string, code: ErrorCode, context?: PrismErrorContext);
|
|
120
43
|
}
|
|
121
44
|
|
|
122
|
-
export {
|
|
45
|
+
export { CompileOptions, CompiledIr, Config, ErrorCode, JsonObject, type JsonSchemaTarget, JsonValue, Limits, OpKey, PrismError, type PrismErrorContext, Result, ValidationResult, compile, evaluate, evaluateSafe, execute, getConfigJsonSchema, getNodeJsonSchema, getProfileJsonSchema, validate };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { MAPPING_OPS, getConfigJsonSchema, getNodeJsonSchema, getProfileJsonSchema } from './chunk-
|
|
2
|
-
import { PrismError, ErrorCode, explainIssues, desugar, primeJsonPathCache, createBudget, evaluateNode, measure, parseJsonPath, opConst, opRef, opVar, opGet, opWith, opMap, opFilter, opReduce, opSlice, opFlatten, opUnique, opSortBy, opAdd, opSub, opMul, opDiv, opRound, opJoin, opToString, opInterpolate, opFill, opTrim, opLower, opUpper, opSplit, opReplace, opEq, opNeq, opGt, opGte, opLt, opLte, opEmpty, opStartsWith, opEndsWith, opContains, opNot, opAnd, opOr, opMerge, opCoalesce, opCase, opEntriesOf, opKeyBy, opGroupBy, opKeys, opValues, opFromEntries, opPick, opOmit, opType, opLength, opHas, opRenameKeys, opUpdate, opAssert, opWalk, opDate, opDateAdd, opDateDiff, opLocaleDate, opLocaleMoney, opLocaleNumber } from './chunk-
|
|
3
|
-
export { DEFAULT_LIMITS, ErrorCode, PrismError, evaluate, evaluateSafe } from './chunk-
|
|
4
|
-
import { ConfigSchema, isJsonObject, isConstNode, isRefNode, isVarNode, isGetNode, isWithNode, isMapNode, isFilterNode, isReduceNode, isSliceNode, isFlattenNode, isUniqueNode, isSortByNode, isAddNode, isSubNode, isMulNode, isDivNode, isRoundNode, isJoinNode, isToStringNode, isInterpolateNode, isFillNode, isTrimNode, isLowerNode, isUpperNode, isSplitNode, isReplaceNode, isEqNode, isNeqNode, isGtNode, isGteNode, isLtNode, isLteNode, isEmptyNode, isStartsWithNode, isEndsWithNode, isContainsNode, isNotNode, isAndNode, isOrNode, isMergeNode, isCoalesceNode, isCaseNode, isEntriesOfNode, isKeyByNode, isGroupByNode, isKeysNode, isValuesNode, isFromEntriesNode, isPickNode, isOmitNode, isTypeNode, isLengthNode, isHasNode, isRenameKeysNode, isUpdateNode, isAssertNode, isWalkNode, isDateNode, isDateAddNode, isDateDiffNode, isLocaleDateNode, isLocaleMoneyNode, isLocaleNumberNode } from './chunk-
|
|
5
|
-
export { ConfigSchema, NodeSchema } from './chunk-
|
|
1
|
+
export { MAPPING_OPS, getConfigJsonSchema, getNodeJsonSchema, getProfileJsonSchema } from './chunk-XRK55NPE.js';
|
|
2
|
+
import { PrismError, ErrorCode, explainIssues, desugar, primeJsonPathCache, createBudget, evaluateNode, measure, parseJsonPath, opConst, opRef, opVar, opGet, opWith, opMap, opFilter, opReduce, opSlice, opFlatten, opUnique, opSortBy, opAdd, opSub, opMul, opDiv, opRound, opJoin, opToString, opInterpolate, opFill, opTrim, opLower, opUpper, opSplit, opReplace, opEq, opNeq, opGt, opGte, opLt, opLte, opEmpty, opStartsWith, opEndsWith, opContains, opNot, opAnd, opOr, opMerge, opCoalesce, opCase, opEntriesOf, opKeyBy, opGroupBy, opKeys, opValues, opFromEntries, opPick, opOmit, opType, opLength, opHas, opRenameKeys, opUpdate, opAssert, opWalk, opDate, opDateAdd, opDateDiff, opLocaleDate, opLocaleMoney, opLocaleNumber } from './chunk-VC4PRB4H.js';
|
|
3
|
+
export { DEFAULT_LIMITS, ErrorCode, PrismError, evaluate, evaluateSafe, prismTransform } from './chunk-VC4PRB4H.js';
|
|
4
|
+
import { ConfigSchema, isJsonObject, isConstNode, isRefNode, isVarNode, isGetNode, isWithNode, isMapNode, isFilterNode, isReduceNode, isSliceNode, isFlattenNode, isUniqueNode, isSortByNode, isAddNode, isSubNode, isMulNode, isDivNode, isRoundNode, isJoinNode, isToStringNode, isInterpolateNode, isFillNode, isTrimNode, isLowerNode, isUpperNode, isSplitNode, isReplaceNode, isEqNode, isNeqNode, isGtNode, isGteNode, isLtNode, isLteNode, isEmptyNode, isStartsWithNode, isEndsWithNode, isContainsNode, isNotNode, isAndNode, isOrNode, isMergeNode, isCoalesceNode, isCaseNode, isEntriesOfNode, isKeyByNode, isGroupByNode, isKeysNode, isValuesNode, isFromEntriesNode, isPickNode, isOmitNode, isTypeNode, isLengthNode, isHasNode, isRenameKeysNode, isUpdateNode, isAssertNode, isWalkNode, isDateNode, isDateAddNode, isDateDiffNode, isLocaleDateNode, isLocaleMoneyNode, isLocaleNumberNode } from './chunk-O3OJAQWA.js';
|
|
5
|
+
export { ConfigSchema, NodeSchema, OP_KEYS } from './chunk-O3OJAQWA.js';
|
|
6
6
|
import { exceedsDepth, depthRefusal } from '@niscorp/strata';
|
|
7
7
|
|
|
8
8
|
// src/engine/optimize.ts
|
|
@@ -1759,6 +1759,23 @@ var evaluate = (config, source, limits) => {
|
|
|
1759
1759
|
return result;
|
|
1760
1760
|
};
|
|
1761
1761
|
|
|
1762
|
+
// src/engine/transform.ts
|
|
1763
|
+
var isJsonValue = (value) => {
|
|
1764
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
1765
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
1766
|
+
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
1767
|
+
if (typeof value === "object") return Object.values(value).every(isJsonValue);
|
|
1768
|
+
return false;
|
|
1769
|
+
};
|
|
1770
|
+
var parsedConfigs = /* @__PURE__ */ new WeakMap();
|
|
1771
|
+
var prismTransform = (config, source) => {
|
|
1772
|
+
if (!isJsonValue(source)) throw new Error("The source of a transform must be plain JSON.");
|
|
1773
|
+
const cached = typeof config === "object" && config !== null ? parsedConfigs.get(config) : void 0;
|
|
1774
|
+
const parsed = cached ?? ConfigSchema.parse(config);
|
|
1775
|
+
if (cached === void 0 && typeof config === "object" && config !== null) parsedConfigs.set(config, parsed);
|
|
1776
|
+
return evaluate(parsed, source);
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1762
1779
|
// src/migrations/index.ts
|
|
1763
1780
|
var PRISM_SEQUENCE = {
|
|
1764
1781
|
id: "nisc.prism",
|
|
@@ -1784,21 +1801,6 @@ var PRISM_SEQUENCE = {
|
|
|
1784
1801
|
}
|
|
1785
1802
|
]
|
|
1786
1803
|
};
|
|
1787
|
-
var isJsonValue = (value) => {
|
|
1788
|
-
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
1789
|
-
if (typeof value === "number") return Number.isFinite(value);
|
|
1790
|
-
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
1791
|
-
if (typeof value === "object") return Object.values(value).every(isJsonValue);
|
|
1792
|
-
return false;
|
|
1793
|
-
};
|
|
1794
|
-
var parsedConfigs = /* @__PURE__ */ new WeakMap();
|
|
1795
|
-
var prismTransform = (config, source) => {
|
|
1796
|
-
if (!isJsonValue(source)) throw new Error("A document to migrate must be plain JSON.");
|
|
1797
|
-
const cached = typeof config === "object" && config !== null ? parsedConfigs.get(config) : void 0;
|
|
1798
|
-
const parsed = cached ?? ConfigSchema.parse(config);
|
|
1799
|
-
if (cached === void 0 && typeof config === "object" && config !== null) parsedConfigs.set(config, parsed);
|
|
1800
|
-
return evaluate(parsed, source);
|
|
1801
|
-
};
|
|
1802
1804
|
var PRISM_SCHEMAS = { "nisc.prism/config": ConfigSchema };
|
|
1803
1805
|
|
|
1804
1806
|
exports.PRISM_SCHEMAS = PRISM_SCHEMAS;
|