@calcit/procs 0.29.0-alpha.28 → 0.29.0-alpha.29
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/lib/calcit.procs.d.mts +3 -3
- package/lib/calcit.procs.mjs +47 -43
- package/lib/package.json +1 -1
- package/package.json +1 -1
package/lib/calcit.procs.d.mts
CHANGED
|
@@ -398,7 +398,7 @@ export declare let macroexpand_all: () => void;
|
|
|
398
398
|
export declare let _$n_get_calcit_running_mode: () => void;
|
|
399
399
|
export declare let _$n_get_def_doc: () => void;
|
|
400
400
|
export declare let _$n_get_def_schema: () => void;
|
|
401
|
-
export declare let _$n_ffi_response_resolve: () =>
|
|
402
|
-
export declare let _$n_ffi_response_reject: () =>
|
|
403
|
-
export declare let _$n_ffi_task_cancel: () =>
|
|
401
|
+
export declare let _$n_ffi_response_resolve: (..._args: CalcitValue[]) => never;
|
|
402
|
+
export declare let _$n_ffi_response_reject: (..._args: CalcitValue[]) => never;
|
|
403
|
+
export declare let _$n_ffi_task_cancel: (..._args: CalcitValue[]) => never;
|
|
404
404
|
export declare let raise: () => void;
|
package/lib/calcit.procs.mjs
CHANGED
|
@@ -2039,75 +2039,75 @@ const typed_edn_error = (path, message) => {
|
|
|
2039
2039
|
const enum_prototype_name = (value) => {
|
|
2040
2040
|
return value instanceof CalcitEnumDef ? value.name() : value.name.value;
|
|
2041
2041
|
};
|
|
2042
|
-
const decode_typed_edn_node = (graph, nodeId, input, path, depth) => {
|
|
2042
|
+
const decode_typed_edn_node = (graph, nodeId, input, path, depth, fail = typed_edn_error) => {
|
|
2043
2043
|
if (depth > 1024)
|
|
2044
|
-
|
|
2044
|
+
fail(path, "decode nesting exceeds 1024");
|
|
2045
2045
|
const node = graph.nodes[nodeId];
|
|
2046
2046
|
if (node == null)
|
|
2047
|
-
|
|
2047
|
+
fail(path, `invalid data shape node #${nodeId}`);
|
|
2048
2048
|
switch (node.kind) {
|
|
2049
2049
|
case "nil":
|
|
2050
2050
|
if (input === null)
|
|
2051
2051
|
return null;
|
|
2052
|
-
return
|
|
2052
|
+
return fail(path, `expected nil, got ${typed_edn_kind(input)}`);
|
|
2053
2053
|
case "unit":
|
|
2054
2054
|
if (input === undefined)
|
|
2055
2055
|
return input;
|
|
2056
|
-
return
|
|
2056
|
+
return fail(path, `expected &unit, got ${typed_edn_kind(input)}`);
|
|
2057
2057
|
case "bool":
|
|
2058
2058
|
if (typeof input === "boolean")
|
|
2059
2059
|
return input;
|
|
2060
|
-
return
|
|
2060
|
+
return fail(path, `expected bool, got ${typed_edn_kind(input)}`);
|
|
2061
2061
|
case "number":
|
|
2062
2062
|
if (typeof input === "number")
|
|
2063
2063
|
return input;
|
|
2064
|
-
return
|
|
2064
|
+
return fail(path, `expected number, got ${typed_edn_kind(input)}`);
|
|
2065
2065
|
case "numeric":
|
|
2066
2066
|
if (typeof input !== "number")
|
|
2067
|
-
return
|
|
2067
|
+
return fail(path, `expected ${node.target}, got ${typed_edn_kind(input)}`);
|
|
2068
2068
|
if (_$n_number_$o_fits_$q_(input, newTag(node.target)))
|
|
2069
2069
|
return input;
|
|
2070
|
-
return
|
|
2070
|
+
return fail(path, `number ${input} does not fit ${node.target}`);
|
|
2071
2071
|
case "string":
|
|
2072
2072
|
if (typeof input === "string")
|
|
2073
2073
|
return input;
|
|
2074
|
-
return
|
|
2074
|
+
return fail(path, `expected string, got ${typed_edn_kind(input)}`);
|
|
2075
2075
|
case "symbol":
|
|
2076
2076
|
if (input instanceof CalcitSymbol)
|
|
2077
2077
|
return input;
|
|
2078
|
-
return
|
|
2078
|
+
return fail(path, `expected symbol, got ${typed_edn_kind(input)}`);
|
|
2079
2079
|
case "tag":
|
|
2080
2080
|
if (input instanceof CalcitTag)
|
|
2081
2081
|
return input;
|
|
2082
|
-
return
|
|
2082
|
+
return fail(path, `expected tag, got ${typed_edn_kind(input)}`);
|
|
2083
2083
|
case "buffer":
|
|
2084
2084
|
if (input instanceof Uint8Array)
|
|
2085
2085
|
return input;
|
|
2086
|
-
return
|
|
2086
|
+
return fail(path, `expected buffer, got ${typed_edn_kind(input)}`);
|
|
2087
2087
|
case "cirru-quote":
|
|
2088
2088
|
if (input instanceof CalcitCirruQuote)
|
|
2089
2089
|
return input;
|
|
2090
|
-
return
|
|
2090
|
+
return fail(path, `expected cirru-quote, got ${typed_edn_kind(input)}`);
|
|
2091
2091
|
case "optional":
|
|
2092
|
-
return input === null ? null : decode_typed_edn_node(graph, node.inner, input, path, depth + 1);
|
|
2092
|
+
return input === null ? null : decode_typed_edn_node(graph, node.inner, input, path, depth + 1, fail);
|
|
2093
2093
|
case "list": {
|
|
2094
2094
|
if (!(input instanceof CalcitList || input instanceof CalcitSliceList)) {
|
|
2095
|
-
return
|
|
2095
|
+
return fail(path, `expected list, got ${typed_edn_kind(input)}`);
|
|
2096
2096
|
}
|
|
2097
|
-
const values = Array.from(input.items()).map((value, idx) => decode_typed_edn_node(graph, node.inner, value, `${path}[${idx}]`, depth + 1));
|
|
2097
|
+
const values = Array.from(input.items()).map((value, idx) => decode_typed_edn_node(graph, node.inner, value, `${path}[${idx}]`, depth + 1, fail));
|
|
2098
2098
|
return new CalcitSliceList(values);
|
|
2099
2099
|
}
|
|
2100
2100
|
case "set": {
|
|
2101
2101
|
if (!(input instanceof CalcitSet || input instanceof TypedEdnSetView)) {
|
|
2102
|
-
return
|
|
2102
|
+
return fail(path, `expected set, got ${typed_edn_kind(input)}`);
|
|
2103
2103
|
}
|
|
2104
2104
|
const values = [];
|
|
2105
2105
|
const inputValues = input instanceof TypedEdnSetView ? input.items : input.values();
|
|
2106
2106
|
inputValues.forEach((value) => {
|
|
2107
2107
|
const itemPath = `${path}.item`;
|
|
2108
|
-
const decoded = decode_typed_edn_node(graph, node.inner, value, itemPath, depth + 1);
|
|
2108
|
+
const decoded = decode_typed_edn_node(graph, node.inner, value, itemPath, depth + 1, fail);
|
|
2109
2109
|
if (values.some((existing) => _$n__$e_(existing, decoded))) {
|
|
2110
|
-
|
|
2110
|
+
fail(itemPath, "duplicate decoded set value");
|
|
2111
2111
|
}
|
|
2112
2112
|
values.push(decoded);
|
|
2113
2113
|
});
|
|
@@ -2115,53 +2115,53 @@ const decode_typed_edn_node = (graph, nodeId, input, path, depth) => {
|
|
|
2115
2115
|
}
|
|
2116
2116
|
case "map": {
|
|
2117
2117
|
if (!(input instanceof CalcitMap || input instanceof CalcitSliceMap)) {
|
|
2118
|
-
return
|
|
2118
|
+
return fail(path, `expected map, got ${typed_edn_kind(input)}`);
|
|
2119
2119
|
}
|
|
2120
2120
|
const entries = [];
|
|
2121
2121
|
input.pairs().forEach(([key, value]) => {
|
|
2122
2122
|
const keyPath = `${path}.key`;
|
|
2123
|
-
const decodedKey = decode_typed_edn_node(graph, node.key, key, keyPath, depth + 1);
|
|
2123
|
+
const decodedKey = decode_typed_edn_node(graph, node.key, key, keyPath, depth + 1, fail);
|
|
2124
2124
|
for (let idx = 0; idx < entries.length; idx += 2) {
|
|
2125
2125
|
if (_$n__$e_(entries[idx], decodedKey)) {
|
|
2126
|
-
|
|
2126
|
+
fail(keyPath, "duplicate decoded map key");
|
|
2127
2127
|
}
|
|
2128
2128
|
}
|
|
2129
|
-
const decodedValue = decode_typed_edn_node(graph, node.value, value, `${path}.value`, depth + 1);
|
|
2129
|
+
const decodedValue = decode_typed_edn_node(graph, node.value, value, `${path}.value`, depth + 1, fail);
|
|
2130
2130
|
entries.push(decodedKey, decodedValue);
|
|
2131
2131
|
});
|
|
2132
2132
|
return new CalcitSliceMap(entries);
|
|
2133
2133
|
}
|
|
2134
2134
|
case "ref":
|
|
2135
2135
|
if (!(input instanceof CalcitRef))
|
|
2136
|
-
return
|
|
2137
|
-
return atom(decode_typed_edn_node(graph, node.inner, input.value, `${path}.value`, depth + 1));
|
|
2136
|
+
return fail(path, `expected atom, got ${typed_edn_kind(input)}`);
|
|
2137
|
+
return atom(decode_typed_edn_node(graph, node.inner, input.value, `${path}.value`, depth + 1, fail));
|
|
2138
2138
|
case "struct": {
|
|
2139
2139
|
if (!(input instanceof CalcitStructValue)) {
|
|
2140
|
-
return
|
|
2140
|
+
return fail(path, `expected struct :${node.nominal.name.value}, got ${typed_edn_kind(input)}`);
|
|
2141
2141
|
}
|
|
2142
2142
|
if (input.name.value !== node.nominal.name.value) {
|
|
2143
|
-
return
|
|
2143
|
+
return fail(path, `expected struct :${node.nominal.name.value}, got struct :${input.name.value}`);
|
|
2144
2144
|
}
|
|
2145
2145
|
const expectedNames = node.fields.map(([name]) => name);
|
|
2146
2146
|
const actualNames = input.fields.map((field) => field.value);
|
|
2147
2147
|
const missing = expectedNames.filter((name) => !actualNames.includes(name)).sort();
|
|
2148
2148
|
const unknown = actualNames.filter((name) => !expectedNames.includes(name)).sort();
|
|
2149
2149
|
if (missing.length > 0 || unknown.length > 0 || expectedNames.length !== actualNames.length) {
|
|
2150
|
-
return
|
|
2150
|
+
return fail(path, `struct :${node.nominal.name.value} fields mismatch; missing [${missing.join(", ")}], unknown [${unknown.join(", ")}]`);
|
|
2151
2151
|
}
|
|
2152
2152
|
const decodedFields = new Map();
|
|
2153
2153
|
node.fields.forEach(([name, fieldNode]) => {
|
|
2154
2154
|
const idx = actualNames.indexOf(name);
|
|
2155
|
-
decodedFields.set(name, decode_typed_edn_node(graph, fieldNode, input.values[idx], `${path}.${name}`, depth + 1));
|
|
2155
|
+
decodedFields.set(name, decode_typed_edn_node(graph, fieldNode, input.values[idx], `${path}.${name}`, depth + 1, fail));
|
|
2156
2156
|
});
|
|
2157
2157
|
// Re-align by name so values produced by older runtimes or external data
|
|
2158
2158
|
// still adopt the current nominal declaration's canonical field layout.
|
|
2159
2159
|
if (decodedFields.size !== node.nominal.fields.length) {
|
|
2160
|
-
return
|
|
2160
|
+
return fail(path, `struct :${node.nominal.name.value} decoder fields do not match its nominal declaration`);
|
|
2161
2161
|
}
|
|
2162
2162
|
const values = node.nominal.fields.map((field) => {
|
|
2163
2163
|
if (!decodedFields.has(field.value)) {
|
|
2164
|
-
return
|
|
2164
|
+
return fail(path, `struct :${node.nominal.name.value} is missing declared field :${field.value}`);
|
|
2165
2165
|
}
|
|
2166
2166
|
return decodedFields.get(field.value);
|
|
2167
2167
|
});
|
|
@@ -2169,28 +2169,28 @@ const decode_typed_edn_node = (graph, nodeId, input, path, depth) => {
|
|
|
2169
2169
|
}
|
|
2170
2170
|
case "enum": {
|
|
2171
2171
|
if (!(input instanceof CalcitEnumValue) || input.enumPrototype == null) {
|
|
2172
|
-
return
|
|
2172
|
+
return fail(path, `expected enum :${node.nominal.name()}, got ${typed_edn_kind(input)}`);
|
|
2173
2173
|
}
|
|
2174
2174
|
const actualEnumName = enum_prototype_name(input.enumPrototype);
|
|
2175
2175
|
if (actualEnumName !== node.nominal.name()) {
|
|
2176
|
-
return
|
|
2176
|
+
return fail(path, `expected enum :${node.nominal.name()}, got enum :${actualEnumName}`);
|
|
2177
2177
|
}
|
|
2178
2178
|
if (!(input.tag instanceof CalcitTag)) {
|
|
2179
|
-
return
|
|
2179
|
+
return fail(path, `enum :${node.nominal.name()} variant must be a tag`);
|
|
2180
2180
|
}
|
|
2181
2181
|
const inputTag = input.tag;
|
|
2182
2182
|
const variant = node.variants.find((candidate) => candidate.tag === inputTag.value);
|
|
2183
2183
|
if (variant == null) {
|
|
2184
|
-
return
|
|
2184
|
+
return fail(path, `enum :${node.nominal.name()} has no variant :${inputTag.value}`);
|
|
2185
2185
|
}
|
|
2186
2186
|
if (variant.payload.length !== input.extra.length) {
|
|
2187
|
-
return
|
|
2187
|
+
return fail(path, `enum :${node.nominal.name()} variant :${variant.tag} expects ${variant.payload.length} payload(s), got ${input.extra.length}`);
|
|
2188
2188
|
}
|
|
2189
|
-
const values = variant.payload.map((payloadNode, idx) => decode_typed_edn_node(graph, payloadNode, input.extra[idx], `${path}.payload[${idx}]`, depth + 1));
|
|
2189
|
+
const values = variant.payload.map((payloadNode, idx) => decode_typed_edn_node(graph, payloadNode, input.extra[idx], `${path}.payload[${idx}]`, depth + 1, fail));
|
|
2190
2190
|
return new CalcitEnumValue(newTag(variant.tag), values, node.nominal);
|
|
2191
2191
|
}
|
|
2192
2192
|
default:
|
|
2193
|
-
return
|
|
2193
|
+
return fail(path, `invalid data shape node kind: ${node.kind}`);
|
|
2194
2194
|
}
|
|
2195
2195
|
};
|
|
2196
2196
|
export let parse_cirru_edn_as = (code, graph) => {
|
|
@@ -2341,7 +2341,7 @@ const decode_runtime_map_node = (graph, nodeId, input, path, depth) => {
|
|
|
2341
2341
|
return new CalcitEnumValue(newTag(variant.tag), values, node.nominal);
|
|
2342
2342
|
}
|
|
2343
2343
|
default:
|
|
2344
|
-
return decode_typed_edn_node(graph, nodeId, input, path, depth);
|
|
2344
|
+
return decode_typed_edn_node(graph, nodeId, input, path, depth, map_decode_error);
|
|
2345
2345
|
}
|
|
2346
2346
|
};
|
|
2347
2347
|
export let decode_map_as = (value, graph) => {
|
|
@@ -3102,8 +3102,12 @@ export let macroexpand_all = unavailableProc;
|
|
|
3102
3102
|
export let _$n_get_calcit_running_mode = unavailableProc;
|
|
3103
3103
|
export let _$n_get_def_doc = unavailableProc;
|
|
3104
3104
|
export let _$n_get_def_schema = unavailableProc;
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3105
|
+
// A missing native lifecycle capability must not look like a successful Unit.
|
|
3106
|
+
const unavailableNativeFfi = (operation) => {
|
|
3107
|
+
throw new Error(`${operation}: native FFI capability is not available for calcit-js`);
|
|
3108
|
+
};
|
|
3109
|
+
export let _$n_ffi_response_resolve = (..._args) => unavailableNativeFfi("&ffi-response-resolve");
|
|
3110
|
+
export let _$n_ffi_response_reject = (..._args) => unavailableNativeFfi("&ffi-response-reject");
|
|
3111
|
+
export let _$n_ffi_task_cancel = (..._args) => unavailableNativeFfi("&ffi-task-cancel");
|
|
3108
3112
|
// already handled in code emitter
|
|
3109
3113
|
export let raise = unavailableProc;
|
package/lib/package.json
CHANGED