superbee 0.4.4-pre.13 → 0.4.4-pre.14
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/dist/publication/bridge-host-kind.d.ts +2 -0
- package/dist/publication/bridge.d.ts +1 -1
- package/dist/publication-bridge.mjs +278 -82
- package/dist/publication.mjs +278 -82
- package/dist/superbee.mjs +389 -129
- package/package.json +1 -1
package/dist/superbee.mjs
CHANGED
|
@@ -44,7 +44,7 @@ var __toESM = (mod, isNodeMode, target3) => (target3 = mod != null ? __create(__
|
|
|
44
44
|
var define_SUPERBEE_BUILD_IDENTITY_default;
|
|
45
45
|
var init_define_SUPERBEE_BUILD_IDENTITY = __esm({
|
|
46
46
|
"<define:__SUPERBEE_BUILD_IDENTITY__>"() {
|
|
47
|
-
define_SUPERBEE_BUILD_IDENTITY_default = { schema: "superbee.build-identity.v1", package: { name: "superbee", version: "0.4.4-pre.
|
|
47
|
+
define_SUPERBEE_BUILD_IDENTITY_default = { schema: "superbee.build-identity.v1", package: { name: "superbee", version: "0.4.4-pre.14" }, source: { commit: "da215d8610a39974bc39a195ad87f769c4d87560", dirty: false }, artifact: { channel: "npm-package" }, compatibility_contracts: { skill: 1, hook: 1, mcp: 1 } };
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -57,7 +57,7 @@ var init_define_SUPERBEE_UPDATE_POLICY = __esm({
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
// ../core/src/errors.ts
|
|
60
|
-
var InvalidInputError, OkfActorError, FilesystemIdentityAliasError, ConcurrentReplacementError;
|
|
60
|
+
var InvalidInputError, FrontmatterRefusedError, OkfActorError, FilesystemIdentityAliasError, ConcurrentReplacementError;
|
|
61
61
|
var init_errors = __esm({
|
|
62
62
|
"../core/src/errors.ts"() {
|
|
63
63
|
"use strict";
|
|
@@ -69,6 +69,14 @@ var init_errors = __esm({
|
|
|
69
69
|
this.name = "InvalidInputError";
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
FrontmatterRefusedError = class extends InvalidInputError {
|
|
73
|
+
code;
|
|
74
|
+
constructor(code3, detail2) {
|
|
75
|
+
super(`frontmatter cannot be stored: ${detail2}`);
|
|
76
|
+
this.name = "FrontmatterRefusedError";
|
|
77
|
+
this.code = code3;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
72
80
|
OkfActorError = class extends InvalidInputError {
|
|
73
81
|
actor;
|
|
74
82
|
constructor(actor, message) {
|
|
@@ -132,8 +140,8 @@ var require_common = __commonJS({
|
|
|
132
140
|
return target3;
|
|
133
141
|
}
|
|
134
142
|
function repeat2(string8, count6) {
|
|
135
|
-
var result3 = "",
|
|
136
|
-
for (
|
|
143
|
+
var result3 = "", cycle2;
|
|
144
|
+
for (cycle2 = 0; cycle2 < count6; cycle2 += 1) {
|
|
137
145
|
result3 += string8;
|
|
138
146
|
}
|
|
139
147
|
return result3;
|
|
@@ -2994,23 +3002,41 @@ var require_js_yaml2 = __commonJS({
|
|
|
2994
3002
|
"use strict";
|
|
2995
3003
|
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
2996
3004
|
init_define_SUPERBEE_UPDATE_POLICY();
|
|
2997
|
-
var
|
|
2998
|
-
module.exports =
|
|
3005
|
+
var yaml3 = require_js_yaml();
|
|
3006
|
+
module.exports = yaml3;
|
|
2999
3007
|
}
|
|
3000
3008
|
});
|
|
3001
3009
|
|
|
3002
3010
|
// ../core/src/frontmatter-contract.ts
|
|
3011
|
+
function isFrontmatterLimitCode(value) {
|
|
3012
|
+
return typeof value === "string" && FRONTMATTER_LIMIT_CODES.has(value);
|
|
3013
|
+
}
|
|
3003
3014
|
function isUsableTimestamp(value) {
|
|
3004
3015
|
return typeof value === "string" && value.trim() !== "";
|
|
3005
3016
|
}
|
|
3006
|
-
var MalformedDocumentError;
|
|
3017
|
+
var FRONTMATTER_LIMIT_CODES, FrontmatterLimitError, MalformedDocumentError;
|
|
3007
3018
|
var init_frontmatter_contract = __esm({
|
|
3008
3019
|
"../core/src/frontmatter-contract.ts"() {
|
|
3009
3020
|
"use strict";
|
|
3010
3021
|
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
3011
3022
|
init_define_SUPERBEE_UPDATE_POLICY();
|
|
3023
|
+
FRONTMATTER_LIMIT_CODES = /* @__PURE__ */ new Set([
|
|
3024
|
+
"FRONTMATTER_TOO_LARGE",
|
|
3025
|
+
"FRONTMATTER_TOO_DEEP",
|
|
3026
|
+
"FRONTMATTER_ALIAS_LIMIT",
|
|
3027
|
+
"FRONTMATTER_CYCLE"
|
|
3028
|
+
]);
|
|
3029
|
+
FrontmatterLimitError = class extends Error {
|
|
3030
|
+
name = "FrontmatterLimitError";
|
|
3031
|
+
code;
|
|
3032
|
+
constructor(code3, message) {
|
|
3033
|
+
super(message);
|
|
3034
|
+
this.code = code3;
|
|
3035
|
+
}
|
|
3036
|
+
};
|
|
3012
3037
|
MalformedDocumentError = class extends Error {
|
|
3013
3038
|
name = "MalformedDocumentError";
|
|
3039
|
+
code;
|
|
3014
3040
|
context;
|
|
3015
3041
|
detail;
|
|
3016
3042
|
constructor(context3, cause) {
|
|
@@ -3018,6 +3044,7 @@ var init_frontmatter_contract = __esm({
|
|
|
3018
3044
|
super(
|
|
3019
3045
|
`malformed frontmatter${context3 ? ` in '${context3}'` : ""}: ${detail2} \u2014 fix the YAML or remove the file`
|
|
3020
3046
|
);
|
|
3047
|
+
this.code = cause instanceof FrontmatterLimitError ? cause.code : "FRONTMATTER_MALFORMED";
|
|
3021
3048
|
if (context3 !== void 0) this.context = context3;
|
|
3022
3049
|
this.detail = detail2;
|
|
3023
3050
|
if (cause !== void 0) this.cause = cause;
|
|
@@ -3026,6 +3053,165 @@ var init_frontmatter_contract = __esm({
|
|
|
3026
3053
|
}
|
|
3027
3054
|
});
|
|
3028
3055
|
|
|
3056
|
+
// ../core/src/bounded-yaml.ts
|
|
3057
|
+
function tooDeep() {
|
|
3058
|
+
return new FrontmatterLimitError("FRONTMATTER_TOO_DEEP", `YAML nesting is deeper than ${FRONTMATTER_LIMITS.depth} levels`);
|
|
3059
|
+
}
|
|
3060
|
+
function tooLarge() {
|
|
3061
|
+
return new FrontmatterLimitError(
|
|
3062
|
+
"FRONTMATTER_ALIAS_LIMIT",
|
|
3063
|
+
`YAML aliases expand to more than ${FRONTMATTER_LIMITS.expandedNodes} nodes or ${FRONTMATTER_LIMITS.expandedChars} characters`
|
|
3064
|
+
);
|
|
3065
|
+
}
|
|
3066
|
+
function cycle() {
|
|
3067
|
+
return new FrontmatterLimitError("FRONTMATTER_CYCLE", "YAML aliases form a cycle");
|
|
3068
|
+
}
|
|
3069
|
+
function scalarExtent(value) {
|
|
3070
|
+
const chars = typeof value === "string" ? value.length : ArrayBuffer.isView(value) ? value.byteLength : 0;
|
|
3071
|
+
return { nodes: 1, chars, depth: 0 };
|
|
3072
|
+
}
|
|
3073
|
+
function isCollection(value) {
|
|
3074
|
+
if (Array.isArray(value)) return true;
|
|
3075
|
+
if (value === null || typeof value !== "object") return false;
|
|
3076
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3077
|
+
return prototype === Object.prototype || prototype === null;
|
|
3078
|
+
}
|
|
3079
|
+
function loadBoundedYaml(source2, options = {}) {
|
|
3080
|
+
if (source2.length > FRONTMATTER_LIMITS.sourceChars) {
|
|
3081
|
+
throw new FrontmatterLimitError(
|
|
3082
|
+
"FRONTMATTER_TOO_LARGE",
|
|
3083
|
+
`YAML source is longer than ${FRONTMATTER_LIMITS.sourceChars} characters`
|
|
3084
|
+
);
|
|
3085
|
+
}
|
|
3086
|
+
const schema = options.schema === "json" ? import_js_yaml.default.JSON_SCHEMA : options.schema;
|
|
3087
|
+
const budget = new AliasBudget();
|
|
3088
|
+
let watched;
|
|
3089
|
+
let nesting = 0;
|
|
3090
|
+
let value;
|
|
3091
|
+
try {
|
|
3092
|
+
value = import_js_yaml.default.safeLoad(source2, {
|
|
3093
|
+
...schema ? { schema } : {},
|
|
3094
|
+
listener(event, rawState) {
|
|
3095
|
+
const state = rawState;
|
|
3096
|
+
if (state.anchorMap !== watched) {
|
|
3097
|
+
budget.watch(state);
|
|
3098
|
+
watched = state.anchorMap;
|
|
3099
|
+
}
|
|
3100
|
+
if (event === "open") {
|
|
3101
|
+
nesting += 1;
|
|
3102
|
+
if (nesting > PARSE_NESTING_GUARD) throw tooDeep();
|
|
3103
|
+
} else {
|
|
3104
|
+
nesting -= 1;
|
|
3105
|
+
if (state.anchor !== null) budget.close(state.anchor, state.result);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
});
|
|
3109
|
+
} catch (error51) {
|
|
3110
|
+
const reason = error51.reason;
|
|
3111
|
+
if (typeof reason === "string" && reason.startsWith(MERGE_KEY_LIMIT_REASON)) {
|
|
3112
|
+
throw new FrontmatterLimitError("FRONTMATTER_ALIAS_LIMIT", reason);
|
|
3113
|
+
}
|
|
3114
|
+
throw error51;
|
|
3115
|
+
}
|
|
3116
|
+
new ExtentMeter().measure(value);
|
|
3117
|
+
return value;
|
|
3118
|
+
}
|
|
3119
|
+
var import_js_yaml, FRONTMATTER_LIMITS, PARSE_NESTING_GUARD, ExtentMeter, AliasBudget, MERGE_KEY_LIMIT_REASON;
|
|
3120
|
+
var init_bounded_yaml = __esm({
|
|
3121
|
+
"../core/src/bounded-yaml.ts"() {
|
|
3122
|
+
"use strict";
|
|
3123
|
+
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
3124
|
+
init_define_SUPERBEE_UPDATE_POLICY();
|
|
3125
|
+
import_js_yaml = __toESM(require_js_yaml2(), 1);
|
|
3126
|
+
init_frontmatter_contract();
|
|
3127
|
+
FRONTMATTER_LIMITS = Object.freeze({
|
|
3128
|
+
sourceChars: 256 * 1024,
|
|
3129
|
+
depth: 32,
|
|
3130
|
+
aliases: 1e3,
|
|
3131
|
+
expandedNodes: 1e5,
|
|
3132
|
+
expandedChars: 1024 * 1024
|
|
3133
|
+
});
|
|
3134
|
+
PARSE_NESTING_GUARD = FRONTMATTER_LIMITS.depth * 4;
|
|
3135
|
+
ExtentMeter = class {
|
|
3136
|
+
known = /* @__PURE__ */ new Map();
|
|
3137
|
+
path = /* @__PURE__ */ new Set();
|
|
3138
|
+
unfinished;
|
|
3139
|
+
constructor(unfinished = /* @__PURE__ */ new Set()) {
|
|
3140
|
+
this.unfinished = unfinished;
|
|
3141
|
+
}
|
|
3142
|
+
measure(value) {
|
|
3143
|
+
if (!isCollection(value)) return scalarExtent(value);
|
|
3144
|
+
const known = this.known.get(value);
|
|
3145
|
+
if (known !== void 0) return known;
|
|
3146
|
+
if (this.path.has(value) || this.unfinished.has(value)) throw cycle();
|
|
3147
|
+
return this.walk(value);
|
|
3148
|
+
}
|
|
3149
|
+
walk(value) {
|
|
3150
|
+
if (this.path.size >= FRONTMATTER_LIMITS.depth) throw tooDeep();
|
|
3151
|
+
this.path.add(value);
|
|
3152
|
+
const keyed = !Array.isArray(value);
|
|
3153
|
+
const extent = { nodes: 1, chars: 0, depth: 1 };
|
|
3154
|
+
for (const [key4, child2] of Object.entries(value)) {
|
|
3155
|
+
const inner = this.measure(child2);
|
|
3156
|
+
extent.nodes += inner.nodes;
|
|
3157
|
+
extent.chars += inner.chars + (keyed ? key4.length : 0);
|
|
3158
|
+
extent.depth = Math.max(extent.depth, inner.depth + 1);
|
|
3159
|
+
if (extent.nodes > FRONTMATTER_LIMITS.expandedNodes || extent.chars > FRONTMATTER_LIMITS.expandedChars) throw tooLarge();
|
|
3160
|
+
if (extent.depth > FRONTMATTER_LIMITS.depth) throw tooDeep();
|
|
3161
|
+
}
|
|
3162
|
+
this.path.delete(value);
|
|
3163
|
+
this.known.set(value, extent);
|
|
3164
|
+
return extent;
|
|
3165
|
+
}
|
|
3166
|
+
};
|
|
3167
|
+
AliasBudget = class {
|
|
3168
|
+
unfinished = /* @__PURE__ */ new Set();
|
|
3169
|
+
finished = /* @__PURE__ */ new Set();
|
|
3170
|
+
meter = new ExtentMeter(this.unfinished);
|
|
3171
|
+
aliases = 0;
|
|
3172
|
+
nodes = 0;
|
|
3173
|
+
chars = 0;
|
|
3174
|
+
/** Wrap the parser's anchor table; the parser reads it only to resolve an alias. */
|
|
3175
|
+
watch(state) {
|
|
3176
|
+
state.anchorMap = new Proxy(state.anchorMap, {
|
|
3177
|
+
get: (target3, name, receiver) => {
|
|
3178
|
+
const value = Reflect.get(target3, name, receiver);
|
|
3179
|
+
if (typeof name === "string") this.charge(name, value);
|
|
3180
|
+
return value;
|
|
3181
|
+
},
|
|
3182
|
+
set: (target3, name, value, receiver) => {
|
|
3183
|
+
if (typeof name === "string") {
|
|
3184
|
+
this.finished.delete(name);
|
|
3185
|
+
if (isCollection(value)) this.unfinished.add(value);
|
|
3186
|
+
}
|
|
3187
|
+
return Reflect.set(target3, name, value, receiver);
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
/** Called when an anchored node closes: its anchor now names a complete value. */
|
|
3192
|
+
close(anchor, value) {
|
|
3193
|
+
this.finished.add(anchor);
|
|
3194
|
+
if (isCollection(value)) this.unfinished.delete(value);
|
|
3195
|
+
}
|
|
3196
|
+
charge(name, value) {
|
|
3197
|
+
this.aliases += 1;
|
|
3198
|
+
if (this.aliases > FRONTMATTER_LIMITS.aliases) {
|
|
3199
|
+
throw new FrontmatterLimitError(
|
|
3200
|
+
"FRONTMATTER_ALIAS_LIMIT",
|
|
3201
|
+
`YAML aliases are used more than ${FRONTMATTER_LIMITS.aliases} times`
|
|
3202
|
+
);
|
|
3203
|
+
}
|
|
3204
|
+
if (!this.finished.has(name) && isCollection(value)) throw cycle();
|
|
3205
|
+
const extent = this.meter.measure(value);
|
|
3206
|
+
this.nodes += extent.nodes;
|
|
3207
|
+
this.chars += extent.chars;
|
|
3208
|
+
if (this.nodes > FRONTMATTER_LIMITS.expandedNodes || this.chars > FRONTMATTER_LIMITS.expandedChars) throw tooLarge();
|
|
3209
|
+
}
|
|
3210
|
+
};
|
|
3211
|
+
MERGE_KEY_LIMIT_REASON = "merge keys exceeded maxTotalMergeKeys";
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
|
|
3029
3215
|
// ../core/src/frontmatter-splitter.ts
|
|
3030
3216
|
function delimiterLineEnd(input, offset) {
|
|
3031
3217
|
if (!input.startsWith("---", offset)) return null;
|
|
@@ -3063,12 +3249,110 @@ var init_frontmatter_splitter = __esm({
|
|
|
3063
3249
|
}
|
|
3064
3250
|
});
|
|
3065
3251
|
|
|
3252
|
+
// ../core/src/frontmatter.ts
|
|
3253
|
+
function requireYamlTimestampType() {
|
|
3254
|
+
const type = import_js_yaml2.default.DEFAULT_SAFE_SCHEMA.implicit.find(
|
|
3255
|
+
(candidate) => candidate.tag === YAML_TIMESTAMP_TAG
|
|
3256
|
+
);
|
|
3257
|
+
if (!type) throw new Error("js-yaml safe schema is missing its timestamp type");
|
|
3258
|
+
return type;
|
|
3259
|
+
}
|
|
3260
|
+
function normalizeFrontmatter(data, options) {
|
|
3261
|
+
const out = { ...data };
|
|
3262
|
+
if (options.preserveTimestamp || options.okfVersion === "0.2") return out;
|
|
3263
|
+
const value = out.timestamp;
|
|
3264
|
+
if (value instanceof Date) {
|
|
3265
|
+
out.timestamp = value.toISOString();
|
|
3266
|
+
} else if (typeof value === "number" && Number.isFinite(value)) {
|
|
3267
|
+
out.timestamp = new Date(value).toISOString();
|
|
3268
|
+
} else if (typeof value === "string" && yamlTimestampType.resolve(value)) {
|
|
3269
|
+
const parsed2 = yamlTimestampType.construct(value);
|
|
3270
|
+
if (parsed2 instanceof Date) out.timestamp = parsed2.toISOString();
|
|
3271
|
+
}
|
|
3272
|
+
return out;
|
|
3273
|
+
}
|
|
3274
|
+
function parseMarkdown(raw, context3, options = {}) {
|
|
3275
|
+
const split = splitLeadingFrontmatter(raw, context3);
|
|
3276
|
+
if (!("yamlSource" in split)) return { frontmatter: {}, body: split.body };
|
|
3277
|
+
return { frontmatter: parseFrontmatter(split.yamlSource, context3, options), body: split.body };
|
|
3278
|
+
}
|
|
3279
|
+
function parseFrontmatter(source2, context3, options = {}) {
|
|
3280
|
+
let parsed2;
|
|
3281
|
+
try {
|
|
3282
|
+
parsed2 = yamlEngine.parse(source2);
|
|
3283
|
+
} catch (err) {
|
|
3284
|
+
throw new MalformedDocumentError(context3, err);
|
|
3285
|
+
}
|
|
3286
|
+
return normalizeFrontmatter(parsed2, options);
|
|
3287
|
+
}
|
|
3288
|
+
function stringifyFrontmatter(data) {
|
|
3289
|
+
const dumped = import_js_yaml2.default.safeDump(data).trim();
|
|
3290
|
+
try {
|
|
3291
|
+
yamlEngine.parse(`${dumped}
|
|
3292
|
+
`);
|
|
3293
|
+
} catch (error51) {
|
|
3294
|
+
if (error51 instanceof FrontmatterLimitError) throw new FrontmatterRefusedError(error51.code, error51.message);
|
|
3295
|
+
const detail2 = (error51 instanceof Error ? error51.message : String(error51)).split("\n")[0] ?? "";
|
|
3296
|
+
throw new FrontmatterRefusedError("FRONTMATTER_MALFORMED", detail2);
|
|
3297
|
+
}
|
|
3298
|
+
return dumped;
|
|
3299
|
+
}
|
|
3300
|
+
function normalizeDocumentBodyForStorage(body) {
|
|
3301
|
+
return body.endsWith("\n") ? body : `${body}
|
|
3302
|
+
`;
|
|
3303
|
+
}
|
|
3304
|
+
function stringifyWithData(data, body) {
|
|
3305
|
+
return stringifyWithSerializedFrontmatter(stringifyFrontmatter(data), body);
|
|
3306
|
+
}
|
|
3307
|
+
function stringifyWithSerializedFrontmatter(dumped, body) {
|
|
3308
|
+
const content3 = body ?? "";
|
|
3309
|
+
const newline = (value) => value.endsWith("\n") ? value : `${value}
|
|
3310
|
+
`;
|
|
3311
|
+
if (dumped === "{}") return normalizeDocumentBodyForStorage(content3);
|
|
3312
|
+
return `---
|
|
3313
|
+
${newline(dumped)}---
|
|
3314
|
+
${normalizeDocumentBodyForStorage(content3)}`;
|
|
3315
|
+
}
|
|
3316
|
+
function stringifyDoc(frontmatter, body) {
|
|
3317
|
+
return stringifyWithData(frontmatter, body);
|
|
3318
|
+
}
|
|
3319
|
+
var import_js_yaml2, YAML_TIMESTAMP_TAG, yamlTimestampType, stringTimestampType, losslessDateSchema, yamlEngine;
|
|
3320
|
+
var init_frontmatter = __esm({
|
|
3321
|
+
"../core/src/frontmatter.ts"() {
|
|
3322
|
+
"use strict";
|
|
3323
|
+
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
3324
|
+
init_define_SUPERBEE_UPDATE_POLICY();
|
|
3325
|
+
import_js_yaml2 = __toESM(require_js_yaml2(), 1);
|
|
3326
|
+
init_bounded_yaml();
|
|
3327
|
+
init_errors();
|
|
3328
|
+
init_frontmatter_contract();
|
|
3329
|
+
init_frontmatter_splitter();
|
|
3330
|
+
init_frontmatter_contract();
|
|
3331
|
+
YAML_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
|
|
3332
|
+
yamlTimestampType = requireYamlTimestampType();
|
|
3333
|
+
stringTimestampType = new import_js_yaml2.default.Type(YAML_TIMESTAMP_TAG, {
|
|
3334
|
+
kind: "scalar",
|
|
3335
|
+
resolve: (value) => yamlTimestampType.resolve(value),
|
|
3336
|
+
construct: (value) => value
|
|
3337
|
+
});
|
|
3338
|
+
losslessDateSchema = new import_js_yaml2.default.Schema({
|
|
3339
|
+
include: [import_js_yaml2.default.DEFAULT_SAFE_SCHEMA],
|
|
3340
|
+
implicit: [stringTimestampType]
|
|
3341
|
+
});
|
|
3342
|
+
yamlEngine = {
|
|
3343
|
+
parse(input) {
|
|
3344
|
+
return loadBoundedYaml(input, { schema: losslessDateSchema }) ?? {};
|
|
3345
|
+
}
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
|
|
3066
3350
|
// ../core/src/portable-frontmatter.ts
|
|
3067
3351
|
function parseLeadingFrontmatter(raw, context3) {
|
|
3068
3352
|
const split = splitLeadingFrontmatter(raw, context3);
|
|
3069
3353
|
if (!("yamlSource" in split)) return {};
|
|
3070
3354
|
try {
|
|
3071
|
-
const parsed2 =
|
|
3355
|
+
const parsed2 = loadBoundedYaml(split.yamlSource);
|
|
3072
3356
|
if (parsed2 === void 0 || parsed2 === null) return {};
|
|
3073
3357
|
if (typeof parsed2 !== "object" || Array.isArray(parsed2)) {
|
|
3074
3358
|
throw new TypeError("YAML frontmatter must be a mapping");
|
|
@@ -3079,14 +3363,27 @@ function parseLeadingFrontmatter(raw, context3) {
|
|
|
3079
3363
|
throw new MalformedDocumentError(context3, error51);
|
|
3080
3364
|
}
|
|
3081
3365
|
}
|
|
3082
|
-
|
|
3366
|
+
function assertStorableFrontmatter(raw) {
|
|
3367
|
+
try {
|
|
3368
|
+
parseLeadingFrontmatter(raw);
|
|
3369
|
+
const split = splitLeadingFrontmatter(raw);
|
|
3370
|
+
if ("yamlSource" in split) parseFrontmatter(split.yamlSource);
|
|
3371
|
+
} catch (error51) {
|
|
3372
|
+
if (error51 instanceof MalformedDocumentError && error51.code !== "FRONTMATTER_MALFORMED") {
|
|
3373
|
+
throw new FrontmatterRefusedError(error51.code, error51.detail);
|
|
3374
|
+
}
|
|
3375
|
+
if (!(error51 instanceof MalformedDocumentError)) throw error51;
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3083
3378
|
var init_portable_frontmatter = __esm({
|
|
3084
3379
|
"../core/src/portable-frontmatter.ts"() {
|
|
3085
3380
|
"use strict";
|
|
3086
3381
|
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
3087
3382
|
init_define_SUPERBEE_UPDATE_POLICY();
|
|
3088
|
-
|
|
3383
|
+
init_bounded_yaml();
|
|
3384
|
+
init_errors();
|
|
3089
3385
|
init_frontmatter_contract();
|
|
3386
|
+
init_frontmatter();
|
|
3090
3387
|
init_frontmatter_splitter();
|
|
3091
3388
|
}
|
|
3092
3389
|
});
|
|
@@ -3495,93 +3792,6 @@ var init_inventory_guard = __esm({
|
|
|
3495
3792
|
}
|
|
3496
3793
|
});
|
|
3497
3794
|
|
|
3498
|
-
// ../core/src/frontmatter.ts
|
|
3499
|
-
function requireYamlTimestampType() {
|
|
3500
|
-
const type = import_js_yaml2.default.DEFAULT_SAFE_SCHEMA.implicit.find(
|
|
3501
|
-
(candidate) => candidate.tag === YAML_TIMESTAMP_TAG
|
|
3502
|
-
);
|
|
3503
|
-
if (!type) throw new Error("js-yaml safe schema is missing its timestamp type");
|
|
3504
|
-
return type;
|
|
3505
|
-
}
|
|
3506
|
-
function normalizeFrontmatter(data, options) {
|
|
3507
|
-
const out = { ...data };
|
|
3508
|
-
if (options.preserveTimestamp || options.okfVersion === "0.2") return out;
|
|
3509
|
-
const value = out.timestamp;
|
|
3510
|
-
if (value instanceof Date) {
|
|
3511
|
-
out.timestamp = value.toISOString();
|
|
3512
|
-
} else if (typeof value === "number" && Number.isFinite(value)) {
|
|
3513
|
-
out.timestamp = new Date(value).toISOString();
|
|
3514
|
-
} else if (typeof value === "string" && yamlTimestampType.resolve(value)) {
|
|
3515
|
-
const parsed2 = yamlTimestampType.construct(value);
|
|
3516
|
-
if (parsed2 instanceof Date) out.timestamp = parsed2.toISOString();
|
|
3517
|
-
}
|
|
3518
|
-
return out;
|
|
3519
|
-
}
|
|
3520
|
-
function parseMarkdown(raw, context3, options = {}) {
|
|
3521
|
-
const split = splitLeadingFrontmatter(raw, context3);
|
|
3522
|
-
if (!("yamlSource" in split)) return { frontmatter: {}, body: split.body };
|
|
3523
|
-
return { frontmatter: parseFrontmatter(split.yamlSource, context3, options), body: split.body };
|
|
3524
|
-
}
|
|
3525
|
-
function parseFrontmatter(source2, context3, options = {}) {
|
|
3526
|
-
let parsed2;
|
|
3527
|
-
try {
|
|
3528
|
-
parsed2 = yamlEngine.parse(source2);
|
|
3529
|
-
} catch (err) {
|
|
3530
|
-
throw new MalformedDocumentError(context3, err);
|
|
3531
|
-
}
|
|
3532
|
-
return normalizeFrontmatter(parsed2, options);
|
|
3533
|
-
}
|
|
3534
|
-
function stringifyFrontmatter(data) {
|
|
3535
|
-
return import_js_yaml2.default.safeDump(data).trim();
|
|
3536
|
-
}
|
|
3537
|
-
function normalizeDocumentBodyForStorage(body) {
|
|
3538
|
-
return body.endsWith("\n") ? body : `${body}
|
|
3539
|
-
`;
|
|
3540
|
-
}
|
|
3541
|
-
function stringifyWithData(data, body) {
|
|
3542
|
-
return stringifyWithSerializedFrontmatter(stringifyFrontmatter(data), body);
|
|
3543
|
-
}
|
|
3544
|
-
function stringifyWithSerializedFrontmatter(dumped, body) {
|
|
3545
|
-
const content3 = body ?? "";
|
|
3546
|
-
const newline = (value) => value.endsWith("\n") ? value : `${value}
|
|
3547
|
-
`;
|
|
3548
|
-
if (dumped === "{}") return normalizeDocumentBodyForStorage(content3);
|
|
3549
|
-
return `---
|
|
3550
|
-
${newline(dumped)}---
|
|
3551
|
-
${normalizeDocumentBodyForStorage(content3)}`;
|
|
3552
|
-
}
|
|
3553
|
-
function stringifyDoc(frontmatter, body) {
|
|
3554
|
-
return stringifyWithData(frontmatter, body);
|
|
3555
|
-
}
|
|
3556
|
-
var import_js_yaml2, YAML_TIMESTAMP_TAG, yamlTimestampType, stringTimestampType, losslessDateSchema, yamlEngine;
|
|
3557
|
-
var init_frontmatter = __esm({
|
|
3558
|
-
"../core/src/frontmatter.ts"() {
|
|
3559
|
-
"use strict";
|
|
3560
|
-
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
3561
|
-
init_define_SUPERBEE_UPDATE_POLICY();
|
|
3562
|
-
import_js_yaml2 = __toESM(require_js_yaml2(), 1);
|
|
3563
|
-
init_frontmatter_contract();
|
|
3564
|
-
init_frontmatter_splitter();
|
|
3565
|
-
init_frontmatter_contract();
|
|
3566
|
-
YAML_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
|
|
3567
|
-
yamlTimestampType = requireYamlTimestampType();
|
|
3568
|
-
stringTimestampType = new import_js_yaml2.default.Type(YAML_TIMESTAMP_TAG, {
|
|
3569
|
-
kind: "scalar",
|
|
3570
|
-
resolve: (value) => yamlTimestampType.resolve(value),
|
|
3571
|
-
construct: (value) => value
|
|
3572
|
-
});
|
|
3573
|
-
losslessDateSchema = new import_js_yaml2.default.Schema({
|
|
3574
|
-
include: [import_js_yaml2.default.DEFAULT_SAFE_SCHEMA],
|
|
3575
|
-
implicit: [stringTimestampType]
|
|
3576
|
-
});
|
|
3577
|
-
yamlEngine = {
|
|
3578
|
-
parse(input) {
|
|
3579
|
-
return import_js_yaml2.default.safeLoad(input, { schema: losslessDateSchema }) ?? {};
|
|
3580
|
-
}
|
|
3581
|
-
};
|
|
3582
|
-
}
|
|
3583
|
-
});
|
|
3584
|
-
|
|
3585
3795
|
// ../core/src/code-unit-order.ts
|
|
3586
3796
|
function compareCodeUnits(a, b) {
|
|
3587
3797
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -5349,6 +5559,22 @@ var init_content_type = __esm({
|
|
|
5349
5559
|
}
|
|
5350
5560
|
});
|
|
5351
5561
|
|
|
5562
|
+
// ../core/src/reserved-write.ts
|
|
5563
|
+
function assertStorableReservedWrite(dir, name, content3) {
|
|
5564
|
+
assertSafeReservedDir(dir);
|
|
5565
|
+
assertSafeReservedFilename(name);
|
|
5566
|
+
if (name.endsWith(".md")) assertStorableFrontmatter(content3);
|
|
5567
|
+
}
|
|
5568
|
+
var init_reserved_write = __esm({
|
|
5569
|
+
"../core/src/reserved-write.ts"() {
|
|
5570
|
+
"use strict";
|
|
5571
|
+
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
5572
|
+
init_define_SUPERBEE_UPDATE_POLICY();
|
|
5573
|
+
init_paths();
|
|
5574
|
+
init_portable_frontmatter();
|
|
5575
|
+
}
|
|
5576
|
+
});
|
|
5577
|
+
|
|
5352
5578
|
// ../core/src/host-policy-snapshot.ts
|
|
5353
5579
|
function snapshotHostPolicy(input, seen = /* @__PURE__ */ new WeakMap()) {
|
|
5354
5580
|
const existing = seen.get(input);
|
|
@@ -6688,6 +6914,7 @@ var init_backend = __esm({
|
|
|
6688
6914
|
init_engine();
|
|
6689
6915
|
init_content_type();
|
|
6690
6916
|
init_paths();
|
|
6917
|
+
init_reserved_write();
|
|
6691
6918
|
init_errors();
|
|
6692
6919
|
init_filesystem_identity();
|
|
6693
6920
|
init_mutation_attribution();
|
|
@@ -6884,8 +7111,7 @@ var init_backend = __esm({
|
|
|
6884
7111
|
return { content: content3, version: versionOfBytes(content3) };
|
|
6885
7112
|
}
|
|
6886
7113
|
async writeReserved(dir, name, content3, options = {}) {
|
|
6887
|
-
|
|
6888
|
-
assertSafeReservedFilename(name);
|
|
7114
|
+
assertStorableReservedWrite(dir, name, content3);
|
|
6889
7115
|
const rel = reservedPath(dir, name);
|
|
6890
7116
|
return this.#mutateExact(rel, async (target3) => {
|
|
6891
7117
|
if (options.expectedVersion !== void 0) {
|
|
@@ -9255,6 +9481,7 @@ var init_memory_backend = __esm({
|
|
|
9255
9481
|
init_engine();
|
|
9256
9482
|
init_frontmatter();
|
|
9257
9483
|
init_paths();
|
|
9484
|
+
init_reserved_write();
|
|
9258
9485
|
init_versioning();
|
|
9259
9486
|
MemoryBackend = class _MemoryBackend {
|
|
9260
9487
|
#inventoryIdentity;
|
|
@@ -9377,8 +9604,7 @@ var init_memory_backend = __esm({
|
|
|
9377
9604
|
return { content: content3, version: versionOfBytes(content3) };
|
|
9378
9605
|
}
|
|
9379
9606
|
async writeReserved(dir, name, content3, options = {}) {
|
|
9380
|
-
|
|
9381
|
-
assertSafeReservedFilename(name);
|
|
9607
|
+
assertStorableReservedWrite(dir, name, content3);
|
|
9382
9608
|
const key4 = reservedKey(dir, name);
|
|
9383
9609
|
const existing = this.reserved.get(key4);
|
|
9384
9610
|
const current = existing === void 0 ? null : versionOfBytes(existing);
|
|
@@ -10204,6 +10430,7 @@ var init_remote_backend = __esm({
|
|
|
10204
10430
|
init_remote_error();
|
|
10205
10431
|
init_remote_parsers();
|
|
10206
10432
|
init_paths();
|
|
10433
|
+
init_reserved_write();
|
|
10207
10434
|
init_uncertain_write();
|
|
10208
10435
|
init_version_transport();
|
|
10209
10436
|
init_remote_error();
|
|
@@ -10276,11 +10503,16 @@ var init_remote_backend = __esm({
|
|
|
10276
10503
|
}
|
|
10277
10504
|
const malformedDoc = envelope3?.error?.details?.malformed;
|
|
10278
10505
|
if (malformedDoc && typeof malformedDoc.reason === "string") {
|
|
10506
|
+
const code4 = malformedDoc.code;
|
|
10279
10507
|
return new MalformedDocumentError(
|
|
10280
10508
|
typeof malformedDoc.id === "string" ? malformedDoc.id : fallbackId,
|
|
10281
|
-
new Error(malformedDoc.reason)
|
|
10509
|
+
isFrontmatterLimitCode(code4) ? new FrontmatterLimitError(code4, malformedDoc.reason) : new Error(malformedDoc.reason)
|
|
10282
10510
|
);
|
|
10283
10511
|
}
|
|
10512
|
+
const refused = envelope3?.error?.details?.frontmatter?.code;
|
|
10513
|
+
if (res.status === 400 && (refused === "FRONTMATTER_MALFORMED" || isFrontmatterLimitCode(refused))) {
|
|
10514
|
+
return new FrontmatterRefusedError(refused, envelope3?.error?.message ?? "frontmatter cannot be stored");
|
|
10515
|
+
}
|
|
10284
10516
|
const message = envelope3?.error?.message ?? `wire request failed with status ${res.status}`;
|
|
10285
10517
|
const code3 = envelope3?.error?.code ?? (res.status === 401 ? "AUTH_REQUIRED" : res.status >= 500 ? "RUNTIME" : "USAGE");
|
|
10286
10518
|
return new RemoteError(message, code3, res.status);
|
|
@@ -10566,8 +10798,7 @@ var init_remote_backend = __esm({
|
|
|
10566
10798
|
return { content: payload.content, version: version5 };
|
|
10567
10799
|
}
|
|
10568
10800
|
async writeReserved(dir, name, content3, options = {}) {
|
|
10569
|
-
|
|
10570
|
-
assertSafeReservedFilename(name);
|
|
10801
|
+
assertStorableReservedWrite(dir, name, content3);
|
|
10571
10802
|
assertValidExpectedVersion(options.expectedVersion);
|
|
10572
10803
|
const headers = { "content-type": "application/json" };
|
|
10573
10804
|
if (options.expectedVersion === null) headers["If-None-Match"] = "*";
|
|
@@ -15094,10 +15325,13 @@ __export(src_exports, {
|
|
|
15094
15325
|
DOCUMENT_TRANSFER_CONTRACT: () => DOCUMENT_TRANSFER_CONTRACT,
|
|
15095
15326
|
DocumentNotFoundError: () => DocumentNotFoundError,
|
|
15096
15327
|
EXTENSION_CONTENT_TYPES: () => EXTENSION_CONTENT_TYPES,
|
|
15328
|
+
FRONTMATTER_LIMITS: () => FRONTMATTER_LIMITS,
|
|
15097
15329
|
FieldActionError: () => FieldActionError,
|
|
15098
15330
|
FilesystemBackend: () => FilesystemBackend,
|
|
15099
15331
|
FilesystemIdentityAliasError: () => FilesystemIdentityAliasError,
|
|
15100
15332
|
FilesystemMutationLockError: () => FilesystemMutationLockError,
|
|
15333
|
+
FrontmatterLimitError: () => FrontmatterLimitError,
|
|
15334
|
+
FrontmatterRefusedError: () => FrontmatterRefusedError,
|
|
15101
15335
|
GENERATED_INDEX_MARKER: () => GENERATED_INDEX_MARKER,
|
|
15102
15336
|
INVENTORY_GUARD_DOMAIN: () => INVENTORY_GUARD_DOMAIN,
|
|
15103
15337
|
IndexProjectionWriteError: () => IndexProjectionWriteError,
|
|
@@ -15157,6 +15391,7 @@ __export(src_exports, {
|
|
|
15157
15391
|
assertSafeReservedDir: () => assertSafeReservedDir,
|
|
15158
15392
|
assertSafeReservedFilename: () => assertSafeReservedFilename,
|
|
15159
15393
|
assertSameBodyDelivery: () => assertSameBodyDelivery,
|
|
15394
|
+
assertStorableFrontmatter: () => assertStorableFrontmatter,
|
|
15160
15395
|
assertTypedListPatch: () => assertTypedListPatch,
|
|
15161
15396
|
attachBodyPreview: () => attachBodyPreview,
|
|
15162
15397
|
backlinks: () => backlinks2,
|
|
@@ -15239,6 +15474,7 @@ __export(src_exports, {
|
|
|
15239
15474
|
latestVerifiedAt: () => latestVerifiedAt,
|
|
15240
15475
|
list: () => list,
|
|
15241
15476
|
listBlobs: () => listBlobs2,
|
|
15477
|
+
loadBoundedYaml: () => loadBoundedYaml,
|
|
15242
15478
|
loadKinds: () => loadKinds,
|
|
15243
15479
|
localEdgeQualifiedDeclaration: () => localEdgeQualifiedDeclaration,
|
|
15244
15480
|
matchesFilter: () => matchesFilter,
|
|
@@ -15367,6 +15603,9 @@ var init_src = __esm({
|
|
|
15367
15603
|
init_freshness();
|
|
15368
15604
|
init_mutation_attribution();
|
|
15369
15605
|
init_frontmatter();
|
|
15606
|
+
init_bounded_yaml();
|
|
15607
|
+
init_portable_frontmatter();
|
|
15608
|
+
init_frontmatter_contract();
|
|
15370
15609
|
init_errors();
|
|
15371
15610
|
init_document_write_policy();
|
|
15372
15611
|
init_kinds();
|
|
@@ -26003,6 +26242,7 @@ __export(errors_exports, {
|
|
|
26003
26242
|
cliErrorFromBoardGit: () => cliErrorFromBoardGit,
|
|
26004
26243
|
cliErrorFromRecipeLifecycle: () => cliErrorFromRecipeLifecycle,
|
|
26005
26244
|
cliErrorFromTransfer: () => cliErrorFromTransfer,
|
|
26245
|
+
frontmatterDetails: () => frontmatterDetails,
|
|
26006
26246
|
toEnvelope: () => toEnvelope,
|
|
26007
26247
|
toExit: () => toExit
|
|
26008
26248
|
});
|
|
@@ -26012,6 +26252,9 @@ function toEnvelope(err) {
|
|
|
26012
26252
|
if (err.help !== void 0) e.help = err.help;
|
|
26013
26253
|
return { error: e };
|
|
26014
26254
|
}
|
|
26255
|
+
function frontmatterDetails(err) {
|
|
26256
|
+
return { frontmatter: { code: err.code, ...err.context !== void 0 ? { document: err.context } : {} } };
|
|
26257
|
+
}
|
|
26015
26258
|
function classifyBundleError(err, remoteUrl) {
|
|
26016
26259
|
if (err instanceof CliError) return err;
|
|
26017
26260
|
if (isBoardGitError(err)) return cliErrorFromBoardGit(err);
|
|
@@ -26023,8 +26266,9 @@ function classifyBundleError(err, remoteUrl) {
|
|
|
26023
26266
|
return new CliError("USAGE", refusal6.message, { help: refusal6.help, details: { actor: err.actor } });
|
|
26024
26267
|
}
|
|
26025
26268
|
if (err instanceof FieldActionError) return new CliError("USAGE", err.message, { details: { ...err.details } });
|
|
26269
|
+
if (err instanceof FrontmatterRefusedError) return new CliError("USAGE", err.message, { details: { frontmatter: { code: err.code } } });
|
|
26026
26270
|
if (err instanceof InvalidInputError) return new CliError("USAGE", err.message);
|
|
26027
|
-
if (err instanceof MalformedDocumentError) return new CliError("RUNTIME", err.message);
|
|
26271
|
+
if (err instanceof MalformedDocumentError) return new CliError("RUNTIME", err.message, { details: frontmatterDetails(err) });
|
|
26028
26272
|
if (err instanceof VersionConflict) {
|
|
26029
26273
|
return new CliError("STALE_HEAD", err.message, {
|
|
26030
26274
|
details: { expected: err.expected, actual: err.actual }
|
|
@@ -30717,6 +30961,8 @@ var init_document_codec = __esm({
|
|
|
30717
30961
|
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
30718
30962
|
init_define_SUPERBEE_UPDATE_POLICY();
|
|
30719
30963
|
init_frontmatter();
|
|
30964
|
+
init_errors();
|
|
30965
|
+
init_portable_frontmatter();
|
|
30720
30966
|
init_remote_document_codec();
|
|
30721
30967
|
}
|
|
30722
30968
|
});
|
|
@@ -33644,7 +33890,13 @@ var init_source_plugins = __esm({
|
|
|
33644
33890
|
// ../cli/src/recipe-resolver.ts
|
|
33645
33891
|
async function resolveRecipe(ref, sources = DEFAULT_SOURCES) {
|
|
33646
33892
|
for (const source2 of sources) {
|
|
33647
|
-
|
|
33893
|
+
let result3;
|
|
33894
|
+
try {
|
|
33895
|
+
result3 = await source2.resolve(ref);
|
|
33896
|
+
} catch (error51) {
|
|
33897
|
+
if (error51 instanceof MalformedDocumentError) throw new CliError("USAGE", error51.message, { details: frontmatterDetails(error51) });
|
|
33898
|
+
throw error51;
|
|
33899
|
+
}
|
|
33648
33900
|
if (result3) return result3;
|
|
33649
33901
|
}
|
|
33650
33902
|
return {
|
|
@@ -33661,6 +33913,8 @@ var init_recipe_resolver = __esm({
|
|
|
33661
33913
|
"use strict";
|
|
33662
33914
|
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
33663
33915
|
init_define_SUPERBEE_UPDATE_POLICY();
|
|
33916
|
+
init_src();
|
|
33917
|
+
init_errors6();
|
|
33664
33918
|
init_source_plugins();
|
|
33665
33919
|
init_recipe_source_builtin();
|
|
33666
33920
|
init_recipe_source_filesystem();
|
|
@@ -35844,9 +36098,9 @@ async function docField(argv2, deps2) {
|
|
|
35844
36098
|
const source2 = await readExternalTextFile(fromFile);
|
|
35845
36099
|
if (!source2.trim()) fail4("--from-file must contain one complete JSON/YAML value; the file is empty.");
|
|
35846
36100
|
try {
|
|
35847
|
-
value = /\.json$/i.test(fromFile) ? JSON.parse(source2) :
|
|
35848
|
-
} catch {
|
|
35849
|
-
fail4("--from-file must contain one complete valid JSON/YAML value.");
|
|
36101
|
+
value = /\.json$/i.test(fromFile) ? JSON.parse(source2) : loadBoundedYaml(source2, { schema: "json" });
|
|
36102
|
+
} catch (error51) {
|
|
36103
|
+
fail4(error51 instanceof FrontmatterLimitError ? `--from-file was refused: ${error51.message}.` : "--from-file must contain one complete valid JSON/YAML value.");
|
|
35850
36104
|
}
|
|
35851
36105
|
if (value === void 0) fail4("--from-file must contain one complete JSON/YAML value.");
|
|
35852
36106
|
}
|
|
@@ -35916,14 +36170,13 @@ async function docField(argv2, deps2) {
|
|
|
35916
36170
|
throw error51;
|
|
35917
36171
|
}
|
|
35918
36172
|
}
|
|
35919
|
-
var
|
|
36173
|
+
var leaves, descriptions, DOC_FIELD_USAGE;
|
|
35920
36174
|
var init_field = __esm({
|
|
35921
36175
|
"../cli/src/commands/doc/field.ts"() {
|
|
35922
36176
|
"use strict";
|
|
35923
36177
|
init_define_SUPERBEE_BUILD_IDENTITY();
|
|
35924
36178
|
init_define_SUPERBEE_UPDATE_POLICY();
|
|
35925
36179
|
init_output2();
|
|
35926
|
-
import_js_yaml3 = __toESM(require_js_yaml2(), 1);
|
|
35927
36180
|
init_src();
|
|
35928
36181
|
init_args();
|
|
35929
36182
|
init_command_spec();
|
|
@@ -37902,7 +38155,7 @@ function head(value) {
|
|
|
37902
38155
|
throw malformed(error51 instanceof Error ? error51.message : "malformed blob head");
|
|
37903
38156
|
}
|
|
37904
38157
|
}
|
|
37905
|
-
function
|
|
38158
|
+
function tooLarge2(maximum) {
|
|
37906
38159
|
return new HostedCarrierError("unavailable", { cause: new HostedAnswerTooLarge(maximum) });
|
|
37907
38160
|
}
|
|
37908
38161
|
function createHostedBlobReadAdapter(options) {
|
|
@@ -38001,7 +38254,7 @@ function createHostedBlobReadAdapter(options) {
|
|
|
38001
38254
|
const lengthText = answer2.headers.get("content-length");
|
|
38002
38255
|
if (answer2.status !== 200 || answer2.headers.get("content-type") !== "application/octet-stream" || answer2.headers.get("x-superbee-blob-version") !== expected.version || answer2.headers.get("x-superbee-content-type") !== expected.contentType || lengthText === null || !/^(0|[1-9][0-9]*)$/.test(lengthText) || !whole(Number(lengthText))) throw malformed("blob read headers do not match the pin");
|
|
38003
38256
|
const length = Number(lengthText);
|
|
38004
|
-
if (length > maximum) throw
|
|
38257
|
+
if (length > maximum) throw tooLarge2(maximum);
|
|
38005
38258
|
const bytes2 = new Uint8Array(length);
|
|
38006
38259
|
let offset = 0;
|
|
38007
38260
|
for (; ; ) {
|
|
@@ -38009,7 +38262,7 @@ function createHostedBlobReadAdapter(options) {
|
|
|
38009
38262
|
assertOpen();
|
|
38010
38263
|
if (chunk.done) break;
|
|
38011
38264
|
if (!(chunk.value instanceof Uint8Array)) throw malformed("blob read yielded non-byte content");
|
|
38012
|
-
if (chunk.value.byteLength > maximum - offset) throw
|
|
38265
|
+
if (chunk.value.byteLength > maximum - offset) throw tooLarge2(maximum);
|
|
38013
38266
|
if (chunk.value.byteLength > length - offset) throw malformed("blob read exceeded its stated length");
|
|
38014
38267
|
bytes2.set(chunk.value, offset);
|
|
38015
38268
|
offset += chunk.value.byteLength;
|
|
@@ -43716,6 +43969,7 @@ var init_indexeddb_backend = __esm({
|
|
|
43716
43969
|
init_mutation_attribution();
|
|
43717
43970
|
init_journaled_backend();
|
|
43718
43971
|
init_paths();
|
|
43972
|
+
init_reserved_write();
|
|
43719
43973
|
init_portable_frontmatter();
|
|
43720
43974
|
init_versioning();
|
|
43721
43975
|
IndexedDbSchemaError = class extends Error {
|
|
@@ -44077,8 +44331,7 @@ var init_indexeddb_backend = __esm({
|
|
|
44077
44331
|
return { content: record19.content, version: record19.version };
|
|
44078
44332
|
}
|
|
44079
44333
|
async writeReserved(dir, name, content3, options = {}) {
|
|
44080
|
-
|
|
44081
|
-
assertSafeReservedFilename(name);
|
|
44334
|
+
assertStorableReservedWrite(dir, name, content3);
|
|
44082
44335
|
const path75 = reservedKey2(dir, name);
|
|
44083
44336
|
return this.#compareAndSwap(RESERVED, path75, path75, options.expectedVersion, () => ({
|
|
44084
44337
|
record: { path: path75, content: content3, version: versionOfBytes(content3) }
|
|
@@ -46429,6 +46682,7 @@ var init_file_journaled_backend = __esm({
|
|
|
46429
46682
|
init_journaled_backend();
|
|
46430
46683
|
init_mutation_attribution();
|
|
46431
46684
|
init_paths();
|
|
46685
|
+
init_reserved_write();
|
|
46432
46686
|
init_portable_frontmatter();
|
|
46433
46687
|
init_sha256();
|
|
46434
46688
|
init_versioning();
|
|
@@ -46806,8 +47060,7 @@ var init_file_journaled_backend = __esm({
|
|
|
46806
47060
|
return record19 ? { content: record19.content, version: record19.version } : null;
|
|
46807
47061
|
}
|
|
46808
47062
|
async writeReserved(dir, name, content3, options = {}) {
|
|
46809
|
-
|
|
46810
|
-
assertSafeReservedFilename(name);
|
|
47063
|
+
assertStorableReservedWrite(dir, name, content3);
|
|
46811
47064
|
const key4 = reservedKey3(dir, name);
|
|
46812
47065
|
const version5 = versionOfBytes(content3);
|
|
46813
47066
|
const expected = options.expectedVersion;
|
|
@@ -51042,7 +51295,7 @@ function foldedPath(id) {
|
|
|
51042
51295
|
function documentInputBound(stated) {
|
|
51043
51296
|
return stated ?? WHOLE_DOCUMENT_BOUNDS.payloadBytes;
|
|
51044
51297
|
}
|
|
51045
|
-
function
|
|
51298
|
+
function tooLarge3(id, size, stated) {
|
|
51046
51299
|
const kib = (bytes2) => Math.ceil(bytes2 / 1024);
|
|
51047
51300
|
const bound2 = documentInputBound(stated);
|
|
51048
51301
|
return stated === null || stated === void 0 ? `'${id}' is ${kib(size)} KiB as sent; this host accepts up to ${kib(bound2)} KiB per document (newer hosts accept about 960 KiB as sent)` : `'${id}' is ${kib(size)} KiB as sent; this host accepts up to ${kib(bound2)} KiB per document`;
|
|
@@ -51076,7 +51329,7 @@ function unsendable(id, rel, bytes2, stored, context3, fence) {
|
|
|
51076
51329
|
}
|
|
51077
51330
|
const bound2 = documentInputBound(context3.documentInputBytes);
|
|
51078
51331
|
const screen = context3.documentInputBytes === null || context3.documentInputBytes === void 0 ? bound2 : Math.max(bound2, STORED_DOCUMENT_BYTES);
|
|
51079
|
-
if (bytes2.byteLength > screen) return held(id, rel, "too_large",
|
|
51332
|
+
if (bytes2.byteLength > screen) return held(id, rel, "too_large", tooLarge3(id, bytes2.byteLength, context3.documentInputBytes));
|
|
51080
51333
|
const content3 = utf83(bytes2);
|
|
51081
51334
|
if (content3 === null) return held(id, rel, "not_sendable", `'${id}' is not UTF-8 text; sending it would change its bytes`);
|
|
51082
51335
|
let request4;
|
|
@@ -51089,7 +51342,7 @@ function unsendable(id, rel, bytes2, stored, context3, fence) {
|
|
|
51089
51342
|
if (request4.kind === "delete") throw new Error(`'${id}' became a delete request`);
|
|
51090
51343
|
const { frontmatter } = request4.payload;
|
|
51091
51344
|
const sent = Buffer.byteLength(JSON.stringify(request4.payload));
|
|
51092
|
-
if (sent > bound2) return held(id, rel, "too_large",
|
|
51345
|
+
if (sent > bound2) return held(id, rel, "too_large", tooLarge3(id, sent, context3.documentInputBytes));
|
|
51093
51346
|
if (Buffer.byteLength(JSON.stringify(frontmatter)) > FRONTMATTER_JSON_BYTES || Object.keys(frontmatter).length > FRONTMATTER_KEY_LIMIT) {
|
|
51094
51347
|
return held(id, rel, "too_large", `'${id}' has more frontmatter than the host accepts (${FRONTMATTER_JSON_BYTES / 1024} KiB, ${FRONTMATTER_KEY_LIMIT} fields)`);
|
|
51095
51348
|
}
|
|
@@ -100105,6 +100358,9 @@ function errorFromCaught(err) {
|
|
|
100105
100358
|
if (err instanceof BodyReplaceError) {
|
|
100106
100359
|
return errorResponse(400, "USAGE", err.message, { id: err.id, ...err.finding });
|
|
100107
100360
|
}
|
|
100361
|
+
if (err instanceof FrontmatterRefusedError) {
|
|
100362
|
+
return errorResponse(400, "USAGE", err.message, { frontmatter: { code: err.code } });
|
|
100363
|
+
}
|
|
100108
100364
|
if (err instanceof InvalidInputError) {
|
|
100109
100365
|
return errorResponse(400, "USAGE", err.message);
|
|
100110
100366
|
}
|
|
@@ -100114,7 +100370,7 @@ function errorFromCaught(err) {
|
|
|
100114
100370
|
if (err instanceof MalformedDocumentError) {
|
|
100115
100371
|
const id = err.context === void 0 ? void 0 : err.context.endsWith(".md") ? err.context.slice(0, -3) : err.context;
|
|
100116
100372
|
return errorResponse(500, "RUNTIME", err.message, {
|
|
100117
|
-
malformed: { ...id === void 0 ? {} : { id }, reason: err.detail }
|
|
100373
|
+
malformed: { ...id === void 0 ? {} : { id }, reason: err.detail, code: err.code }
|
|
100118
100374
|
});
|
|
100119
100375
|
}
|
|
100120
100376
|
return errorResponse(500, "RUNTIME", "internal server error");
|
|
@@ -100644,6 +100900,7 @@ function buildRouter(options) {
|
|
|
100644
100900
|
return errorResponse(400, "USAGE", "request body must include a content: string field");
|
|
100645
100901
|
}
|
|
100646
100902
|
const writeOptions = writeOptionsFromRequest(req, attribution);
|
|
100903
|
+
assertStorableFrontmatter(payload.content);
|
|
100647
100904
|
const version5 = await backend.writeReserved(dir, name, payload.content, writeOptions);
|
|
100648
100905
|
const status2 = writeOptions.expectedVersion === null ? 201 : 200;
|
|
100649
100906
|
return jsonResponse(status2, { version: version5 }, versionHeaders(version5));
|
|
@@ -109452,6 +109709,9 @@ var init_files = __esm({
|
|
|
109452
109709
|
});
|
|
109453
109710
|
|
|
109454
109711
|
// ../cli/src/integration-author/validate.ts
|
|
109712
|
+
function frontmatterCode(error51) {
|
|
109713
|
+
return error51 instanceof MalformedDocumentError ? { frontmatter_code: error51.code } : {};
|
|
109714
|
+
}
|
|
109455
109715
|
function safeDiagnostic(code3, file2, pointer2, message) {
|
|
109456
109716
|
return { code: code3, file: authorLocation(file2), path: authorLocation(pointer2), message: authorLocation(message) };
|
|
109457
109717
|
}
|
|
@@ -109464,8 +109724,8 @@ async function loadAuthorRecipe(folder) {
|
|
|
109464
109724
|
if (!file2.path.endsWith(".md")) continue;
|
|
109465
109725
|
try {
|
|
109466
109726
|
docs.push({ id: file2.path.slice(0, -3), ...parseMarkdown(file2.bytes) });
|
|
109467
|
-
} catch {
|
|
109468
|
-
diagnostics.push(safeDiagnostic("AUTHOR_MARKDOWN_INVALID", file2.path, "", "Invalid Markdown frontmatter; repair this file before validation."));
|
|
109727
|
+
} catch (error51) {
|
|
109728
|
+
diagnostics.push({ ...safeDiagnostic("AUTHOR_MARKDOWN_INVALID", file2.path, "", "Invalid Markdown frontmatter; repair this file before validation."), ...frontmatterCode(error51) });
|
|
109469
109729
|
}
|
|
109470
109730
|
}
|
|
109471
109731
|
if (diagnostics.length) return { ok: false, diagnostics };
|
|
@@ -109479,8 +109739,8 @@ async function loadAuthorRecipe(folder) {
|
|
|
109479
109739
|
let loaded;
|
|
109480
109740
|
try {
|
|
109481
109741
|
loaded = parseRecipeFiles(acquired.files, "local author package", { okfVersion: "0.2" });
|
|
109482
|
-
} catch {
|
|
109483
|
-
diagnostics.push(safeDiagnostic("RECIPE_MALFORMED", "recipe.md", "", "The recipe could not be parsed; repair its declarations."));
|
|
109742
|
+
} catch (error51) {
|
|
109743
|
+
diagnostics.push({ ...safeDiagnostic("RECIPE_MALFORMED", "recipe.md", "", "The recipe could not be parsed; repair its declarations."), ...frontmatterCode(error51) });
|
|
109484
109744
|
return { ok: false, diagnostics };
|
|
109485
109745
|
}
|
|
109486
109746
|
if (!loaded.ok) {
|
|
@@ -156109,10 +156369,10 @@ function capabilityRefusal(error51, named, target3, listed2, resume2) {
|
|
|
156109
156369
|
help: hostedListCommand(target3)
|
|
156110
156370
|
});
|
|
156111
156371
|
}
|
|
156112
|
-
if (error51 instanceof RemoteError && error51.code === "result_too_large") return
|
|
156372
|
+
if (error51 instanceof RemoteError && error51.code === "result_too_large") return tooLarge4(reference, target3, null);
|
|
156113
156373
|
return hostedFailure(error51, target3, resume2);
|
|
156114
156374
|
}
|
|
156115
|
-
function
|
|
156375
|
+
function tooLarge4(named, target3, count6, limit = CHECKOUT_DOCUMENT_LIMIT) {
|
|
156116
156376
|
const reference = typeof named === "string" ? { slug: null, bundleId: named } : named;
|
|
156117
156377
|
const text7 = hostedBundleReferenceText(reference);
|
|
156118
156378
|
return new CliError("FORBIDDEN", `hosted bundle '${text7}' is too large to check out (over ${limit} documents)`, {
|
|
@@ -156567,7 +156827,7 @@ async function connectHostedBundle(typed, target3, workspaceFlag2, deps2, resume
|
|
|
156567
156827
|
throw capabilityRefusal(error51, reference, target3, listed2, resume2);
|
|
156568
156828
|
}
|
|
156569
156829
|
const limit = Math.min(CHECKOUT_DOCUMENT_LIMIT, capabilities.paged?.documents ?? capabilities.bound.documents);
|
|
156570
|
-
if (ids.length > limit) throw
|
|
156830
|
+
if (ids.length > limit) throw tooLarge4(reference, target3, ids.length, limit);
|
|
156571
156831
|
assertProjectable(ids, bundleId2, target3);
|
|
156572
156832
|
return { identity, reader, listed: listed2, workspace: tenantId ?? workspace, reference, client, definitionWrites: capabilities.definitionWrites, documentInputBytes: capabilities.documentInputBytes };
|
|
156573
156833
|
}
|