@thatopen/services 0.19.0 → 0.21.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/dist/cli.js CHANGED
@@ -6795,6 +6795,525 @@ Object.assign(lookup, {
6795
6795
  io: lookup,
6796
6796
  connect: lookup
6797
6797
  });
6798
+ class StaleHistoryError extends Error {
6799
+ constructor(expectedGuid, actualGuid) {
6800
+ super(
6801
+ `The document history advanced while this version was being prepared: expected head ${expectedGuid}, found ${actualGuid ?? "none"}. Read the timeline again and rebuild on the new head.`
6802
+ );
6803
+ this.expectedGuid = expectedGuid;
6804
+ this.actualGuid = actualGuid;
6805
+ this.name = "StaleHistoryError";
6806
+ }
6807
+ }
6808
+ const ROOT_FOLDER = "bimterop";
6809
+ const HISTORY_FILE = "revitflow_history.json";
6810
+ const OPS_FILE = "revitflow_ops.json";
6811
+ const OPS_SCHEMA = "revitflow/ops@1";
6812
+ const LEGACY_MODEL_FILE = "revitflow_model.frag";
6813
+ const INTERNAL_PREFIX = "revitflow_";
6814
+ const versionTag = () => `v-${Date.now()}`;
6815
+ function childrenOf(folders, parentId) {
6816
+ return folders.filter((f) => String(f.parentId ?? "") === parentId);
6817
+ }
6818
+ function idOf(item) {
6819
+ return String(item._id ?? item.id ?? "");
6820
+ }
6821
+ class ProjectHistory {
6822
+ constructor(client, projectId) {
6823
+ this.client = client;
6824
+ this.projectId = projectId;
6825
+ }
6826
+ #rootFolderId;
6827
+ /** The project's connected documents. */
6828
+ async docs() {
6829
+ const root = await this.#root();
6830
+ if (!root) return [];
6831
+ const folders = await this.client.listFolders({
6832
+ parentFolderId: root,
6833
+ projectId: this.projectId
6834
+ });
6835
+ const docs = [];
6836
+ for (const folder of childrenOf(folders, root)) {
6837
+ const name = String(folder.name ?? "");
6838
+ const dash = name.indexOf("-");
6839
+ if (dash <= 0) continue;
6840
+ docs.push({
6841
+ source: name.slice(0, dash),
6842
+ docId: name.slice(dash + 1),
6843
+ modelName: void 0
6844
+ });
6845
+ }
6846
+ return docs;
6847
+ }
6848
+ /** One document's history. `source` and `docId` as {@link docs} lists them. */
6849
+ doc(source, docId) {
6850
+ return new FlowDoc(this.client, this, source, docId);
6851
+ }
6852
+ /** @internal The `bimterop` folder id, resolved once. */
6853
+ async rootFolderId(create = false) {
6854
+ if (this.#rootFolderId) return this.#rootFolderId;
6855
+ const found = await this.#root();
6856
+ if (found) return found;
6857
+ if (!create) return void 0;
6858
+ const made = await this.client.createFolder(
6859
+ ROOT_FOLDER,
6860
+ void 0,
6861
+ this.projectId
6862
+ );
6863
+ this.#rootFolderId = idOf(made);
6864
+ return this.#rootFolderId;
6865
+ }
6866
+ async #root() {
6867
+ if (this.#rootFolderId) return this.#rootFolderId;
6868
+ const folders = await this.client.listFolders({
6869
+ projectId: this.projectId
6870
+ });
6871
+ const root = folders.find(
6872
+ (f) => String(f.name ?? "") === ROOT_FOLDER && !f.parentId
6873
+ );
6874
+ if (root) this.#rootFolderId = idOf(root);
6875
+ return this.#rootFolderId;
6876
+ }
6877
+ }
6878
+ class FlowDoc {
6879
+ constructor(client, project, source, docId) {
6880
+ this.client = client;
6881
+ this.project = project;
6882
+ this.source = source;
6883
+ this.docId = docId;
6884
+ }
6885
+ #folderId;
6886
+ // ─── Reading ───────────────────────────────────────────────────────────────
6887
+ /**
6888
+ * The document's versions, oldest first, ordered by the parent graph (not
6889
+ * by array position, which concurrent writers do not keep meaningful).
6890
+ * Each version gets its `ordinal` filled in.
6891
+ */
6892
+ async timeline() {
6893
+ const history = await this.#readHistory();
6894
+ return orderByGraph(history?.commits ?? []);
6895
+ }
6896
+ /** The head of the timeline, or null before the first sync. */
6897
+ async latest() {
6898
+ const timeline = await this.timeline();
6899
+ return timeline.length ? timeline[timeline.length - 1] : null;
6900
+ }
6901
+ /**
6902
+ * A version's delta geometry as a .frag. The baseline (`full`) versions have
6903
+ * no delta: their geometry IS the model file — use {@link model}.
6904
+ */
6905
+ async delta(version2) {
6906
+ if (!version2.deltaId) {
6907
+ throw new Error(
6908
+ `Version ${version2.guid} carries no delta: it is a full export — read model() instead.`
6909
+ );
6910
+ }
6911
+ const response = await this.client.downloadHiddenFile(version2.deltaId);
6912
+ return await response.blob();
6913
+ }
6914
+ /** The visible model .frag as last fully exported. */
6915
+ async model() {
6916
+ const file = await this.#modelFile();
6917
+ if (!file) {
6918
+ throw new Error(
6919
+ `Document ${this.source}-${this.docId} has no model file yet.`
6920
+ );
6921
+ }
6922
+ const response = await this.client.downloadFile(file.id);
6923
+ return await response.blob();
6924
+ }
6925
+ // ─── Writing versions ─────────────────────────────────────────────────────
6926
+ /**
6927
+ * Appends one version: uploads the geometry it carries, then the updated
6928
+ * history. Give `expectedLatestGuid` whenever you built on a head you read,
6929
+ * so a concurrent writer surfaces as {@link StaleHistoryError} instead of a
6930
+ * silent fork.
6931
+ */
6932
+ async sync(input) {
6933
+ const folderId = await this.#folder(true);
6934
+ let history = await this.#readHistory() ?? {
6935
+ model: this.docId,
6936
+ commits: []
6937
+ };
6938
+ const head = lastByGraph(history.commits);
6939
+ if (input.expectedLatestGuid !== void 0 && head?.guid !== input.expectedLatestGuid) {
6940
+ throw new StaleHistoryError(input.expectedLatestGuid, head?.guid);
6941
+ }
6942
+ const version2 = {
6943
+ guid: mintGuid(),
6944
+ ...head ? { parents: [head.guid] } : {},
6945
+ author: input.author,
6946
+ source: input.source,
6947
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6948
+ ...input.message ? { message: input.message } : {},
6949
+ ...input.userId ? { userId: input.userId } : {},
6950
+ ...input.appliedOps?.length ? { appliedOps: input.appliedOps } : {},
6951
+ changes: input.changes,
6952
+ counts: tally(input.changes)
6953
+ };
6954
+ if (input.model) {
6955
+ await this.#writeModel(folderId, input.model);
6956
+ version2.full = true;
6957
+ }
6958
+ if (input.delta) {
6959
+ const modelFile = await this.#modelFile();
6960
+ if (!modelFile) {
6961
+ throw new Error(
6962
+ "A delta needs the model file to hang from: sync a full model first."
6963
+ );
6964
+ }
6965
+ const hidden = await this.client.createHiddenFile(
6966
+ input.delta,
6967
+ modelFile.id
6968
+ );
6969
+ version2.deltaId = String(
6970
+ hidden._id ?? hidden.id
6971
+ );
6972
+ }
6973
+ const fresh = await this.#readHistory();
6974
+ if (fresh) {
6975
+ history = fresh;
6976
+ const freshHead = lastByGraph(history.commits);
6977
+ if (input.expectedLatestGuid !== void 0 && freshHead?.guid !== input.expectedLatestGuid) {
6978
+ throw new StaleHistoryError(input.expectedLatestGuid, freshHead?.guid);
6979
+ }
6980
+ if (freshHead && !version2.parents) version2.parents = [freshHead.guid];
6981
+ }
6982
+ history.commits.push(version2);
6983
+ await this.#writeJson(folderId, HISTORY_FILE, history);
6984
+ return version2;
6985
+ }
6986
+ // ─── Suggestions (change requests) ────────────────────────────────────────
6987
+ /** Every suggestion in the document's queue, pending or resolved. */
6988
+ async suggestions() {
6989
+ const ops2 = await this.#readOps();
6990
+ return ops2?.ops ?? [];
6991
+ }
6992
+ /** The suggestions still waiting for the owner, oldest first. */
6993
+ async pendingSuggestions() {
6994
+ return (await this.suggestions()).filter((op) => op.state === "pending");
6995
+ }
6996
+ /**
6997
+ * Queues a change request for this document. The payload, when given, is
6998
+ * uploaded as a hidden file under the suggestions index.
6999
+ */
7000
+ async suggest(input) {
7001
+ const folderId = await this.#folder(true);
7002
+ const index = await this.#readOps() ?? { schema: OPS_SCHEMA, ops: [] };
7003
+ const indexFile = await this.#file(OPS_FILE);
7004
+ const suggestion = {
7005
+ opId: input.opId ?? mintGuid(),
7006
+ title: input.title,
7007
+ verb: input.verb,
7008
+ author: input.author,
7009
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7010
+ state: "pending",
7011
+ ...input.targets !== void 0 ? { targets: input.targets } : {},
7012
+ ...input.batchId ? { batchId: input.batchId } : {},
7013
+ ...input.userId ? { userId: input.userId } : {},
7014
+ ...input.baseCommitGuid ? { baseCommitGuid: input.baseCommitGuid } : {}
7015
+ };
7016
+ if (input.payload) {
7017
+ const holder = indexFile ?? await this.#createJson(folderId, OPS_FILE, index);
7018
+ const hidden = await this.client.createHiddenFile(
7019
+ input.payload,
7020
+ holder.id
7021
+ );
7022
+ suggestion.fragId = String(
7023
+ hidden._id ?? hidden.id
7024
+ );
7025
+ }
7026
+ const fresh = await this.#readOps() ?? index;
7027
+ fresh.schema ??= OPS_SCHEMA;
7028
+ fresh.ops.push(suggestion);
7029
+ await this.#writeJson(folderId, OPS_FILE, fresh);
7030
+ return suggestion;
7031
+ }
7032
+ /** A suggestion's .frag payload. */
7033
+ async suggestionPayload(suggestion) {
7034
+ if (!suggestion.fragId) {
7035
+ throw new Error(`Suggestion ${suggestion.opId} carries no payload.`);
7036
+ }
7037
+ const response = await this.client.downloadHiddenFile(suggestion.fragId);
7038
+ return await response.blob();
7039
+ }
7040
+ /**
7041
+ * Marks a suggestion applied (naming the version that materialised it) or
7042
+ * discarded. The native plugins do this themselves when they apply; apps
7043
+ * use it for `discarded`.
7044
+ */
7045
+ async resolveSuggestion(opId, outcome) {
7046
+ const folderId = await this.#folder(false);
7047
+ if (!folderId) throw new Error("This document has no suggestion queue.");
7048
+ const index = await this.#readOps();
7049
+ const suggestion = index?.ops.find((op) => op.opId === opId);
7050
+ if (!index || !suggestion) {
7051
+ throw new Error(`No suggestion ${opId} in this document's queue.`);
7052
+ }
7053
+ Object.assign(suggestion, outcome);
7054
+ await this.#writeJson(folderId, OPS_FILE, index);
7055
+ return suggestion;
7056
+ }
7057
+ // ─── The layout, below the surface ────────────────────────────────────────
7058
+ get #folderName() {
7059
+ return `${this.source}-${this.docId}`;
7060
+ }
7061
+ async #folder(create) {
7062
+ if (this.#folderId) return this.#folderId;
7063
+ const rootId = await this.project.rootFolderId(create);
7064
+ if (!rootId) {
7065
+ throw new Error(
7066
+ `Project ${this.project.projectId} has no connected documents yet.`
7067
+ );
7068
+ }
7069
+ const folders = await this.client.listFolders({
7070
+ parentFolderId: rootId,
7071
+ projectId: this.project.projectId
7072
+ });
7073
+ const found = childrenOf(folders, rootId).find(
7074
+ (f) => String(f.name ?? "") === this.#folderName
7075
+ );
7076
+ if (found) {
7077
+ this.#folderId = idOf(found);
7078
+ return this.#folderId;
7079
+ }
7080
+ if (!create) {
7081
+ throw new Error(
7082
+ `Document ${this.#folderName} does not exist in this project.`
7083
+ );
7084
+ }
7085
+ const made = await this.client.createFolder(
7086
+ this.#folderName,
7087
+ rootId,
7088
+ this.project.projectId
7089
+ );
7090
+ this.#folderId = idOf(made);
7091
+ return this.#folderId;
7092
+ }
7093
+ async #files() {
7094
+ const folderId = await this.#folder(false);
7095
+ const items2 = await this.client.listFiles({ folderId });
7096
+ return items2.map((item) => ({
7097
+ id: idOf(item),
7098
+ name: String(item.name ?? "")
7099
+ }));
7100
+ }
7101
+ async #file(name) {
7102
+ try {
7103
+ return (await this.#files()).find((f) => f.name === name);
7104
+ } catch {
7105
+ return void 0;
7106
+ }
7107
+ }
7108
+ async #modelFile() {
7109
+ try {
7110
+ const files = await this.#files();
7111
+ return files.find((f) => f.name === LEGACY_MODEL_FILE) ?? files.find(
7112
+ (f) => f.name.endsWith(".frag") && !f.name.startsWith(INTERNAL_PREFIX)
7113
+ );
7114
+ } catch {
7115
+ return void 0;
7116
+ }
7117
+ }
7118
+ async #readJson(name) {
7119
+ const file = await this.#file(name);
7120
+ if (!file) return void 0;
7121
+ const response = await this.client.downloadFile(file.id);
7122
+ const text2 = await response.text();
7123
+ if (!text2.trim()) return void 0;
7124
+ return JSON.parse(text2);
7125
+ }
7126
+ #readHistory() {
7127
+ return this.#readJson(HISTORY_FILE);
7128
+ }
7129
+ #readOps() {
7130
+ return this.#readJson(OPS_FILE);
7131
+ }
7132
+ async #writeJson(folderId, name, value2) {
7133
+ const blob = new Blob([JSON.stringify(value2)], {
7134
+ type: "application/json"
7135
+ });
7136
+ const existing = await this.#file(name);
7137
+ if (existing) {
7138
+ await this.client.updateFile(existing.id, {
7139
+ file: blob,
7140
+ versionTag: versionTag()
7141
+ });
7142
+ return existing;
7143
+ }
7144
+ return await this.#createJson(folderId, name, value2);
7145
+ }
7146
+ async #createJson(folderId, name, value2) {
7147
+ const blob = new Blob([JSON.stringify(value2)], {
7148
+ type: "application/json"
7149
+ });
7150
+ const created = await this.client.createFile({
7151
+ file: blob,
7152
+ name,
7153
+ versionTag: versionTag(),
7154
+ parentFolderId: folderId,
7155
+ projectId: this.project.projectId
7156
+ });
7157
+ const item = created.item;
7158
+ return { id: idOf(item ?? created), name };
7159
+ }
7160
+ async #writeModel(folderId, model) {
7161
+ const existing = await this.#modelFile();
7162
+ if (existing) {
7163
+ await this.client.updateFile(existing.id, {
7164
+ file: model,
7165
+ versionTag: versionTag()
7166
+ });
7167
+ return existing;
7168
+ }
7169
+ const name = `${this.#folderName}.frag`;
7170
+ const created = await this.client.createFile({
7171
+ file: model,
7172
+ name,
7173
+ versionTag: versionTag(),
7174
+ parentFolderId: folderId,
7175
+ projectId: this.project.projectId
7176
+ });
7177
+ const item = created.item;
7178
+ return { id: idOf(item ?? created), name };
7179
+ }
7180
+ }
7181
+ function tally(changes) {
7182
+ const counts = { added: 0, modified: 0, removed: 0 };
7183
+ for (const change of changes) {
7184
+ if (change.type === "create") counts.added++;
7185
+ else if (change.type === "delete") counts.removed++;
7186
+ else counts.modified++;
7187
+ }
7188
+ return counts;
7189
+ }
7190
+ function orderByGraph(versions) {
7191
+ if (versions.length <= 1) {
7192
+ versions.forEach((v, i) => v.ordinal = i);
7193
+ return [...versions];
7194
+ }
7195
+ const byGuid = new Map(versions.map((v) => [v.guid, v]));
7196
+ const children = /* @__PURE__ */ new Map();
7197
+ const roots = [];
7198
+ for (const version2 of versions) {
7199
+ const parent = version2.parents?.[0];
7200
+ if (parent && byGuid.has(parent)) {
7201
+ const list = children.get(parent) ?? [];
7202
+ list.push(version2);
7203
+ children.set(parent, list);
7204
+ } else {
7205
+ roots.push(version2);
7206
+ }
7207
+ }
7208
+ const byTime = (a, b) => String(a.timestamp).localeCompare(String(b.timestamp));
7209
+ roots.sort(byTime);
7210
+ const ordered = [];
7211
+ const stack = [...roots].reverse();
7212
+ const seen = /* @__PURE__ */ new Set();
7213
+ while (stack.length) {
7214
+ const version2 = stack.pop();
7215
+ if (seen.has(version2.guid)) continue;
7216
+ seen.add(version2.guid);
7217
+ ordered.push(version2);
7218
+ const next = (children.get(version2.guid) ?? []).sort(byTime);
7219
+ for (let i = next.length - 1; i >= 0; i--) stack.push(next[i]);
7220
+ }
7221
+ for (const version2 of versions) {
7222
+ if (!seen.has(version2.guid)) ordered.push(version2);
7223
+ }
7224
+ ordered.forEach((v, i) => v.ordinal = i);
7225
+ return ordered;
7226
+ }
7227
+ function lastByGraph(versions) {
7228
+ const ordered = orderByGraph(versions);
7229
+ return ordered[ordered.length - 1];
7230
+ }
7231
+ function mintGuid() {
7232
+ const anyCrypto = globalThis.crypto;
7233
+ if (anyCrypto?.randomUUID) return anyCrypto.randomUUID();
7234
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
7235
+ const r = Math.random() * 16 | 0;
7236
+ return (c === "x" ? r : r & 3 | 8).toString(16);
7237
+ });
7238
+ }
7239
+ class Recipes {
7240
+ constructor(client) {
7241
+ this.client = client;
7242
+ }
7243
+ #registry = /* @__PURE__ */ new Map();
7244
+ /** Registers a recipe. One per name; a second with the same name throws. */
7245
+ register(recipe) {
7246
+ if (this.#registry.has(recipe.name)) {
7247
+ throw new Error(`A recipe named "${recipe.name}" is already registered.`);
7248
+ }
7249
+ this.#registry.set(recipe.name, recipe);
7250
+ }
7251
+ /** The registered recipes, optionally filtered by target application. */
7252
+ list(filter) {
7253
+ const all = [...this.#registry.values()];
7254
+ return all.filter(
7255
+ (recipe) => (!filter?.to || recipe.to === filter.to) && (!filter?.input || recipe.inputs.includes(filter.input))
7256
+ );
7257
+ }
7258
+ /** A registered recipe by name, or undefined. */
7259
+ get(name) {
7260
+ return this.#registry.get(name);
7261
+ }
7262
+ /**
7263
+ * Runs a recipe WITHOUT queueing anything: the dry pass. Returns the
7264
+ * recipe's result — title, tallies per rule, targets — so an app can show
7265
+ * what would be proposed before anybody confirms. The payload it may have
7266
+ * built is discarded along with its opId.
7267
+ */
7268
+ async plan(name, options) {
7269
+ const { result } = await this.#execute(name, options);
7270
+ return result;
7271
+ }
7272
+ /**
7273
+ * Runs a recipe and queues its suggestion on the target document. Safe to
7274
+ * call freely: nothing touches the native application until its owner
7275
+ * accepts the suggestion there. Use {@link plan} first when the app wants
7276
+ * to show the tallies before queueing.
7277
+ */
7278
+ async run(name, options) {
7279
+ const { targetDoc, base, opId, result } = await this.#execute(
7280
+ name,
7281
+ options
7282
+ );
7283
+ const suggestion = await targetDoc.suggest({
7284
+ opId,
7285
+ title: result.title,
7286
+ verb: result.verb,
7287
+ author: options.author,
7288
+ payload: result.payload,
7289
+ targets: result.targets,
7290
+ userId: options.userId,
7291
+ baseCommitGuid: base?.guid
7292
+ });
7293
+ return { suggestion, result };
7294
+ }
7295
+ async #execute(name, options) {
7296
+ const recipe = this.#registry.get(name);
7297
+ if (!recipe) throw new Error(`No recipe named "${name}" is registered.`);
7298
+ if (recipe.to !== options.target.source) {
7299
+ throw new Error(
7300
+ `Recipe "${name}" writes ${recipe.to}, but the target document belongs to ${options.target.source}.`
7301
+ );
7302
+ }
7303
+ const targetDoc = this.client.history(options.projectId).doc(options.target.source, options.target.docId);
7304
+ const base = await targetDoc.latest();
7305
+ const opId = mintGuid();
7306
+ const result = await recipe.run({
7307
+ client: this.client,
7308
+ projectId: options.projectId,
7309
+ targetDoc,
7310
+ opId,
7311
+ input: options.input,
7312
+ settings: options.settings ?? {}
7313
+ });
7314
+ return { recipe, targetDoc, base, opId, result };
7315
+ }
7316
+ }
6798
7317
  const STORAGE_BATCH_MAX = 100;
6799
7318
  function parseErrorBody(body) {
6800
7319
  try {
@@ -7171,11 +7690,11 @@ class EngineServicesClient {
7171
7690
  * @param versionTag - The version tag (e.g. "v1").
7172
7691
  * @param params - Optional flags such as `withDraft`.
7173
7692
  */
7174
- async getFileVersionMetadata(fileId, versionTag, params) {
7693
+ async getFileVersionMetadata(fileId, versionTag2, params) {
7175
7694
  const { withDraft } = params || {};
7176
7695
  return await this.#requestApi(
7177
7696
  "GET",
7178
- `${ITEM_PATH}/${encodeURIComponent(fileId)}/version/${encodeURIComponent(versionTag)}/metadata`,
7697
+ `${ITEM_PATH}/${encodeURIComponent(fileId)}/version/${encodeURIComponent(versionTag2)}/metadata`,
7179
7698
  {
7180
7699
  query: {
7181
7700
  ...withDraft && { withDraft: "true" }
@@ -7189,10 +7708,10 @@ class EngineServicesClient {
7189
7708
  * @param versionTag - The version tag.
7190
7709
  * @param metadata - Free-JSON object (max 200 fields, 50-char keys/values).
7191
7710
  */
7192
- async updateFileVersionMetadata(fileId, versionTag, metadata2) {
7711
+ async updateFileVersionMetadata(fileId, versionTag2, metadata2) {
7193
7712
  return await this.#requestApi(
7194
7713
  "PUT",
7195
- `${ITEM_PATH}/${encodeURIComponent(fileId)}/version/${encodeURIComponent(versionTag)}/metadata`,
7714
+ `${ITEM_PATH}/${encodeURIComponent(fileId)}/version/${encodeURIComponent(versionTag2)}/metadata`,
7196
7715
  {
7197
7716
  body: JSON.stringify({ metadata: metadata2 }),
7198
7717
  contentType: "application/json"
@@ -7204,10 +7723,10 @@ class EngineServicesClient {
7204
7723
  * @param fileId - The file's unique identifier.
7205
7724
  * @param versionTag - The version tag.
7206
7725
  */
7207
- async deleteFileVersionMetadata(fileId, versionTag) {
7726
+ async deleteFileVersionMetadata(fileId, versionTag2) {
7208
7727
  return await this.#requestApi(
7209
7728
  "DELETE",
7210
- `${ITEM_PATH}/${encodeURIComponent(fileId)}/version/${encodeURIComponent(versionTag)}/metadata`
7729
+ `${ITEM_PATH}/${encodeURIComponent(fileId)}/version/${encodeURIComponent(versionTag2)}/metadata`
7211
7730
  );
7212
7731
  }
7213
7732
  /**
@@ -7436,12 +7955,12 @@ class EngineServicesClient {
7436
7955
  * @returns A fetch Response containing the bundle JavaScript text.
7437
7956
  */
7438
7957
  async downloadComponentBundle(componentId, params) {
7439
- const { versionTag, withDraft } = params || {};
7958
+ const { versionTag: versionTag2, withDraft } = params || {};
7440
7959
  return await this.#requestFile(
7441
7960
  `${ITEM_PATH}/${componentId}/download/bundle`,
7442
7961
  {
7443
7962
  query: {
7444
- ...versionTag && { versionTag },
7963
+ ...versionTag2 && { versionTag: versionTag2 },
7445
7964
  ...withDraft && { withDraft }
7446
7965
  }
7447
7966
  }
@@ -7633,10 +8152,10 @@ return main;`);
7633
8152
  * @returns A fetch Response containing the bundle JavaScript text.
7634
8153
  */
7635
8154
  async downloadAppBundle(appId, params) {
7636
- const { versionTag, withDraft } = params || {};
8155
+ const { versionTag: versionTag2, withDraft } = params || {};
7637
8156
  return await this.#requestFile(`${ITEM_PATH}/${appId}/download/bundle`, {
7638
8157
  query: {
7639
- ...versionTag && { versionTag },
8158
+ ...versionTag2 && { versionTag: versionTag2 },
7640
8159
  ...withDraft && { withDraft }
7641
8160
  }
7642
8161
  });
@@ -7678,7 +8197,7 @@ return main;`);
7678
8197
  * @param versionTag - Optional version to execute (defaults to latest).
7679
8198
  * @returns An object containing the `executionId` to track progress.
7680
8199
  */
7681
- async executeComponent(componentId, executionParams, versionTag) {
8200
+ async executeComponent(componentId, executionParams, versionTag2) {
7682
8201
  if (this.localServerUrl) {
7683
8202
  const url2 = `${this.localServerUrl}/api/${PROCESS_PATH}/${componentId}/execute`;
7684
8203
  const response = await fetch(url2, {
@@ -7699,7 +8218,7 @@ return main;`);
7699
8218
  `${PROCESS_PATH}/${componentId}/execute`,
7700
8219
  {
7701
8220
  body: JSON.stringify(executionParams),
7702
- query: { ...versionTag && { versionTag } },
8221
+ query: { ...versionTag2 && { versionTag: versionTag2 } },
7703
8222
  contentType: "application/json"
7704
8223
  }
7705
8224
  );
@@ -7801,6 +8320,25 @@ return main;`);
7801
8320
  console.log(e);
7802
8321
  });
7803
8322
  }
8323
+ // ─── History & Recipes ───────────────────────────────────────────
8324
+ /**
8325
+ * A project's history of connected documents (Revit models, AutoCAD
8326
+ * drawings…): their version timelines and their change requests. See
8327
+ * `src/core/history.ts` — this surface is the only supported way to read
8328
+ * or write it; the storage underneath is private and will move.
8329
+ */
8330
+ history(projectId) {
8331
+ return new ProjectHistory(this, projectId);
8332
+ }
8333
+ #recipes;
8334
+ /**
8335
+ * The recipe registry and runner: scripts that write change requests in a
8336
+ * native application's language. See `src/core/recipes.ts`.
8337
+ */
8338
+ get recipes() {
8339
+ this.#recipes ??= new Recipes(this);
8340
+ return this.#recipes;
8341
+ }
7804
8342
  // ─── Hidden Files ────────────────────────────────────────────────
7805
8343
  /**
7806
8344
  * Creates a hidden file attached to a parent item (e.g., dependencies, assets).
@@ -8017,10 +8555,10 @@ return main;`);
8017
8555
  * @param metadata - Optional free-JSON metadata to store on the new version.
8018
8556
  * @returns The created version.
8019
8557
  */
8020
- async createVersion(itemId, file, versionTag, extraProps, metadata2) {
8558
+ async createVersion(itemId, file, versionTag2, extraProps, metadata2) {
8021
8559
  const formData = new FormData();
8022
8560
  formData.append("file", file);
8023
- formData.append("versionTag", versionTag);
8561
+ formData.append("versionTag", versionTag2);
8024
8562
  extraProps && formData.append("extraProps", JSON.stringify(extraProps));
8025
8563
  metadata2 && formData.append("metadata", JSON.stringify(metadata2));
8026
8564
  return await this.#requestApi(
@@ -8084,10 +8622,10 @@ return main;`);
8084
8622
  * @param versionTag - The version's tag (e.g. "v2").
8085
8623
  * @returns The archived version.
8086
8624
  */
8087
- async archiveVersion(itemId, versionTag) {
8625
+ async archiveVersion(itemId, versionTag2) {
8088
8626
  return await this.#requestApi(
8089
8627
  "PUT",
8090
- `${ITEM_PATH}/${encodeURIComponent(itemId)}/version/${encodeURIComponent(versionTag)}/archive`
8628
+ `${ITEM_PATH}/${encodeURIComponent(itemId)}/version/${encodeURIComponent(versionTag2)}/archive`
8091
8629
  );
8092
8630
  }
8093
8631
  /**
@@ -8096,10 +8634,10 @@ return main;`);
8096
8634
  * @param versionTag - The version's tag (e.g. "v2").
8097
8635
  * @returns The recovered version.
8098
8636
  */
8099
- async recoverVersion(itemId, versionTag) {
8637
+ async recoverVersion(itemId, versionTag2) {
8100
8638
  return await this.#requestApi(
8101
8639
  "PUT",
8102
- `${ITEM_PATH}/${encodeURIComponent(itemId)}/version/${encodeURIComponent(versionTag)}/recover`
8640
+ `${ITEM_PATH}/${encodeURIComponent(itemId)}/version/${encodeURIComponent(versionTag2)}/recover`
8103
8641
  );
8104
8642
  }
8105
8643
  /**
@@ -8108,10 +8646,10 @@ return main;`);
8108
8646
  * @param itemId - The item's unique identifier.
8109
8647
  * @param versionTag - The version's tag (e.g. "v2").
8110
8648
  */
8111
- async deleteVersion(itemId, versionTag) {
8649
+ async deleteVersion(itemId, versionTag2) {
8112
8650
  return await this.#requestApi(
8113
8651
  "DELETE",
8114
- `${ITEM_PATH}/${encodeURIComponent(itemId)}/version/${encodeURIComponent(versionTag)}`
8652
+ `${ITEM_PATH}/${encodeURIComponent(itemId)}/version/${encodeURIComponent(versionTag2)}`
8115
8653
  );
8116
8654
  }
8117
8655
  // Project-scoped listings happen via the main list methods — e.g.
@@ -8142,20 +8680,20 @@ return main;`);
8142
8680
  return responses.flat();
8143
8681
  }
8144
8682
  async #downloadItem(itemId, params) {
8145
- const { versionTag, withDraft } = params || {};
8683
+ const { versionTag: versionTag2, withDraft } = params || {};
8146
8684
  return await this.#requestFile(`${ITEM_PATH}/${itemId}/download`, {
8147
8685
  query: {
8148
- ...versionTag && { versionTag },
8686
+ ...versionTag2 && { versionTag: versionTag2 },
8149
8687
  ...withDraft && { withDraft }
8150
8688
  }
8151
8689
  });
8152
8690
  }
8153
8691
  async #createItem(fileData, itemType, extraProps) {
8154
- const { name, versionTag, parentFolderId, projectId, file, metadata: metadata2 } = fileData;
8692
+ const { name, versionTag: versionTag2, parentFolderId, projectId, file, metadata: metadata2 } = fileData;
8155
8693
  const formData = new FormData();
8156
8694
  formData.append("file", file);
8157
8695
  formData.append("name", name);
8158
- formData.append("versionTag", versionTag);
8696
+ formData.append("versionTag", versionTag2);
8159
8697
  formData.append("itemType", itemType);
8160
8698
  parentFolderId && formData.append("folderId", parentFolderId);
8161
8699
  projectId && formData.append("projectId", projectId);
@@ -8166,13 +8704,13 @@ return main;`);
8166
8704
  });
8167
8705
  }
8168
8706
  async #updateItem(itemId, fileData, extraProps) {
8169
- const { name, versionTag, parentFolderId, file, metadata: metadata2 } = fileData;
8707
+ const { name, versionTag: versionTag2, parentFolderId, file, metadata: metadata2 } = fileData;
8170
8708
  let item;
8171
8709
  let version2;
8172
8710
  if (file) {
8173
8711
  const formData = new FormData();
8174
8712
  formData.append("file", file);
8175
- versionTag && formData.append("versionTag", versionTag);
8713
+ versionTag2 && formData.append("versionTag", versionTag2);
8176
8714
  extraProps && formData.append("extraProps", JSON.stringify(extraProps));
8177
8715
  metadata2 && formData.append("metadata", JSON.stringify(metadata2));
8178
8716
  version2 = await this.#requestApi(
@@ -10877,15 +11415,15 @@ const publishCommand = new Command2("publish").description("Build and publish th
10877
11415
  }
10878
11416
  const pkg2 = JSON.parse(require$$3$1.readFileSync(pkgPath, "utf-8"));
10879
11417
  const projectName = opts.name || pkg2.name || require$$2.basename(cwd);
10880
- const versionTag = opts.versionTag || pkg2.version || "1.0.0";
11418
+ const versionTag2 = opts.versionTag || pkg2.version || "1.0.0";
10881
11419
  const projectId = opts.projectId || localConfig?.projectId;
10882
11420
  const client = cliClient(config2.accessToken, config2.apiUrl);
10883
11421
  if (existingId) {
10884
11422
  try {
10885
11423
  const versions = await client.listVersions(existingId);
10886
- if (versions.some((v) => v.tag === versionTag)) {
11424
+ if (versions.some((v) => v.tag === versionTag2)) {
10887
11425
  console.error(
10888
- `Version ${versionTag} already exists for this ${isComponent ? "component" : "app"}. Bump the version in package.json or pass --version-tag.`
11426
+ `Version ${versionTag2} already exists for this ${isComponent ? "component" : "app"}. Bump the version in package.json or pass --version-tag.`
10889
11427
  );
10890
11428
  process.exit(1);
10891
11429
  }
@@ -10944,7 +11482,7 @@ const publishCommand = new Command2("publish").description("Build and publish th
10944
11482
  existingId,
10945
11483
  zipFile,
10946
11484
  projectName,
10947
- versionTag,
11485
+ versionTag2,
10948
11486
  cwd,
10949
11487
  projectId
10950
11488
  );
@@ -10954,7 +11492,7 @@ const publishCommand = new Command2("publish").description("Build and publish th
10954
11492
  existingId,
10955
11493
  zipFile,
10956
11494
  projectName,
10957
- versionTag,
11495
+ versionTag2,
10958
11496
  cwd,
10959
11497
  projectId
10960
11498
  );
@@ -10991,7 +11529,7 @@ const publishCommand = new Command2("publish").description("Build and publish th
10991
11529
  }
10992
11530
  }
10993
11531
  );
10994
- async function publishApp(client, appId, zipFile, name, versionTag, cwd, projectId) {
11532
+ async function publishApp(client, appId, zipFile, name, versionTag2, cwd, projectId) {
10995
11533
  if (appId) {
10996
11534
  const existing = await client.getFile(appId);
10997
11535
  if (existing.archived) {
@@ -10999,23 +11537,23 @@ async function publishApp(client, appId, zipFile, name, versionTag, cwd, project
10999
11537
  await client.recoverFile(appId);
11000
11538
  }
11001
11539
  console.log(
11002
- `Publishing new version (${versionTag}) for app ${appId}...`
11540
+ `Publishing new version (${versionTag2}) for app ${appId}...`
11003
11541
  );
11004
11542
  const result = await client.createVersion(
11005
11543
  appId,
11006
11544
  zipFile,
11007
- versionTag,
11545
+ versionTag2,
11008
11546
  {}
11009
11547
  // extraProps required by backend for APP items
11010
11548
  );
11011
11549
  console.log("Version created:", JSON.stringify(result, null, 2));
11012
11550
  return appId;
11013
11551
  } else {
11014
- console.log(`Publishing new app "${name}" (${versionTag})...`);
11552
+ console.log(`Publishing new app "${name}" (${versionTag2})...`);
11015
11553
  const result = await client.createApp({
11016
11554
  file: zipFile,
11017
11555
  name,
11018
- versionTag,
11556
+ versionTag: versionTag2,
11019
11557
  // The API has always accepted it; the CLI just never sent it, so a CI
11020
11558
  // publish could not land an app inside a project.
11021
11559
  ...projectId && { projectId }
@@ -11029,7 +11567,7 @@ async function publishApp(client, appId, zipFile, name, versionTag, cwd, project
11029
11567
  return newAppId ? String(newAppId) : void 0;
11030
11568
  }
11031
11569
  }
11032
- async function publishComponent(client, componentId, zipFile, name, versionTag, cwd, projectId) {
11570
+ async function publishComponent(client, componentId, zipFile, name, versionTag2, cwd, projectId) {
11033
11571
  const componentProps = {
11034
11572
  type: "CLOUD",
11035
11573
  tier: "FREE",
@@ -11042,23 +11580,23 @@ async function publishComponent(client, componentId, zipFile, name, versionTag,
11042
11580
  await client.recoverComponent(componentId);
11043
11581
  }
11044
11582
  console.log(
11045
- `Publishing new version (${versionTag}) for component ${componentId}...`
11583
+ `Publishing new version (${versionTag2}) for component ${componentId}...`
11046
11584
  );
11047
11585
  const result = await client.updateComponent(componentId, {
11048
11586
  file: zipFile,
11049
- versionTag,
11587
+ versionTag: versionTag2,
11050
11588
  componentProps
11051
11589
  });
11052
11590
  console.log("Version created:", JSON.stringify(result, null, 2));
11053
11591
  return componentId;
11054
11592
  } else {
11055
11593
  console.log(
11056
- `Publishing new cloud component "${name}" (${versionTag})...`
11594
+ `Publishing new cloud component "${name}" (${versionTag2})...`
11057
11595
  );
11058
11596
  const result = await client.createComponent({
11059
11597
  file: zipFile,
11060
11598
  name,
11061
- versionTag,
11599
+ versionTag: versionTag2,
11062
11600
  componentProps,
11063
11601
  ...projectId && { projectId }
11064
11602
  });
@@ -25070,8 +25608,8 @@ var scope = {};
25070
25608
  var util = {};
25071
25609
  Object.defineProperty(util, "__esModule", { value: true });
25072
25610
  util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
25073
- const codegen_1$q = codegen;
25074
- const code_1$9 = code$1;
25611
+ const codegen_1$v = codegen;
25612
+ const code_1$a = code$1;
25075
25613
  function toHash(arr) {
25076
25614
  const hash = {};
25077
25615
  for (const item of arr)
@@ -25124,9 +25662,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
25124
25662
  if (typeof schema == "number" || typeof schema == "boolean")
25125
25663
  return schema;
25126
25664
  if (typeof schema == "string")
25127
- return (0, codegen_1$q._)`${schema}`;
25665
+ return (0, codegen_1$v._)`${schema}`;
25128
25666
  }
25129
- return (0, codegen_1$q._)`${topSchemaRef}${schemaPath}${(0, codegen_1$q.getProperty)(keyword2)}`;
25667
+ return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
25130
25668
  }
25131
25669
  util.schemaRefOrVal = schemaRefOrVal;
25132
25670
  function unescapeFragment(str) {
@@ -25158,20 +25696,20 @@ function eachItem(xs, f) {
25158
25696
  util.eachItem = eachItem;
25159
25697
  function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
25160
25698
  return (gen, from, to, toName) => {
25161
- const res = to === void 0 ? from : to instanceof codegen_1$q.Name ? (from instanceof codegen_1$q.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$q.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
25162
- return toName === codegen_1$q.Name && !(res instanceof codegen_1$q.Name) ? resultToName(gen, res) : res;
25699
+ const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
25700
+ return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
25163
25701
  };
25164
25702
  }
25165
25703
  util.mergeEvaluated = {
25166
25704
  props: makeMergeEvaluated({
25167
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => {
25168
- gen.if((0, codegen_1$q._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$q._)`${to} || {}`).code((0, codegen_1$q._)`Object.assign(${to}, ${from})`));
25705
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
25706
+ gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
25169
25707
  }),
25170
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => {
25708
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
25171
25709
  if (from === true) {
25172
25710
  gen.assign(to, true);
25173
25711
  } else {
25174
- gen.assign(to, (0, codegen_1$q._)`${to} || {}`);
25712
+ gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
25175
25713
  setEvaluated(gen, to, from);
25176
25714
  }
25177
25715
  }),
@@ -25179,8 +25717,8 @@ util.mergeEvaluated = {
25179
25717
  resultToName: evaluatedPropsToName
25180
25718
  }),
25181
25719
  items: makeMergeEvaluated({
25182
- mergeNames: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$q._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
25183
- mergeToName: (gen, from, to) => gen.if((0, codegen_1$q._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$q._)`${to} > ${from} ? ${to} : ${from}`)),
25720
+ mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
25721
+ mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
25184
25722
  mergeValues: (from, to) => from === true ? true : Math.max(from, to),
25185
25723
  resultToName: (gen, items2) => gen.var("items", items2)
25186
25724
  })
@@ -25188,21 +25726,21 @@ util.mergeEvaluated = {
25188
25726
  function evaluatedPropsToName(gen, ps) {
25189
25727
  if (ps === true)
25190
25728
  return gen.var("props", true);
25191
- const props = gen.var("props", (0, codegen_1$q._)`{}`);
25729
+ const props = gen.var("props", (0, codegen_1$v._)`{}`);
25192
25730
  if (ps !== void 0)
25193
25731
  setEvaluated(gen, props, ps);
25194
25732
  return props;
25195
25733
  }
25196
25734
  util.evaluatedPropsToName = evaluatedPropsToName;
25197
25735
  function setEvaluated(gen, props, ps) {
25198
- Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$q._)`${props}${(0, codegen_1$q.getProperty)(p)}`, true));
25736
+ Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
25199
25737
  }
25200
25738
  util.setEvaluated = setEvaluated;
25201
25739
  const snippets = {};
25202
25740
  function useFunc(gen, f) {
25203
25741
  return gen.scopeValue("func", {
25204
25742
  ref: f,
25205
- code: snippets[f.code] || (snippets[f.code] = new code_1$9._Code(f.code))
25743
+ code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
25206
25744
  });
25207
25745
  }
25208
25746
  util.useFunc = useFunc;
@@ -25212,11 +25750,11 @@ var Type;
25212
25750
  Type2[Type2["Str"] = 1] = "Str";
25213
25751
  })(Type || (util.Type = Type = {}));
25214
25752
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
25215
- if (dataProp instanceof codegen_1$q.Name) {
25753
+ if (dataProp instanceof codegen_1$v.Name) {
25216
25754
  const isNumber = dataPropType === Type.Num;
25217
- return jsPropertySyntax ? isNumber ? (0, codegen_1$q._)`"[" + ${dataProp} + "]"` : (0, codegen_1$q._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$q._)`"/" + ${dataProp}` : (0, codegen_1$q._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
25755
+ return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
25218
25756
  }
25219
- return jsPropertySyntax ? (0, codegen_1$q.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
25757
+ return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
25220
25758
  }
25221
25759
  util.getErrorPath = getErrorPath;
25222
25760
  function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
@@ -25230,35 +25768,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
25230
25768
  util.checkStrictMode = checkStrictMode;
25231
25769
  var names$1 = {};
25232
25770
  Object.defineProperty(names$1, "__esModule", { value: true });
25233
- const codegen_1$p = codegen;
25771
+ const codegen_1$u = codegen;
25234
25772
  const names = {
25235
25773
  // validation function arguments
25236
- data: new codegen_1$p.Name("data"),
25774
+ data: new codegen_1$u.Name("data"),
25237
25775
  // data passed to validation function
25238
25776
  // args passed from referencing schema
25239
- valCxt: new codegen_1$p.Name("valCxt"),
25777
+ valCxt: new codegen_1$u.Name("valCxt"),
25240
25778
  // validation/data context - should not be used directly, it is destructured to the names below
25241
- instancePath: new codegen_1$p.Name("instancePath"),
25242
- parentData: new codegen_1$p.Name("parentData"),
25243
- parentDataProperty: new codegen_1$p.Name("parentDataProperty"),
25244
- rootData: new codegen_1$p.Name("rootData"),
25779
+ instancePath: new codegen_1$u.Name("instancePath"),
25780
+ parentData: new codegen_1$u.Name("parentData"),
25781
+ parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
25782
+ rootData: new codegen_1$u.Name("rootData"),
25245
25783
  // root data - same as the data passed to the first/top validation function
25246
- dynamicAnchors: new codegen_1$p.Name("dynamicAnchors"),
25784
+ dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
25247
25785
  // used to support recursiveRef and dynamicRef
25248
25786
  // function scoped variables
25249
- vErrors: new codegen_1$p.Name("vErrors"),
25787
+ vErrors: new codegen_1$u.Name("vErrors"),
25250
25788
  // null or array of validation errors
25251
- errors: new codegen_1$p.Name("errors"),
25789
+ errors: new codegen_1$u.Name("errors"),
25252
25790
  // counter of validation errors
25253
- this: new codegen_1$p.Name("this"),
25791
+ this: new codegen_1$u.Name("this"),
25254
25792
  // "globals"
25255
- self: new codegen_1$p.Name("self"),
25256
- scope: new codegen_1$p.Name("scope"),
25793
+ self: new codegen_1$u.Name("self"),
25794
+ scope: new codegen_1$u.Name("scope"),
25257
25795
  // JTD serialize/parse name for JSON string and position
25258
- json: new codegen_1$p.Name("json"),
25259
- jsonPos: new codegen_1$p.Name("jsonPos"),
25260
- jsonLen: new codegen_1$p.Name("jsonLen"),
25261
- jsonPart: new codegen_1$p.Name("jsonPart")
25796
+ json: new codegen_1$u.Name("json"),
25797
+ jsonPos: new codegen_1$u.Name("jsonPos"),
25798
+ jsonLen: new codegen_1$u.Name("jsonLen"),
25799
+ jsonPart: new codegen_1$u.Name("jsonPart")
25262
25800
  };
25263
25801
  names$1.default = names;
25264
25802
  (function(exports) {
@@ -25378,55 +25916,49 @@ names$1.default = names;
25378
25916
  keyValues.push([E.propertyName, propertyName]);
25379
25917
  }
25380
25918
  })(errors);
25381
- var hasRequiredBoolSchema;
25382
- function requireBoolSchema() {
25383
- if (hasRequiredBoolSchema) return boolSchema;
25384
- hasRequiredBoolSchema = 1;
25385
- Object.defineProperty(boolSchema, "__esModule", { value: true });
25386
- boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
25387
- const errors_12 = errors;
25388
- const codegen_12 = codegen;
25389
- const names_12 = names$1;
25390
- const boolError = {
25391
- message: "boolean schema is false"
25392
- };
25393
- function topBoolOrEmptySchema(it) {
25394
- const { gen, schema, validateName } = it;
25395
- if (schema === false) {
25396
- falseSchemaError(it, false);
25397
- } else if (typeof schema == "object" && schema.$async === true) {
25398
- gen.return(names_12.default.data);
25399
- } else {
25400
- gen.assign((0, codegen_12._)`${validateName}.errors`, null);
25401
- gen.return(true);
25402
- }
25403
- }
25404
- boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
25405
- function boolOrEmptySchema(it, valid) {
25406
- const { gen, schema } = it;
25407
- if (schema === false) {
25408
- gen.var(valid, false);
25409
- falseSchemaError(it);
25410
- } else {
25411
- gen.var(valid, true);
25412
- }
25919
+ Object.defineProperty(boolSchema, "__esModule", { value: true });
25920
+ boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
25921
+ const errors_1$3 = errors;
25922
+ const codegen_1$t = codegen;
25923
+ const names_1$6 = names$1;
25924
+ const boolError = {
25925
+ message: "boolean schema is false"
25926
+ };
25927
+ function topBoolOrEmptySchema(it) {
25928
+ const { gen, schema, validateName } = it;
25929
+ if (schema === false) {
25930
+ falseSchemaError(it, false);
25931
+ } else if (typeof schema == "object" && schema.$async === true) {
25932
+ gen.return(names_1$6.default.data);
25933
+ } else {
25934
+ gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
25935
+ gen.return(true);
25413
25936
  }
25414
- boolSchema.boolOrEmptySchema = boolOrEmptySchema;
25415
- function falseSchemaError(it, overrideAllErrors) {
25416
- const { gen, data } = it;
25417
- const cxt = {
25418
- gen,
25419
- keyword: "false schema",
25420
- data,
25421
- schema: false,
25422
- schemaCode: false,
25423
- schemaValue: false,
25424
- params: {},
25425
- it
25426
- };
25427
- (0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
25937
+ }
25938
+ boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
25939
+ function boolOrEmptySchema(it, valid) {
25940
+ const { gen, schema } = it;
25941
+ if (schema === false) {
25942
+ gen.var(valid, false);
25943
+ falseSchemaError(it);
25944
+ } else {
25945
+ gen.var(valid, true);
25428
25946
  }
25429
- return boolSchema;
25947
+ }
25948
+ boolSchema.boolOrEmptySchema = boolOrEmptySchema;
25949
+ function falseSchemaError(it, overrideAllErrors) {
25950
+ const { gen, data } = it;
25951
+ const cxt = {
25952
+ gen,
25953
+ keyword: "false schema",
25954
+ data,
25955
+ schema: false,
25956
+ schemaCode: false,
25957
+ schemaValue: false,
25958
+ params: {},
25959
+ it
25960
+ };
25961
+ (0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
25430
25962
  }
25431
25963
  var dataType = {};
25432
25964
  var rules = {};
@@ -25474,10 +26006,10 @@ applicability.shouldUseRule = shouldUseRule;
25474
26006
  Object.defineProperty(dataType, "__esModule", { value: true });
25475
26007
  dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
25476
26008
  const rules_1 = rules;
25477
- const applicability_1 = applicability;
25478
- const errors_1 = errors;
25479
- const codegen_1$o = codegen;
25480
- const util_1$o = util;
26009
+ const applicability_1$1 = applicability;
26010
+ const errors_1$2 = errors;
26011
+ const codegen_1$s = codegen;
26012
+ const util_1$r = util;
25481
26013
  var DataType;
25482
26014
  (function(DataType2) {
25483
26015
  DataType2[DataType2["Correct"] = 0] = "Correct";
@@ -25509,7 +26041,7 @@ dataType.getJSONTypes = getJSONTypes;
25509
26041
  function coerceAndCheckDataType(it, types2) {
25510
26042
  const { gen, data, opts } = it;
25511
26043
  const coerceTo = coerceToTypes(types2, opts.coerceTypes);
25512
- const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
26044
+ const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
25513
26045
  if (checkTypes) {
25514
26046
  const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
25515
26047
  gen.if(wrongType, () => {
@@ -25528,12 +26060,12 @@ function coerceToTypes(types2, coerceTypes) {
25528
26060
  }
25529
26061
  function coerceData(it, types2, coerceTo) {
25530
26062
  const { gen, data, opts } = it;
25531
- const dataType2 = gen.let("dataType", (0, codegen_1$o._)`typeof ${data}`);
25532
- const coerced = gen.let("coerced", (0, codegen_1$o._)`undefined`);
26063
+ const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
26064
+ const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
25533
26065
  if (opts.coerceTypes === "array") {
25534
- gen.if((0, codegen_1$o._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$o._)`${data}[0]`).assign(dataType2, (0, codegen_1$o._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
26066
+ gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
25535
26067
  }
25536
- gen.if((0, codegen_1$o._)`${coerced} !== undefined`);
26068
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
25537
26069
  for (const t of coerceTo) {
25538
26070
  if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
25539
26071
  coerceSpecificType(t);
@@ -25542,63 +26074,63 @@ function coerceData(it, types2, coerceTo) {
25542
26074
  gen.else();
25543
26075
  reportTypeError(it);
25544
26076
  gen.endIf();
25545
- gen.if((0, codegen_1$o._)`${coerced} !== undefined`, () => {
26077
+ gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
25546
26078
  gen.assign(data, coerced);
25547
26079
  assignParentData(it, coerced);
25548
26080
  });
25549
26081
  function coerceSpecificType(t) {
25550
26082
  switch (t) {
25551
26083
  case "string":
25552
- gen.elseIf((0, codegen_1$o._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$o._)`"" + ${data}`).elseIf((0, codegen_1$o._)`${data} === null`).assign(coerced, (0, codegen_1$o._)`""`);
26084
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
25553
26085
  return;
25554
26086
  case "number":
25555
- gen.elseIf((0, codegen_1$o._)`${dataType2} == "boolean" || ${data} === null
25556
- || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$o._)`+${data}`);
26087
+ gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
26088
+ || (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
25557
26089
  return;
25558
26090
  case "integer":
25559
- gen.elseIf((0, codegen_1$o._)`${dataType2} === "boolean" || ${data} === null
25560
- || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$o._)`+${data}`);
26091
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
26092
+ || (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
25561
26093
  return;
25562
26094
  case "boolean":
25563
- gen.elseIf((0, codegen_1$o._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$o._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
26095
+ gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
25564
26096
  return;
25565
26097
  case "null":
25566
- gen.elseIf((0, codegen_1$o._)`${data} === "" || ${data} === 0 || ${data} === false`);
26098
+ gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
25567
26099
  gen.assign(coerced, null);
25568
26100
  return;
25569
26101
  case "array":
25570
- gen.elseIf((0, codegen_1$o._)`${dataType2} === "string" || ${dataType2} === "number"
25571
- || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$o._)`[${data}]`);
26102
+ gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
26103
+ || ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
25572
26104
  }
25573
26105
  }
25574
26106
  }
25575
26107
  function assignParentData({ gen, parentData, parentDataProperty }, expr) {
25576
- gen.if((0, codegen_1$o._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$o._)`${parentData}[${parentDataProperty}]`, expr));
26108
+ gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
25577
26109
  }
25578
26110
  function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
25579
- const EQ = correct === DataType.Correct ? codegen_1$o.operators.EQ : codegen_1$o.operators.NEQ;
26111
+ const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
25580
26112
  let cond;
25581
26113
  switch (dataType2) {
25582
26114
  case "null":
25583
- return (0, codegen_1$o._)`${data} ${EQ} null`;
26115
+ return (0, codegen_1$s._)`${data} ${EQ} null`;
25584
26116
  case "array":
25585
- cond = (0, codegen_1$o._)`Array.isArray(${data})`;
26117
+ cond = (0, codegen_1$s._)`Array.isArray(${data})`;
25586
26118
  break;
25587
26119
  case "object":
25588
- cond = (0, codegen_1$o._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
26120
+ cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
25589
26121
  break;
25590
26122
  case "integer":
25591
- cond = numCond((0, codegen_1$o._)`!(${data} % 1) && !isNaN(${data})`);
26123
+ cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
25592
26124
  break;
25593
26125
  case "number":
25594
26126
  cond = numCond();
25595
26127
  break;
25596
26128
  default:
25597
- return (0, codegen_1$o._)`typeof ${data} ${EQ} ${dataType2}`;
26129
+ return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
25598
26130
  }
25599
- return correct === DataType.Correct ? cond : (0, codegen_1$o.not)(cond);
25600
- function numCond(_cond = codegen_1$o.nil) {
25601
- return (0, codegen_1$o.and)((0, codegen_1$o._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$o._)`isFinite(${data})` : codegen_1$o.nil);
26131
+ return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
26132
+ function numCond(_cond = codegen_1$s.nil) {
26133
+ return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
25602
26134
  }
25603
26135
  }
25604
26136
  dataType.checkDataType = checkDataType;
@@ -25607,35 +26139,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
25607
26139
  return checkDataType(dataTypes[0], data, strictNums, correct);
25608
26140
  }
25609
26141
  let cond;
25610
- const types2 = (0, util_1$o.toHash)(dataTypes);
26142
+ const types2 = (0, util_1$r.toHash)(dataTypes);
25611
26143
  if (types2.array && types2.object) {
25612
- const notObj = (0, codegen_1$o._)`typeof ${data} != "object"`;
25613
- cond = types2.null ? notObj : (0, codegen_1$o._)`!${data} || ${notObj}`;
26144
+ const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
26145
+ cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
25614
26146
  delete types2.null;
25615
26147
  delete types2.array;
25616
26148
  delete types2.object;
25617
26149
  } else {
25618
- cond = codegen_1$o.nil;
26150
+ cond = codegen_1$s.nil;
25619
26151
  }
25620
26152
  if (types2.number)
25621
26153
  delete types2.integer;
25622
26154
  for (const t in types2)
25623
- cond = (0, codegen_1$o.and)(cond, checkDataType(t, data, strictNums, correct));
26155
+ cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
25624
26156
  return cond;
25625
26157
  }
25626
26158
  dataType.checkDataTypes = checkDataTypes;
25627
26159
  const typeError = {
25628
26160
  message: ({ schema }) => `must be ${schema}`,
25629
- params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$o._)`{type: ${schema}}` : (0, codegen_1$o._)`{type: ${schemaValue}}`
26161
+ params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
25630
26162
  };
25631
26163
  function reportTypeError(it) {
25632
26164
  const cxt = getTypeErrorContext(it);
25633
- (0, errors_1.reportError)(cxt, typeError);
26165
+ (0, errors_1$2.reportError)(cxt, typeError);
25634
26166
  }
25635
26167
  dataType.reportTypeError = reportTypeError;
25636
26168
  function getTypeErrorContext(it) {
25637
26169
  const { gen, data, schema } = it;
25638
- const schemaCode = (0, util_1$o.schemaRefOrVal)(it, schema, "type");
26170
+ const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
25639
26171
  return {
25640
26172
  gen,
25641
26173
  keyword: "type",
@@ -25649,60 +26181,54 @@ function getTypeErrorContext(it) {
25649
26181
  };
25650
26182
  }
25651
26183
  var defaults = {};
25652
- var hasRequiredDefaults;
25653
- function requireDefaults() {
25654
- if (hasRequiredDefaults) return defaults;
25655
- hasRequiredDefaults = 1;
25656
- Object.defineProperty(defaults, "__esModule", { value: true });
25657
- defaults.assignDefaults = void 0;
25658
- const codegen_12 = codegen;
25659
- const util_12 = util;
25660
- function assignDefaults(it, ty) {
25661
- const { properties: properties2, items: items2 } = it.schema;
25662
- if (ty === "object" && properties2) {
25663
- for (const key in properties2) {
25664
- assignDefault(it, key, properties2[key].default);
25665
- }
25666
- } else if (ty === "array" && Array.isArray(items2)) {
25667
- items2.forEach((sch, i) => assignDefault(it, i, sch.default));
25668
- }
26184
+ Object.defineProperty(defaults, "__esModule", { value: true });
26185
+ defaults.assignDefaults = void 0;
26186
+ const codegen_1$r = codegen;
26187
+ const util_1$q = util;
26188
+ function assignDefaults(it, ty) {
26189
+ const { properties: properties2, items: items2 } = it.schema;
26190
+ if (ty === "object" && properties2) {
26191
+ for (const key in properties2) {
26192
+ assignDefault(it, key, properties2[key].default);
26193
+ }
26194
+ } else if (ty === "array" && Array.isArray(items2)) {
26195
+ items2.forEach((sch, i) => assignDefault(it, i, sch.default));
26196
+ }
26197
+ }
26198
+ defaults.assignDefaults = assignDefaults;
26199
+ function assignDefault(it, prop, defaultValue) {
26200
+ const { gen, compositeRule, data, opts } = it;
26201
+ if (defaultValue === void 0)
26202
+ return;
26203
+ const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
26204
+ if (compositeRule) {
26205
+ (0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
26206
+ return;
25669
26207
  }
25670
- defaults.assignDefaults = assignDefaults;
25671
- function assignDefault(it, prop, defaultValue) {
25672
- const { gen, compositeRule, data, opts } = it;
25673
- if (defaultValue === void 0)
25674
- return;
25675
- const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
25676
- if (compositeRule) {
25677
- (0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
25678
- return;
25679
- }
25680
- let condition = (0, codegen_12._)`${childData} === undefined`;
25681
- if (opts.useDefaults === "empty") {
25682
- condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
25683
- }
25684
- gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
26208
+ let condition = (0, codegen_1$r._)`${childData} === undefined`;
26209
+ if (opts.useDefaults === "empty") {
26210
+ condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
25685
26211
  }
25686
- return defaults;
26212
+ gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
25687
26213
  }
25688
26214
  var keyword = {};
25689
26215
  var code = {};
25690
26216
  Object.defineProperty(code, "__esModule", { value: true });
25691
26217
  code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0;
25692
- const codegen_1$n = codegen;
25693
- const util_1$n = util;
25694
- const names_1$3 = names$1;
26218
+ const codegen_1$q = codegen;
26219
+ const util_1$p = util;
26220
+ const names_1$5 = names$1;
25695
26221
  const util_2$1 = util;
25696
26222
  function checkReportMissingProp(cxt, prop) {
25697
26223
  const { gen, data, it } = cxt;
25698
26224
  gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
25699
- cxt.setParams({ missingProperty: (0, codegen_1$n._)`${prop}` }, true);
26225
+ cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
25700
26226
  cxt.error();
25701
26227
  });
25702
26228
  }
25703
26229
  code.checkReportMissingProp = checkReportMissingProp;
25704
26230
  function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
25705
- return (0, codegen_1$n.or)(...properties2.map((prop) => (0, codegen_1$n.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$n._)`${missing} = ${prop}`)));
26231
+ return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
25706
26232
  }
25707
26233
  code.checkMissingProp = checkMissingProp;
25708
26234
  function reportMissingProp(cxt, missing) {
@@ -25714,22 +26240,22 @@ function hasPropFunc(gen) {
25714
26240
  return gen.scopeValue("func", {
25715
26241
  // eslint-disable-next-line @typescript-eslint/unbound-method
25716
26242
  ref: Object.prototype.hasOwnProperty,
25717
- code: (0, codegen_1$n._)`Object.prototype.hasOwnProperty`
26243
+ code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
25718
26244
  });
25719
26245
  }
25720
26246
  code.hasPropFunc = hasPropFunc;
25721
26247
  function isOwnProperty(gen, data, property) {
25722
- return (0, codegen_1$n._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
26248
+ return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
25723
26249
  }
25724
26250
  code.isOwnProperty = isOwnProperty;
25725
26251
  function propertyInData(gen, data, property, ownProperties) {
25726
- const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} !== undefined`;
25727
- return ownProperties ? (0, codegen_1$n._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
26252
+ const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
26253
+ return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
25728
26254
  }
25729
26255
  code.propertyInData = propertyInData;
25730
26256
  function noPropertyInData(gen, data, property, ownProperties) {
25731
- const cond = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)(property)} === undefined`;
25732
- return ownProperties ? (0, codegen_1$n.or)(cond, (0, codegen_1$n.not)(isOwnProperty(gen, data, property))) : cond;
26257
+ const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
26258
+ return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
25733
26259
  }
25734
26260
  code.noPropertyInData = noPropertyInData;
25735
26261
  function allSchemaProperties(schemaMap) {
@@ -25737,24 +26263,24 @@ function allSchemaProperties(schemaMap) {
25737
26263
  }
25738
26264
  code.allSchemaProperties = allSchemaProperties;
25739
26265
  function schemaProperties(it, schemaMap) {
25740
- return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$n.alwaysValidSchema)(it, schemaMap[p]));
26266
+ return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p]));
25741
26267
  }
25742
26268
  code.schemaProperties = schemaProperties;
25743
26269
  function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
25744
- const dataAndSchema = passSchema ? (0, codegen_1$n._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
26270
+ const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
25745
26271
  const valCxt = [
25746
- [names_1$3.default.instancePath, (0, codegen_1$n.strConcat)(names_1$3.default.instancePath, errorPath)],
25747
- [names_1$3.default.parentData, it.parentData],
25748
- [names_1$3.default.parentDataProperty, it.parentDataProperty],
25749
- [names_1$3.default.rootData, names_1$3.default.rootData]
26272
+ [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
26273
+ [names_1$5.default.parentData, it.parentData],
26274
+ [names_1$5.default.parentDataProperty, it.parentDataProperty],
26275
+ [names_1$5.default.rootData, names_1$5.default.rootData]
25750
26276
  ];
25751
26277
  if (it.opts.dynamicRef)
25752
- valCxt.push([names_1$3.default.dynamicAnchors, names_1$3.default.dynamicAnchors]);
25753
- const args = (0, codegen_1$n._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
25754
- return context !== codegen_1$n.nil ? (0, codegen_1$n._)`${func}.call(${context}, ${args})` : (0, codegen_1$n._)`${func}(${args})`;
26278
+ valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
26279
+ const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
26280
+ return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
25755
26281
  }
25756
26282
  code.callValidateCode = callValidateCode;
25757
- const newRegExp = (0, codegen_1$n._)`new RegExp`;
26283
+ const newRegExp = (0, codegen_1$q._)`new RegExp`;
25758
26284
  function usePattern({ gen, it: { opts } }, pattern2) {
25759
26285
  const u = opts.unicodeRegExp ? "u" : "";
25760
26286
  const { regExp } = opts.code;
@@ -25762,7 +26288,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
25762
26288
  return gen.scopeValue("pattern", {
25763
26289
  key: rx.toString(),
25764
26290
  ref: rx,
25765
- code: (0, codegen_1$n._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
26291
+ code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
25766
26292
  });
25767
26293
  }
25768
26294
  code.usePattern = usePattern;
@@ -25778,14 +26304,14 @@ function validateArray(cxt) {
25778
26304
  validateItems(() => gen.break());
25779
26305
  return valid;
25780
26306
  function validateItems(notValid) {
25781
- const len = gen.const("len", (0, codegen_1$n._)`${data}.length`);
26307
+ const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
25782
26308
  gen.forRange("i", 0, len, (i) => {
25783
26309
  cxt.subschema({
25784
26310
  keyword: keyword2,
25785
26311
  dataProp: i,
25786
- dataPropType: util_1$n.Type.Num
26312
+ dataPropType: util_1$p.Type.Num
25787
26313
  }, valid);
25788
- gen.if((0, codegen_1$n.not)(valid), notValid);
26314
+ gen.if((0, codegen_1$q.not)(valid), notValid);
25789
26315
  });
25790
26316
  }
25791
26317
  }
@@ -25794,7 +26320,7 @@ function validateUnion(cxt) {
25794
26320
  const { gen, schema, keyword: keyword2, it } = cxt;
25795
26321
  if (!Array.isArray(schema))
25796
26322
  throw new Error("ajv implementation error");
25797
- const alwaysValid = schema.some((sch) => (0, util_1$n.alwaysValidSchema)(it, sch));
26323
+ const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
25798
26324
  if (alwaysValid && !it.opts.unevaluated)
25799
26325
  return;
25800
26326
  const valid = gen.let("valid", false);
@@ -25805,214 +26331,202 @@ function validateUnion(cxt) {
25805
26331
  schemaProp: i,
25806
26332
  compositeRule: true
25807
26333
  }, schValid);
25808
- gen.assign(valid, (0, codegen_1$n._)`${valid} || ${schValid}`);
26334
+ gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
25809
26335
  const merged = cxt.mergeValidEvaluated(schCxt, schValid);
25810
26336
  if (!merged)
25811
- gen.if((0, codegen_1$n.not)(valid));
26337
+ gen.if((0, codegen_1$q.not)(valid));
25812
26338
  }));
25813
26339
  cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
25814
26340
  }
25815
26341
  code.validateUnion = validateUnion;
25816
- var hasRequiredKeyword;
25817
- function requireKeyword() {
25818
- if (hasRequiredKeyword) return keyword;
25819
- hasRequiredKeyword = 1;
25820
- Object.defineProperty(keyword, "__esModule", { value: true });
25821
- keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
25822
- const codegen_12 = codegen;
25823
- const names_12 = names$1;
25824
- const code_12 = code;
25825
- const errors_12 = errors;
25826
- function macroKeywordCode(cxt, def2) {
25827
- const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
25828
- const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
25829
- const schemaRef = useKeyword(gen, keyword2, macroSchema);
25830
- if (it.opts.validateSchema !== false)
25831
- it.self.validateSchema(macroSchema, true);
25832
- const valid = gen.name("valid");
25833
- cxt.subschema({
25834
- schema: macroSchema,
25835
- schemaPath: codegen_12.nil,
25836
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
25837
- topSchemaRef: schemaRef,
25838
- compositeRule: true
25839
- }, valid);
25840
- cxt.pass(valid, () => cxt.error(true));
25841
- }
25842
- keyword.macroKeywordCode = macroKeywordCode;
25843
- function funcKeywordCode(cxt, def2) {
25844
- var _a;
25845
- const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
25846
- checkAsyncKeyword(it, def2);
25847
- const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
25848
- const validateRef = useKeyword(gen, keyword2, validate2);
25849
- const valid = gen.let("valid");
25850
- cxt.block$data(valid, validateKeyword);
25851
- cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
25852
- function validateKeyword() {
25853
- if (def2.errors === false) {
25854
- assignValid();
25855
- if (def2.modifying)
25856
- modifyData(cxt);
25857
- reportErrs(() => cxt.error());
25858
- } else {
25859
- const ruleErrs = def2.async ? validateAsync() : validateSync();
25860
- if (def2.modifying)
25861
- modifyData(cxt);
25862
- reportErrs(() => addErrs(cxt, ruleErrs));
25863
- }
25864
- }
25865
- function validateAsync() {
25866
- const ruleErrs = gen.let("ruleErrs", null);
25867
- gen.try(() => assignValid((0, codegen_12._)`await `), (e) => gen.assign(valid, false).if((0, codegen_12._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_12._)`${e}.errors`), () => gen.throw(e)));
25868
- return ruleErrs;
25869
- }
25870
- function validateSync() {
25871
- const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
25872
- gen.assign(validateErrs, null);
25873
- assignValid(codegen_12.nil);
25874
- return validateErrs;
25875
- }
25876
- function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
25877
- const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
25878
- const passSchema = !("compile" in def2 && !$data || def2.schema === false);
25879
- gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
25880
- }
25881
- function reportErrs(errors2) {
25882
- var _a2;
25883
- gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
26342
+ Object.defineProperty(keyword, "__esModule", { value: true });
26343
+ keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
26344
+ const codegen_1$p = codegen;
26345
+ const names_1$4 = names$1;
26346
+ const code_1$9 = code;
26347
+ const errors_1$1 = errors;
26348
+ function macroKeywordCode(cxt, def2) {
26349
+ const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
26350
+ const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
26351
+ const schemaRef = useKeyword(gen, keyword2, macroSchema);
26352
+ if (it.opts.validateSchema !== false)
26353
+ it.self.validateSchema(macroSchema, true);
26354
+ const valid = gen.name("valid");
26355
+ cxt.subschema({
26356
+ schema: macroSchema,
26357
+ schemaPath: codegen_1$p.nil,
26358
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
26359
+ topSchemaRef: schemaRef,
26360
+ compositeRule: true
26361
+ }, valid);
26362
+ cxt.pass(valid, () => cxt.error(true));
26363
+ }
26364
+ keyword.macroKeywordCode = macroKeywordCode;
26365
+ function funcKeywordCode(cxt, def2) {
26366
+ var _a;
26367
+ const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
26368
+ checkAsyncKeyword(it, def2);
26369
+ const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
26370
+ const validateRef = useKeyword(gen, keyword2, validate2);
26371
+ const valid = gen.let("valid");
26372
+ cxt.block$data(valid, validateKeyword);
26373
+ cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
26374
+ function validateKeyword() {
26375
+ if (def2.errors === false) {
26376
+ assignValid();
26377
+ if (def2.modifying)
26378
+ modifyData(cxt);
26379
+ reportErrs(() => cxt.error());
26380
+ } else {
26381
+ const ruleErrs = def2.async ? validateAsync() : validateSync();
26382
+ if (def2.modifying)
26383
+ modifyData(cxt);
26384
+ reportErrs(() => addErrs(cxt, ruleErrs));
25884
26385
  }
25885
26386
  }
25886
- keyword.funcKeywordCode = funcKeywordCode;
25887
- function modifyData(cxt) {
25888
- const { gen, data, it } = cxt;
25889
- gen.if(it.parentData, () => gen.assign(data, (0, codegen_12._)`${it.parentData}[${it.parentDataProperty}]`));
25890
- }
25891
- function addErrs(cxt, errs) {
25892
- const { gen } = cxt;
25893
- gen.if((0, codegen_12._)`Array.isArray(${errs})`, () => {
25894
- gen.assign(names_12.default.vErrors, (0, codegen_12._)`${names_12.default.vErrors} === null ? ${errs} : ${names_12.default.vErrors}.concat(${errs})`).assign(names_12.default.errors, (0, codegen_12._)`${names_12.default.vErrors}.length`);
25895
- (0, errors_12.extendErrors)(cxt);
25896
- }, () => cxt.error());
25897
- }
25898
- function checkAsyncKeyword({ schemaEnv }, def2) {
25899
- if (def2.async && !schemaEnv.$async)
25900
- throw new Error("async keyword in sync schema");
25901
- }
25902
- function useKeyword(gen, keyword2, result) {
25903
- if (result === void 0)
25904
- throw new Error(`keyword "${keyword2}" failed to compile`);
25905
- return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_12.stringify)(result) });
25906
- }
25907
- function validSchemaType(schema, schemaType, allowUndefined = false) {
25908
- return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
25909
- }
25910
- keyword.validSchemaType = validSchemaType;
25911
- function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
25912
- if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
25913
- throw new Error("ajv implementation error");
25914
- }
25915
- const deps = def2.dependencies;
25916
- if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
25917
- throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
25918
- }
25919
- if (def2.validateSchema) {
25920
- const valid = def2.validateSchema(schema[keyword2]);
25921
- if (!valid) {
25922
- const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
25923
- if (opts.validateSchema === "log")
25924
- self2.logger.error(msg);
25925
- else
25926
- throw new Error(msg);
25927
- }
26387
+ function validateAsync() {
26388
+ const ruleErrs = gen.let("ruleErrs", null);
26389
+ gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
26390
+ return ruleErrs;
26391
+ }
26392
+ function validateSync() {
26393
+ const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
26394
+ gen.assign(validateErrs, null);
26395
+ assignValid(codegen_1$p.nil);
26396
+ return validateErrs;
26397
+ }
26398
+ function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
26399
+ const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
26400
+ const passSchema = !("compile" in def2 && !$data || def2.schema === false);
26401
+ gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
26402
+ }
26403
+ function reportErrs(errors2) {
26404
+ var _a2;
26405
+ gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
26406
+ }
26407
+ }
26408
+ keyword.funcKeywordCode = funcKeywordCode;
26409
+ function modifyData(cxt) {
26410
+ const { gen, data, it } = cxt;
26411
+ gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
26412
+ }
26413
+ function addErrs(cxt, errs) {
26414
+ const { gen } = cxt;
26415
+ gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
26416
+ gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
26417
+ (0, errors_1$1.extendErrors)(cxt);
26418
+ }, () => cxt.error());
26419
+ }
26420
+ function checkAsyncKeyword({ schemaEnv }, def2) {
26421
+ if (def2.async && !schemaEnv.$async)
26422
+ throw new Error("async keyword in sync schema");
26423
+ }
26424
+ function useKeyword(gen, keyword2, result) {
26425
+ if (result === void 0)
26426
+ throw new Error(`keyword "${keyword2}" failed to compile`);
26427
+ return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
26428
+ }
26429
+ function validSchemaType(schema, schemaType, allowUndefined = false) {
26430
+ return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
26431
+ }
26432
+ keyword.validSchemaType = validSchemaType;
26433
+ function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
26434
+ if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
26435
+ throw new Error("ajv implementation error");
26436
+ }
26437
+ const deps = def2.dependencies;
26438
+ if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
26439
+ throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
26440
+ }
26441
+ if (def2.validateSchema) {
26442
+ const valid = def2.validateSchema(schema[keyword2]);
26443
+ if (!valid) {
26444
+ const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
26445
+ if (opts.validateSchema === "log")
26446
+ self2.logger.error(msg);
26447
+ else
26448
+ throw new Error(msg);
25928
26449
  }
25929
26450
  }
25930
- keyword.validateKeywordUsage = validateKeywordUsage;
25931
- return keyword;
25932
26451
  }
26452
+ keyword.validateKeywordUsage = validateKeywordUsage;
25933
26453
  var subschema = {};
25934
- var hasRequiredSubschema;
25935
- function requireSubschema() {
25936
- if (hasRequiredSubschema) return subschema;
25937
- hasRequiredSubschema = 1;
25938
- Object.defineProperty(subschema, "__esModule", { value: true });
25939
- subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
25940
- const codegen_12 = codegen;
25941
- const util_12 = util;
25942
- function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
25943
- if (keyword2 !== void 0 && schema !== void 0) {
25944
- throw new Error('both "keyword" and "schema" passed, only one allowed');
25945
- }
25946
- if (keyword2 !== void 0) {
25947
- const sch = it.schema[keyword2];
25948
- return schemaProp === void 0 ? {
25949
- schema: sch,
25950
- schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}`,
25951
- errSchemaPath: `${it.errSchemaPath}/${keyword2}`
25952
- } : {
25953
- schema: sch[schemaProp],
25954
- schemaPath: (0, codegen_12._)`${it.schemaPath}${(0, codegen_12.getProperty)(keyword2)}${(0, codegen_12.getProperty)(schemaProp)}`,
25955
- errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_12.escapeFragment)(schemaProp)}`
25956
- };
25957
- }
25958
- if (schema !== void 0) {
25959
- if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
25960
- throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
25961
- }
25962
- return {
25963
- schema,
25964
- schemaPath,
25965
- topSchemaRef,
25966
- errSchemaPath
25967
- };
26454
+ Object.defineProperty(subschema, "__esModule", { value: true });
26455
+ subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
26456
+ const codegen_1$o = codegen;
26457
+ const util_1$o = util;
26458
+ function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
26459
+ if (keyword2 !== void 0 && schema !== void 0) {
26460
+ throw new Error('both "keyword" and "schema" passed, only one allowed');
26461
+ }
26462
+ if (keyword2 !== void 0) {
26463
+ const sch = it.schema[keyword2];
26464
+ return schemaProp === void 0 ? {
26465
+ schema: sch,
26466
+ schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
26467
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}`
26468
+ } : {
26469
+ schema: sch[schemaProp],
26470
+ schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
26471
+ errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
26472
+ };
26473
+ }
26474
+ if (schema !== void 0) {
26475
+ if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
26476
+ throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
25968
26477
  }
25969
- throw new Error('either "keyword" or "schema" must be passed');
25970
- }
25971
- subschema.getSubschema = getSubschema;
25972
- function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
25973
- if (data !== void 0 && dataProp !== void 0) {
25974
- throw new Error('both "data" and "dataProp" passed, only one allowed');
25975
- }
25976
- const { gen } = it;
25977
- if (dataProp !== void 0) {
25978
- const { errorPath, dataPathArr, opts } = it;
25979
- const nextData = gen.let("data", (0, codegen_12._)`${it.data}${(0, codegen_12.getProperty)(dataProp)}`, true);
25980
- dataContextProps(nextData);
25981
- subschema2.errorPath = (0, codegen_12.str)`${errorPath}${(0, util_12.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
25982
- subschema2.parentDataProperty = (0, codegen_12._)`${dataProp}`;
25983
- subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
25984
- }
25985
- if (data !== void 0) {
25986
- const nextData = data instanceof codegen_12.Name ? data : gen.let("data", data, true);
25987
- dataContextProps(nextData);
25988
- if (propertyName !== void 0)
25989
- subschema2.propertyName = propertyName;
25990
- }
25991
- if (dataTypes)
25992
- subschema2.dataTypes = dataTypes;
25993
- function dataContextProps(_nextData) {
25994
- subschema2.data = _nextData;
25995
- subschema2.dataLevel = it.dataLevel + 1;
25996
- subschema2.dataTypes = [];
25997
- it.definedProperties = /* @__PURE__ */ new Set();
25998
- subschema2.parentData = it.data;
25999
- subschema2.dataNames = [...it.dataNames, _nextData];
26000
- }
26001
- }
26002
- subschema.extendSubschemaData = extendSubschemaData;
26003
- function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
26004
- if (compositeRule !== void 0)
26005
- subschema2.compositeRule = compositeRule;
26006
- if (createErrors !== void 0)
26007
- subschema2.createErrors = createErrors;
26008
- if (allErrors !== void 0)
26009
- subschema2.allErrors = allErrors;
26010
- subschema2.jtdDiscriminator = jtdDiscriminator;
26011
- subschema2.jtdMetadata = jtdMetadata;
26012
- }
26013
- subschema.extendSubschemaMode = extendSubschemaMode;
26014
- return subschema;
26015
- }
26478
+ return {
26479
+ schema,
26480
+ schemaPath,
26481
+ topSchemaRef,
26482
+ errSchemaPath
26483
+ };
26484
+ }
26485
+ throw new Error('either "keyword" or "schema" must be passed');
26486
+ }
26487
+ subschema.getSubschema = getSubschema;
26488
+ function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
26489
+ if (data !== void 0 && dataProp !== void 0) {
26490
+ throw new Error('both "data" and "dataProp" passed, only one allowed');
26491
+ }
26492
+ const { gen } = it;
26493
+ if (dataProp !== void 0) {
26494
+ const { errorPath, dataPathArr, opts } = it;
26495
+ const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
26496
+ dataContextProps(nextData);
26497
+ subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
26498
+ subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
26499
+ subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
26500
+ }
26501
+ if (data !== void 0) {
26502
+ const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
26503
+ dataContextProps(nextData);
26504
+ if (propertyName !== void 0)
26505
+ subschema2.propertyName = propertyName;
26506
+ }
26507
+ if (dataTypes)
26508
+ subschema2.dataTypes = dataTypes;
26509
+ function dataContextProps(_nextData) {
26510
+ subschema2.data = _nextData;
26511
+ subschema2.dataLevel = it.dataLevel + 1;
26512
+ subschema2.dataTypes = [];
26513
+ it.definedProperties = /* @__PURE__ */ new Set();
26514
+ subschema2.parentData = it.data;
26515
+ subschema2.dataNames = [...it.dataNames, _nextData];
26516
+ }
26517
+ }
26518
+ subschema.extendSubschemaData = extendSubschemaData;
26519
+ function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
26520
+ if (compositeRule !== void 0)
26521
+ subschema2.compositeRule = compositeRule;
26522
+ if (createErrors !== void 0)
26523
+ subschema2.createErrors = createErrors;
26524
+ if (allErrors !== void 0)
26525
+ subschema2.allErrors = allErrors;
26526
+ subschema2.jtdDiscriminator = jtdDiscriminator;
26527
+ subschema2.jtdMetadata = jtdMetadata;
26528
+ }
26529
+ subschema.extendSubschemaMode = extendSubschemaMode;
26016
26530
  var resolve$2 = {};
26017
26531
  var fastDeepEqual = function equal(a, b) {
26018
26532
  if (a === b) return true;
@@ -26127,7 +26641,7 @@ function escapeJsonPtr(str) {
26127
26641
  var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
26128
26642
  Object.defineProperty(resolve$2, "__esModule", { value: true });
26129
26643
  resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
26130
- const util_1$m = util;
26644
+ const util_1$n = util;
26131
26645
  const equal$3 = fastDeepEqual;
26132
26646
  const traverse = jsonSchemaTraverseExports;
26133
26647
  const SIMPLE_INLINED = /* @__PURE__ */ new Set([
@@ -26186,7 +26700,7 @@ function countKeys(schema) {
26186
26700
  if (SIMPLE_INLINED.has(key))
26187
26701
  continue;
26188
26702
  if (typeof schema[key] == "object") {
26189
- (0, util_1$m.eachItem)(schema[key], (sch) => count += countKeys(sch));
26703
+ (0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
26190
26704
  }
26191
26705
  if (count === Infinity)
26192
26706
  return Infinity;
@@ -26274,528 +26788,516 @@ function getSchemaRefs(schema, baseId) {
26274
26788
  }
26275
26789
  }
26276
26790
  resolve$2.getSchemaRefs = getSchemaRefs;
26277
- var hasRequiredValidate;
26278
- function requireValidate() {
26279
- if (hasRequiredValidate) return validate;
26280
- hasRequiredValidate = 1;
26281
- Object.defineProperty(validate, "__esModule", { value: true });
26282
- validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
26283
- const boolSchema_1 = requireBoolSchema();
26284
- const dataType_12 = dataType;
26285
- const applicability_12 = applicability;
26286
- const dataType_2 = dataType;
26287
- const defaults_1 = requireDefaults();
26288
- const keyword_1 = requireKeyword();
26289
- const subschema_1 = requireSubschema();
26290
- const codegen_12 = codegen;
26291
- const names_12 = names$1;
26292
- const resolve_12 = resolve$2;
26293
- const util_12 = util;
26294
- const errors_12 = errors;
26295
- function validateFunctionCode(it) {
26296
- if (isSchemaObj(it)) {
26297
- checkKeywords(it);
26298
- if (schemaCxtHasRules(it)) {
26299
- topSchemaObjCode(it);
26300
- return;
26301
- }
26791
+ Object.defineProperty(validate, "__esModule", { value: true });
26792
+ validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
26793
+ const boolSchema_1 = boolSchema;
26794
+ const dataType_1$1 = dataType;
26795
+ const applicability_1 = applicability;
26796
+ const dataType_2 = dataType;
26797
+ const defaults_1 = defaults;
26798
+ const keyword_1 = keyword;
26799
+ const subschema_1 = subschema;
26800
+ const codegen_1$n = codegen;
26801
+ const names_1$3 = names$1;
26802
+ const resolve_1$2 = resolve$2;
26803
+ const util_1$m = util;
26804
+ const errors_1 = errors;
26805
+ function validateFunctionCode(it) {
26806
+ if (isSchemaObj(it)) {
26807
+ checkKeywords(it);
26808
+ if (schemaCxtHasRules(it)) {
26809
+ topSchemaObjCode(it);
26810
+ return;
26302
26811
  }
26303
- validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
26304
26812
  }
26305
- validate.validateFunctionCode = validateFunctionCode;
26306
- function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
26307
- if (opts.code.es5) {
26308
- gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
26309
- gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
26310
- destructureValCxtES5(gen, opts);
26311
- gen.code(body);
26312
- });
26313
- } else {
26314
- gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
26315
- }
26316
- }
26317
- function destructureValCxt(opts) {
26318
- return (0, codegen_12._)`{${names_12.default.instancePath}="", ${names_12.default.parentData}, ${names_12.default.parentDataProperty}, ${names_12.default.rootData}=${names_12.default.data}${opts.dynamicRef ? (0, codegen_12._)`, ${names_12.default.dynamicAnchors}={}` : codegen_12.nil}}={}`;
26319
- }
26320
- function destructureValCxtES5(gen, opts) {
26321
- gen.if(names_12.default.valCxt, () => {
26322
- gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
26323
- gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
26324
- gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
26325
- gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
26326
- if (opts.dynamicRef)
26327
- gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
26328
- }, () => {
26329
- gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
26330
- gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
26331
- gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
26332
- gen.var(names_12.default.rootData, names_12.default.data);
26333
- if (opts.dynamicRef)
26334
- gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
26335
- });
26336
- }
26337
- function topSchemaObjCode(it) {
26338
- const { schema, opts, gen } = it;
26339
- validateFunction(it, () => {
26340
- if (opts.$comment && schema.$comment)
26341
- commentKeyword(it);
26342
- checkNoDefault(it);
26343
- gen.let(names_12.default.vErrors, null);
26344
- gen.let(names_12.default.errors, 0);
26345
- if (opts.unevaluated)
26346
- resetEvaluated(it);
26347
- typeAndKeywords(it);
26348
- returnResults(it);
26813
+ validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
26814
+ }
26815
+ validate.validateFunctionCode = validateFunctionCode;
26816
+ function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
26817
+ if (opts.code.es5) {
26818
+ gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
26819
+ gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
26820
+ destructureValCxtES5(gen, opts);
26821
+ gen.code(body);
26349
26822
  });
26350
- return;
26351
- }
26352
- function resetEvaluated(it) {
26353
- const { gen, validateName } = it;
26354
- it.evaluated = gen.const("evaluated", (0, codegen_12._)`${validateName}.evaluated`);
26355
- gen.if((0, codegen_12._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_12._)`${it.evaluated}.props`, (0, codegen_12._)`undefined`));
26356
- gen.if((0, codegen_12._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_12._)`${it.evaluated}.items`, (0, codegen_12._)`undefined`));
26357
- }
26358
- function funcSourceUrl(schema, opts) {
26359
- const schId = typeof schema == "object" && schema[opts.schemaId];
26360
- return schId && (opts.code.source || opts.code.process) ? (0, codegen_12._)`/*# sourceURL=${schId} */` : codegen_12.nil;
26361
- }
26362
- function subschemaCode(it, valid) {
26363
- if (isSchemaObj(it)) {
26364
- checkKeywords(it);
26365
- if (schemaCxtHasRules(it)) {
26366
- subSchemaObjCode(it, valid);
26367
- return;
26368
- }
26369
- }
26370
- (0, boolSchema_1.boolOrEmptySchema)(it, valid);
26371
- }
26372
- function schemaCxtHasRules({ schema, self: self2 }) {
26373
- if (typeof schema == "boolean")
26374
- return !schema;
26375
- for (const key in schema)
26376
- if (self2.RULES.all[key])
26377
- return true;
26378
- return false;
26379
- }
26380
- function isSchemaObj(it) {
26381
- return typeof it.schema != "boolean";
26382
- }
26383
- function subSchemaObjCode(it, valid) {
26384
- const { schema, gen, opts } = it;
26823
+ } else {
26824
+ gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
26825
+ }
26826
+ }
26827
+ function destructureValCxt(opts) {
26828
+ return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
26829
+ }
26830
+ function destructureValCxtES5(gen, opts) {
26831
+ gen.if(names_1$3.default.valCxt, () => {
26832
+ gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
26833
+ gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
26834
+ gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
26835
+ gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
26836
+ if (opts.dynamicRef)
26837
+ gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
26838
+ }, () => {
26839
+ gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
26840
+ gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
26841
+ gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
26842
+ gen.var(names_1$3.default.rootData, names_1$3.default.data);
26843
+ if (opts.dynamicRef)
26844
+ gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
26845
+ });
26846
+ }
26847
+ function topSchemaObjCode(it) {
26848
+ const { schema, opts, gen } = it;
26849
+ validateFunction(it, () => {
26385
26850
  if (opts.$comment && schema.$comment)
26386
26851
  commentKeyword(it);
26387
- updateContext(it);
26388
- checkAsyncSchema(it);
26389
- const errsCount = gen.const("_errs", names_12.default.errors);
26390
- typeAndKeywords(it, errsCount);
26391
- gen.var(valid, (0, codegen_12._)`${errsCount} === ${names_12.default.errors}`);
26392
- }
26393
- function checkKeywords(it) {
26394
- (0, util_12.checkUnknownRules)(it);
26395
- checkRefsAndKeywords(it);
26396
- }
26397
- function typeAndKeywords(it, errsCount) {
26398
- if (it.opts.jtd)
26399
- return schemaKeywords(it, [], false, errsCount);
26400
- const types2 = (0, dataType_12.getSchemaTypes)(it.schema);
26401
- const checkedTypes = (0, dataType_12.coerceAndCheckDataType)(it, types2);
26402
- schemaKeywords(it, types2, !checkedTypes, errsCount);
26403
- }
26404
- function checkRefsAndKeywords(it) {
26405
- const { schema, errSchemaPath, opts, self: self2 } = it;
26406
- if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_12.schemaHasRulesButRef)(schema, self2.RULES)) {
26407
- self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
26408
- }
26409
- }
26410
- function checkNoDefault(it) {
26411
- const { schema, opts } = it;
26412
- if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
26413
- (0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
26852
+ checkNoDefault(it);
26853
+ gen.let(names_1$3.default.vErrors, null);
26854
+ gen.let(names_1$3.default.errors, 0);
26855
+ if (opts.unevaluated)
26856
+ resetEvaluated(it);
26857
+ typeAndKeywords(it);
26858
+ returnResults(it);
26859
+ });
26860
+ return;
26861
+ }
26862
+ function resetEvaluated(it) {
26863
+ const { gen, validateName } = it;
26864
+ it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
26865
+ gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
26866
+ gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
26867
+ }
26868
+ function funcSourceUrl(schema, opts) {
26869
+ const schId = typeof schema == "object" && schema[opts.schemaId];
26870
+ return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
26871
+ }
26872
+ function subschemaCode(it, valid) {
26873
+ if (isSchemaObj(it)) {
26874
+ checkKeywords(it);
26875
+ if (schemaCxtHasRules(it)) {
26876
+ subSchemaObjCode(it, valid);
26877
+ return;
26414
26878
  }
26415
26879
  }
26416
- function updateContext(it) {
26417
- const schId = it.schema[it.opts.schemaId];
26418
- if (schId)
26419
- it.baseId = (0, resolve_12.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
26420
- }
26421
- function checkAsyncSchema(it) {
26422
- if (it.schema.$async && !it.schemaEnv.$async)
26423
- throw new Error("async schema in sync schema");
26424
- }
26425
- function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
26426
- const msg = schema.$comment;
26427
- if (opts.$comment === true) {
26428
- gen.code((0, codegen_12._)`${names_12.default.self}.logger.log(${msg})`);
26429
- } else if (typeof opts.$comment == "function") {
26430
- const schemaPath = (0, codegen_12.str)`${errSchemaPath}/$comment`;
26431
- const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
26432
- gen.code((0, codegen_12._)`${names_12.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
26433
- }
26880
+ (0, boolSchema_1.boolOrEmptySchema)(it, valid);
26881
+ }
26882
+ function schemaCxtHasRules({ schema, self: self2 }) {
26883
+ if (typeof schema == "boolean")
26884
+ return !schema;
26885
+ for (const key in schema)
26886
+ if (self2.RULES.all[key])
26887
+ return true;
26888
+ return false;
26889
+ }
26890
+ function isSchemaObj(it) {
26891
+ return typeof it.schema != "boolean";
26892
+ }
26893
+ function subSchemaObjCode(it, valid) {
26894
+ const { schema, gen, opts } = it;
26895
+ if (opts.$comment && schema.$comment)
26896
+ commentKeyword(it);
26897
+ updateContext(it);
26898
+ checkAsyncSchema(it);
26899
+ const errsCount = gen.const("_errs", names_1$3.default.errors);
26900
+ typeAndKeywords(it, errsCount);
26901
+ gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
26902
+ }
26903
+ function checkKeywords(it) {
26904
+ (0, util_1$m.checkUnknownRules)(it);
26905
+ checkRefsAndKeywords(it);
26906
+ }
26907
+ function typeAndKeywords(it, errsCount) {
26908
+ if (it.opts.jtd)
26909
+ return schemaKeywords(it, [], false, errsCount);
26910
+ const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
26911
+ const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
26912
+ schemaKeywords(it, types2, !checkedTypes, errsCount);
26913
+ }
26914
+ function checkRefsAndKeywords(it) {
26915
+ const { schema, errSchemaPath, opts, self: self2 } = it;
26916
+ if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self2.RULES)) {
26917
+ self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
26918
+ }
26919
+ }
26920
+ function checkNoDefault(it) {
26921
+ const { schema, opts } = it;
26922
+ if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
26923
+ (0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
26924
+ }
26925
+ }
26926
+ function updateContext(it) {
26927
+ const schId = it.schema[it.opts.schemaId];
26928
+ if (schId)
26929
+ it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
26930
+ }
26931
+ function checkAsyncSchema(it) {
26932
+ if (it.schema.$async && !it.schemaEnv.$async)
26933
+ throw new Error("async schema in sync schema");
26934
+ }
26935
+ function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
26936
+ const msg = schema.$comment;
26937
+ if (opts.$comment === true) {
26938
+ gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
26939
+ } else if (typeof opts.$comment == "function") {
26940
+ const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
26941
+ const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
26942
+ gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
26943
+ }
26944
+ }
26945
+ function returnResults(it) {
26946
+ const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
26947
+ if (schemaEnv.$async) {
26948
+ gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError2}(${names_1$3.default.vErrors})`));
26949
+ } else {
26950
+ gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
26951
+ if (opts.unevaluated)
26952
+ assignEvaluated(it);
26953
+ gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
26954
+ }
26955
+ }
26956
+ function assignEvaluated({ gen, evaluated, props, items: items2 }) {
26957
+ if (props instanceof codegen_1$n.Name)
26958
+ gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
26959
+ if (items2 instanceof codegen_1$n.Name)
26960
+ gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
26961
+ }
26962
+ function schemaKeywords(it, types2, typeErrors, errsCount) {
26963
+ const { gen, schema, data, allErrors, opts, self: self2 } = it;
26964
+ const { RULES } = self2;
26965
+ if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
26966
+ gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
26967
+ return;
26434
26968
  }
26435
- function returnResults(it) {
26436
- const { gen, schemaEnv, validateName, ValidationError, opts } = it;
26437
- if (schemaEnv.$async) {
26438
- gen.if((0, codegen_12._)`${names_12.default.errors} === 0`, () => gen.return(names_12.default.data), () => gen.throw((0, codegen_12._)`new ${ValidationError}(${names_12.default.vErrors})`));
26439
- } else {
26440
- gen.assign((0, codegen_12._)`${validateName}.errors`, names_12.default.vErrors);
26441
- if (opts.unevaluated)
26442
- assignEvaluated(it);
26443
- gen.return((0, codegen_12._)`${names_12.default.errors} === 0`);
26444
- }
26445
- }
26446
- function assignEvaluated({ gen, evaluated, props, items: items2 }) {
26447
- if (props instanceof codegen_12.Name)
26448
- gen.assign((0, codegen_12._)`${evaluated}.props`, props);
26449
- if (items2 instanceof codegen_12.Name)
26450
- gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
26451
- }
26452
- function schemaKeywords(it, types2, typeErrors, errsCount) {
26453
- const { gen, schema, data, allErrors, opts, self: self2 } = it;
26454
- const { RULES } = self2;
26455
- if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
26456
- gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
26969
+ if (!opts.jtd)
26970
+ checkStrictTypes(it, types2);
26971
+ gen.block(() => {
26972
+ for (const group of RULES.rules)
26973
+ groupKeywords(group);
26974
+ groupKeywords(RULES.post);
26975
+ });
26976
+ function groupKeywords(group) {
26977
+ if (!(0, applicability_1.shouldUseGroup)(schema, group))
26457
26978
  return;
26458
- }
26459
- if (!opts.jtd)
26460
- checkStrictTypes(it, types2);
26461
- gen.block(() => {
26462
- for (const group of RULES.rules)
26463
- groupKeywords(group);
26464
- groupKeywords(RULES.post);
26465
- });
26466
- function groupKeywords(group) {
26467
- if (!(0, applicability_12.shouldUseGroup)(schema, group))
26468
- return;
26469
- if (group.type) {
26470
- gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
26471
- iterateKeywords(it, group);
26472
- if (types2.length === 1 && types2[0] === group.type && typeErrors) {
26473
- gen.else();
26474
- (0, dataType_2.reportTypeError)(it);
26475
- }
26476
- gen.endIf();
26477
- } else {
26478
- iterateKeywords(it, group);
26979
+ if (group.type) {
26980
+ gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
26981
+ iterateKeywords(it, group);
26982
+ if (types2.length === 1 && types2[0] === group.type && typeErrors) {
26983
+ gen.else();
26984
+ (0, dataType_2.reportTypeError)(it);
26479
26985
  }
26480
- if (!allErrors)
26481
- gen.if((0, codegen_12._)`${names_12.default.errors} === ${errsCount || 0}`);
26986
+ gen.endIf();
26987
+ } else {
26988
+ iterateKeywords(it, group);
26482
26989
  }
26990
+ if (!allErrors)
26991
+ gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
26483
26992
  }
26484
- function iterateKeywords(it, group) {
26485
- const { gen, schema, opts: { useDefaults } } = it;
26486
- if (useDefaults)
26487
- (0, defaults_1.assignDefaults)(it, group.type);
26488
- gen.block(() => {
26489
- for (const rule of group.rules) {
26490
- if ((0, applicability_12.shouldUseRule)(schema, rule)) {
26491
- keywordCode(it, rule.keyword, rule.definition, group.type);
26492
- }
26493
- }
26494
- });
26495
- }
26496
- function checkStrictTypes(it, types2) {
26497
- if (it.schemaEnv.meta || !it.opts.strictTypes)
26498
- return;
26499
- checkContextTypes(it, types2);
26500
- if (!it.opts.allowUnionTypes)
26501
- checkMultipleTypes(it, types2);
26502
- checkKeywordTypes(it, it.dataTypes);
26503
- }
26504
- function checkContextTypes(it, types2) {
26505
- if (!types2.length)
26506
- return;
26507
- if (!it.dataTypes.length) {
26508
- it.dataTypes = types2;
26509
- return;
26510
- }
26511
- types2.forEach((t) => {
26512
- if (!includesType(it.dataTypes, t)) {
26513
- strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
26514
- }
26515
- });
26516
- narrowSchemaTypes(it, types2);
26517
- }
26518
- function checkMultipleTypes(it, ts) {
26519
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
26520
- strictTypesError(it, "use allowUnionTypes to allow union type keyword");
26521
- }
26522
- }
26523
- function checkKeywordTypes(it, ts) {
26524
- const rules2 = it.self.RULES.all;
26525
- for (const keyword2 in rules2) {
26526
- const rule = rules2[keyword2];
26527
- if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
26528
- const { type: type2 } = rule.definition;
26529
- if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
26530
- strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
26531
- }
26532
- }
26533
- }
26534
- }
26535
- function hasApplicableType(schTs, kwdT) {
26536
- return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
26537
- }
26538
- function includesType(ts, t) {
26539
- return ts.includes(t) || t === "integer" && ts.includes("number");
26540
- }
26541
- function narrowSchemaTypes(it, withTypes) {
26542
- const ts = [];
26543
- for (const t of it.dataTypes) {
26544
- if (includesType(withTypes, t))
26545
- ts.push(t);
26546
- else if (withTypes.includes("integer") && t === "number")
26547
- ts.push("integer");
26548
- }
26549
- it.dataTypes = ts;
26550
- }
26551
- function strictTypesError(it, msg) {
26552
- const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
26553
- msg += ` at "${schemaPath}" (strictTypes)`;
26554
- (0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
26555
- }
26556
- class KeywordCxt {
26557
- constructor(it, def2, keyword2) {
26558
- (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
26559
- this.gen = it.gen;
26560
- this.allErrors = it.allErrors;
26561
- this.keyword = keyword2;
26562
- this.data = it.data;
26563
- this.schema = it.schema[keyword2];
26564
- this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
26565
- this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
26566
- this.schemaType = def2.schemaType;
26567
- this.parentSchema = it.schema;
26568
- this.params = {};
26569
- this.it = it;
26570
- this.def = def2;
26571
- if (this.$data) {
26572
- this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
26573
- } else {
26574
- this.schemaCode = this.schemaValue;
26575
- if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
26576
- throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
26577
- }
26578
- }
26579
- if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
26580
- this.errsCount = it.gen.const("_errs", names_12.default.errors);
26993
+ }
26994
+ function iterateKeywords(it, group) {
26995
+ const { gen, schema, opts: { useDefaults } } = it;
26996
+ if (useDefaults)
26997
+ (0, defaults_1.assignDefaults)(it, group.type);
26998
+ gen.block(() => {
26999
+ for (const rule of group.rules) {
27000
+ if ((0, applicability_1.shouldUseRule)(schema, rule)) {
27001
+ keywordCode(it, rule.keyword, rule.definition, group.type);
26581
27002
  }
26582
27003
  }
26583
- result(condition, successAction, failAction) {
26584
- this.failResult((0, codegen_12.not)(condition), successAction, failAction);
27004
+ });
27005
+ }
27006
+ function checkStrictTypes(it, types2) {
27007
+ if (it.schemaEnv.meta || !it.opts.strictTypes)
27008
+ return;
27009
+ checkContextTypes(it, types2);
27010
+ if (!it.opts.allowUnionTypes)
27011
+ checkMultipleTypes(it, types2);
27012
+ checkKeywordTypes(it, it.dataTypes);
27013
+ }
27014
+ function checkContextTypes(it, types2) {
27015
+ if (!types2.length)
27016
+ return;
27017
+ if (!it.dataTypes.length) {
27018
+ it.dataTypes = types2;
27019
+ return;
27020
+ }
27021
+ types2.forEach((t) => {
27022
+ if (!includesType(it.dataTypes, t)) {
27023
+ strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
26585
27024
  }
26586
- failResult(condition, successAction, failAction) {
26587
- this.gen.if(condition);
26588
- if (failAction)
26589
- failAction();
26590
- else
26591
- this.error();
26592
- if (successAction) {
26593
- this.gen.else();
26594
- successAction();
26595
- if (this.allErrors)
26596
- this.gen.endIf();
26597
- } else {
26598
- if (this.allErrors)
26599
- this.gen.endIf();
26600
- else
26601
- this.gen.else();
27025
+ });
27026
+ narrowSchemaTypes(it, types2);
27027
+ }
27028
+ function checkMultipleTypes(it, ts) {
27029
+ if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
27030
+ strictTypesError(it, "use allowUnionTypes to allow union type keyword");
27031
+ }
27032
+ }
27033
+ function checkKeywordTypes(it, ts) {
27034
+ const rules2 = it.self.RULES.all;
27035
+ for (const keyword2 in rules2) {
27036
+ const rule = rules2[keyword2];
27037
+ if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
27038
+ const { type: type2 } = rule.definition;
27039
+ if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
27040
+ strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
27041
+ }
27042
+ }
27043
+ }
27044
+ }
27045
+ function hasApplicableType(schTs, kwdT) {
27046
+ return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
27047
+ }
27048
+ function includesType(ts, t) {
27049
+ return ts.includes(t) || t === "integer" && ts.includes("number");
27050
+ }
27051
+ function narrowSchemaTypes(it, withTypes) {
27052
+ const ts = [];
27053
+ for (const t of it.dataTypes) {
27054
+ if (includesType(withTypes, t))
27055
+ ts.push(t);
27056
+ else if (withTypes.includes("integer") && t === "number")
27057
+ ts.push("integer");
27058
+ }
27059
+ it.dataTypes = ts;
27060
+ }
27061
+ function strictTypesError(it, msg) {
27062
+ const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
27063
+ msg += ` at "${schemaPath}" (strictTypes)`;
27064
+ (0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
27065
+ }
27066
+ class KeywordCxt {
27067
+ constructor(it, def2, keyword2) {
27068
+ (0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
27069
+ this.gen = it.gen;
27070
+ this.allErrors = it.allErrors;
27071
+ this.keyword = keyword2;
27072
+ this.data = it.data;
27073
+ this.schema = it.schema[keyword2];
27074
+ this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
27075
+ this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
27076
+ this.schemaType = def2.schemaType;
27077
+ this.parentSchema = it.schema;
27078
+ this.params = {};
27079
+ this.it = it;
27080
+ this.def = def2;
27081
+ if (this.$data) {
27082
+ this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
27083
+ } else {
27084
+ this.schemaCode = this.schemaValue;
27085
+ if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
27086
+ throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
26602
27087
  }
26603
27088
  }
26604
- pass(condition, failAction) {
26605
- this.failResult((0, codegen_12.not)(condition), void 0, failAction);
27089
+ if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
27090
+ this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
26606
27091
  }
26607
- fail(condition) {
26608
- if (condition === void 0) {
26609
- this.error();
26610
- if (!this.allErrors)
26611
- this.gen.if(false);
26612
- return;
26613
- }
26614
- this.gen.if(condition);
27092
+ }
27093
+ result(condition, successAction, failAction) {
27094
+ this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
27095
+ }
27096
+ failResult(condition, successAction, failAction) {
27097
+ this.gen.if(condition);
27098
+ if (failAction)
27099
+ failAction();
27100
+ else
26615
27101
  this.error();
27102
+ if (successAction) {
27103
+ this.gen.else();
27104
+ successAction();
27105
+ if (this.allErrors)
27106
+ this.gen.endIf();
27107
+ } else {
26616
27108
  if (this.allErrors)
26617
27109
  this.gen.endIf();
26618
27110
  else
26619
27111
  this.gen.else();
26620
27112
  }
26621
- fail$data(condition) {
26622
- if (!this.$data)
26623
- return this.fail(condition);
26624
- const { schemaCode } = this;
26625
- this.fail((0, codegen_12._)`${schemaCode} !== undefined && (${(0, codegen_12.or)(this.invalid$data(), condition)})`);
26626
- }
26627
- error(append, errorParams, errorPaths) {
26628
- if (errorParams) {
26629
- this.setParams(errorParams);
26630
- this._error(append, errorPaths);
26631
- this.setParams({});
26632
- return;
26633
- }
26634
- this._error(append, errorPaths);
26635
- }
26636
- _error(append, errorPaths) {
26637
- (append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
26638
- }
26639
- $dataError() {
26640
- (0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
26641
- }
26642
- reset() {
26643
- if (this.errsCount === void 0)
26644
- throw new Error('add "trackErrors" to keyword definition');
26645
- (0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
26646
- }
26647
- ok(cond) {
27113
+ }
27114
+ pass(condition, failAction) {
27115
+ this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
27116
+ }
27117
+ fail(condition) {
27118
+ if (condition === void 0) {
27119
+ this.error();
26648
27120
  if (!this.allErrors)
26649
- this.gen.if(cond);
26650
- }
26651
- setParams(obj, assign) {
26652
- if (assign)
26653
- Object.assign(this.params, obj);
26654
- else
26655
- this.params = obj;
27121
+ this.gen.if(false);
27122
+ return;
26656
27123
  }
26657
- block$data(valid, codeBlock, $dataValid = codegen_12.nil) {
26658
- this.gen.block(() => {
26659
- this.check$data(valid, $dataValid);
26660
- codeBlock();
26661
- });
27124
+ this.gen.if(condition);
27125
+ this.error();
27126
+ if (this.allErrors)
27127
+ this.gen.endIf();
27128
+ else
27129
+ this.gen.else();
27130
+ }
27131
+ fail$data(condition) {
27132
+ if (!this.$data)
27133
+ return this.fail(condition);
27134
+ const { schemaCode } = this;
27135
+ this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
27136
+ }
27137
+ error(append, errorParams, errorPaths) {
27138
+ if (errorParams) {
27139
+ this.setParams(errorParams);
27140
+ this._error(append, errorPaths);
27141
+ this.setParams({});
27142
+ return;
26662
27143
  }
26663
- check$data(valid = codegen_12.nil, $dataValid = codegen_12.nil) {
26664
- if (!this.$data)
26665
- return;
26666
- const { gen, schemaCode, schemaType, def: def2 } = this;
26667
- gen.if((0, codegen_12.or)((0, codegen_12._)`${schemaCode} === undefined`, $dataValid));
26668
- if (valid !== codegen_12.nil)
26669
- gen.assign(valid, true);
26670
- if (schemaType.length || def2.validateSchema) {
26671
- gen.elseIf(this.invalid$data());
26672
- this.$dataError();
26673
- if (valid !== codegen_12.nil)
26674
- gen.assign(valid, false);
26675
- }
26676
- gen.else();
27144
+ this._error(append, errorPaths);
27145
+ }
27146
+ _error(append, errorPaths) {
27147
+ (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
27148
+ }
27149
+ $dataError() {
27150
+ (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
27151
+ }
27152
+ reset() {
27153
+ if (this.errsCount === void 0)
27154
+ throw new Error('add "trackErrors" to keyword definition');
27155
+ (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
27156
+ }
27157
+ ok(cond) {
27158
+ if (!this.allErrors)
27159
+ this.gen.if(cond);
27160
+ }
27161
+ setParams(obj, assign) {
27162
+ if (assign)
27163
+ Object.assign(this.params, obj);
27164
+ else
27165
+ this.params = obj;
27166
+ }
27167
+ block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
27168
+ this.gen.block(() => {
27169
+ this.check$data(valid, $dataValid);
27170
+ codeBlock();
27171
+ });
27172
+ }
27173
+ check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
27174
+ if (!this.$data)
27175
+ return;
27176
+ const { gen, schemaCode, schemaType, def: def2 } = this;
27177
+ gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
27178
+ if (valid !== codegen_1$n.nil)
27179
+ gen.assign(valid, true);
27180
+ if (schemaType.length || def2.validateSchema) {
27181
+ gen.elseIf(this.invalid$data());
27182
+ this.$dataError();
27183
+ if (valid !== codegen_1$n.nil)
27184
+ gen.assign(valid, false);
26677
27185
  }
26678
- invalid$data() {
26679
- const { gen, schemaCode, schemaType, def: def2, it } = this;
26680
- return (0, codegen_12.or)(wrong$DataType(), invalid$DataSchema());
26681
- function wrong$DataType() {
26682
- if (schemaType.length) {
26683
- if (!(schemaCode instanceof codegen_12.Name))
26684
- throw new Error("ajv implementation error");
26685
- const st = Array.isArray(schemaType) ? schemaType : [schemaType];
26686
- return (0, codegen_12._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
26687
- }
26688
- return codegen_12.nil;
26689
- }
26690
- function invalid$DataSchema() {
26691
- if (def2.validateSchema) {
26692
- const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
26693
- return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
26694
- }
26695
- return codegen_12.nil;
26696
- }
26697
- }
26698
- subschema(appl, valid) {
26699
- const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
26700
- (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
26701
- (0, subschema_1.extendSubschemaMode)(subschema2, appl);
26702
- const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
26703
- subschemaCode(nextContext, valid);
26704
- return nextContext;
26705
- }
26706
- mergeEvaluated(schemaCxt, toName) {
26707
- const { it, gen } = this;
26708
- if (!it.opts.unevaluated)
26709
- return;
26710
- if (it.props !== true && schemaCxt.props !== void 0) {
26711
- it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
26712
- }
26713
- if (it.items !== true && schemaCxt.items !== void 0) {
26714
- it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
27186
+ gen.else();
27187
+ }
27188
+ invalid$data() {
27189
+ const { gen, schemaCode, schemaType, def: def2, it } = this;
27190
+ return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
27191
+ function wrong$DataType() {
27192
+ if (schemaType.length) {
27193
+ if (!(schemaCode instanceof codegen_1$n.Name))
27194
+ throw new Error("ajv implementation error");
27195
+ const st = Array.isArray(schemaType) ? schemaType : [schemaType];
27196
+ return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
26715
27197
  }
27198
+ return codegen_1$n.nil;
26716
27199
  }
26717
- mergeValidEvaluated(schemaCxt, valid) {
26718
- const { it, gen } = this;
26719
- if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
26720
- gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_12.Name));
26721
- return true;
27200
+ function invalid$DataSchema() {
27201
+ if (def2.validateSchema) {
27202
+ const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
27203
+ return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
26722
27204
  }
27205
+ return codegen_1$n.nil;
26723
27206
  }
26724
27207
  }
26725
- validate.KeywordCxt = KeywordCxt;
26726
- function keywordCode(it, keyword2, def2, ruleType) {
26727
- const cxt = new KeywordCxt(it, def2, keyword2);
26728
- if ("code" in def2) {
26729
- def2.code(cxt, ruleType);
26730
- } else if (cxt.$data && def2.validate) {
26731
- (0, keyword_1.funcKeywordCode)(cxt, def2);
26732
- } else if ("macro" in def2) {
26733
- (0, keyword_1.macroKeywordCode)(cxt, def2);
26734
- } else if (def2.compile || def2.validate) {
26735
- (0, keyword_1.funcKeywordCode)(cxt, def2);
26736
- }
26737
- }
26738
- const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
26739
- const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
26740
- function getData($data, { dataLevel, dataNames, dataPathArr }) {
26741
- let jsonPointer;
26742
- let data;
26743
- if ($data === "")
26744
- return names_12.default.rootData;
26745
- if ($data[0] === "/") {
26746
- if (!JSON_POINTER.test($data))
26747
- throw new Error(`Invalid JSON-pointer: ${$data}`);
26748
- jsonPointer = $data;
26749
- data = names_12.default.rootData;
26750
- } else {
26751
- const matches = RELATIVE_JSON_POINTER.exec($data);
26752
- if (!matches)
26753
- throw new Error(`Invalid JSON-pointer: ${$data}`);
26754
- const up = +matches[1];
26755
- jsonPointer = matches[2];
26756
- if (jsonPointer === "#") {
26757
- if (up >= dataLevel)
26758
- throw new Error(errorMsg("property/index", up));
26759
- return dataPathArr[dataLevel - up];
26760
- }
26761
- if (up > dataLevel)
26762
- throw new Error(errorMsg("data", up));
26763
- data = dataNames[dataLevel - up];
26764
- if (!jsonPointer)
26765
- return data;
27208
+ subschema(appl, valid) {
27209
+ const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
27210
+ (0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
27211
+ (0, subschema_1.extendSubschemaMode)(subschema2, appl);
27212
+ const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
27213
+ subschemaCode(nextContext, valid);
27214
+ return nextContext;
27215
+ }
27216
+ mergeEvaluated(schemaCxt, toName) {
27217
+ const { it, gen } = this;
27218
+ if (!it.opts.unevaluated)
27219
+ return;
27220
+ if (it.props !== true && schemaCxt.props !== void 0) {
27221
+ it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
26766
27222
  }
26767
- let expr = data;
26768
- const segments = jsonPointer.split("/");
26769
- for (const segment of segments) {
26770
- if (segment) {
26771
- data = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)((0, util_12.unescapeJsonPointer)(segment))}`;
26772
- expr = (0, codegen_12._)`${expr} && ${data}`;
26773
- }
27223
+ if (it.items !== true && schemaCxt.items !== void 0) {
27224
+ it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
26774
27225
  }
26775
- return expr;
26776
- function errorMsg(pointerType, up) {
26777
- return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
27226
+ }
27227
+ mergeValidEvaluated(schemaCxt, valid) {
27228
+ const { it, gen } = this;
27229
+ if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
27230
+ gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
27231
+ return true;
26778
27232
  }
26779
27233
  }
26780
- validate.getData = getData;
26781
- return validate;
26782
27234
  }
26783
- var validation_error = {};
26784
- var hasRequiredValidation_error;
26785
- function requireValidation_error() {
26786
- if (hasRequiredValidation_error) return validation_error;
26787
- hasRequiredValidation_error = 1;
26788
- Object.defineProperty(validation_error, "__esModule", { value: true });
26789
- class ValidationError extends Error {
26790
- constructor(errors2) {
26791
- super("validation failed");
26792
- this.errors = errors2;
26793
- this.ajv = this.validation = true;
27235
+ validate.KeywordCxt = KeywordCxt;
27236
+ function keywordCode(it, keyword2, def2, ruleType) {
27237
+ const cxt = new KeywordCxt(it, def2, keyword2);
27238
+ if ("code" in def2) {
27239
+ def2.code(cxt, ruleType);
27240
+ } else if (cxt.$data && def2.validate) {
27241
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
27242
+ } else if ("macro" in def2) {
27243
+ (0, keyword_1.macroKeywordCode)(cxt, def2);
27244
+ } else if (def2.compile || def2.validate) {
27245
+ (0, keyword_1.funcKeywordCode)(cxt, def2);
27246
+ }
27247
+ }
27248
+ const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
27249
+ const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
27250
+ function getData($data, { dataLevel, dataNames, dataPathArr }) {
27251
+ let jsonPointer;
27252
+ let data;
27253
+ if ($data === "")
27254
+ return names_1$3.default.rootData;
27255
+ if ($data[0] === "/") {
27256
+ if (!JSON_POINTER.test($data))
27257
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
27258
+ jsonPointer = $data;
27259
+ data = names_1$3.default.rootData;
27260
+ } else {
27261
+ const matches = RELATIVE_JSON_POINTER.exec($data);
27262
+ if (!matches)
27263
+ throw new Error(`Invalid JSON-pointer: ${$data}`);
27264
+ const up = +matches[1];
27265
+ jsonPointer = matches[2];
27266
+ if (jsonPointer === "#") {
27267
+ if (up >= dataLevel)
27268
+ throw new Error(errorMsg("property/index", up));
27269
+ return dataPathArr[dataLevel - up];
27270
+ }
27271
+ if (up > dataLevel)
27272
+ throw new Error(errorMsg("data", up));
27273
+ data = dataNames[dataLevel - up];
27274
+ if (!jsonPointer)
27275
+ return data;
27276
+ }
27277
+ let expr = data;
27278
+ const segments = jsonPointer.split("/");
27279
+ for (const segment of segments) {
27280
+ if (segment) {
27281
+ data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
27282
+ expr = (0, codegen_1$n._)`${expr} && ${data}`;
26794
27283
  }
26795
27284
  }
26796
- validation_error.default = ValidationError;
26797
- return validation_error;
27285
+ return expr;
27286
+ function errorMsg(pointerType, up) {
27287
+ return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
27288
+ }
27289
+ }
27290
+ validate.getData = getData;
27291
+ var validation_error = {};
27292
+ Object.defineProperty(validation_error, "__esModule", { value: true });
27293
+ class ValidationError extends Error {
27294
+ constructor(errors2) {
27295
+ super("validation failed");
27296
+ this.errors = errors2;
27297
+ this.ajv = this.validation = true;
27298
+ }
26798
27299
  }
27300
+ validation_error.default = ValidationError;
26799
27301
  var ref_error = {};
26800
27302
  Object.defineProperty(ref_error, "__esModule", { value: true });
26801
27303
  const resolve_1$1 = resolve$2;
@@ -26811,11 +27313,11 @@ var compile = {};
26811
27313
  Object.defineProperty(compile, "__esModule", { value: true });
26812
27314
  compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
26813
27315
  const codegen_1$m = codegen;
26814
- const validation_error_1 = requireValidation_error();
27316
+ const validation_error_1 = validation_error;
26815
27317
  const names_1$2 = names$1;
26816
27318
  const resolve_1 = resolve$2;
26817
27319
  const util_1$l = util;
26818
- const validate_1$1 = requireValidate();
27320
+ const validate_1$1 = validate;
26819
27321
  class SchemaEnv {
26820
27322
  constructor(env) {
26821
27323
  var _a;
@@ -28100,7 +28602,7 @@ uri$1.default = uri;
28100
28602
  (function(exports) {
28101
28603
  Object.defineProperty(exports, "__esModule", { value: true });
28102
28604
  exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
28103
- var validate_12 = requireValidate();
28605
+ var validate_12 = validate;
28104
28606
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
28105
28607
  return validate_12.KeywordCxt;
28106
28608
  } });
@@ -28123,7 +28625,7 @@ uri$1.default = uri;
28123
28625
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
28124
28626
  return codegen_12.CodeGen;
28125
28627
  } });
28126
- const validation_error_12 = requireValidation_error();
28628
+ const validation_error_12 = validation_error;
28127
28629
  const ref_error_12 = ref_error;
28128
28630
  const rules_12 = rules;
28129
28631
  const compile_12 = compile;
@@ -29711,7 +30213,7 @@ const def$a = {
29711
30213
  additionalProperties.default = def$a;
29712
30214
  var properties$1 = {};
29713
30215
  Object.defineProperty(properties$1, "__esModule", { value: true });
29714
- const validate_1 = requireValidate();
30216
+ const validate_1 = validate;
29715
30217
  const code_1$2 = code;
29716
30218
  const util_1$7 = util;
29717
30219
  const additionalProperties_1$1 = additionalProperties;
@@ -30562,7 +31064,7 @@ const require$$3 = {
30562
31064
  module2.exports.Ajv = Ajv2;
30563
31065
  Object.defineProperty(exports, "__esModule", { value: true });
30564
31066
  exports.default = Ajv2;
30565
- var validate_12 = requireValidate();
31067
+ var validate_12 = validate;
30566
31068
  Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
30567
31069
  return validate_12.KeywordCxt;
30568
31070
  } });
@@ -30585,7 +31087,7 @@ const require$$3 = {
30585
31087
  Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
30586
31088
  return codegen_12.CodeGen;
30587
31089
  } });
30588
- var validation_error_12 = requireValidation_error();
31090
+ var validation_error_12 = validation_error;
30589
31091
  Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
30590
31092
  return validation_error_12.default;
30591
31093
  } });