monorise 1.15.0-dev.0 → 1.15.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.
@@ -17,18 +17,6 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
20
 
33
21
  // types/monorise.type.ts
34
22
  var Entity = /* @__PURE__ */ ((Entity2) => {
@@ -37,6 +25,144 @@ var Entity = /* @__PURE__ */ ((Entity2) => {
37
25
 
38
26
  // utils/index.ts
39
27
  import { z } from "zod";
28
+
29
+ // utils/search.ts
30
+ var DEFAULT_MAX_WORDS = 8;
31
+ var DEFAULT_IGNORE_WORDS = [
32
+ "the",
33
+ "and",
34
+ "of",
35
+ "in",
36
+ "to",
37
+ "for",
38
+ "with",
39
+ "on",
40
+ "at",
41
+ "by",
42
+ "from",
43
+ "or",
44
+ "is",
45
+ "are",
46
+ "was",
47
+ "be",
48
+ "as",
49
+ "it",
50
+ "this",
51
+ "that"
52
+ ];
53
+ var MIN_WORD_LENGTH = 2;
54
+ var NON_WORD = /[^\p{L}\p{N}]+/u;
55
+ var MARKS = new RegExp("\\p{M}", "gu");
56
+ function foldText(text) {
57
+ return text.normalize("NFKD").replace(MARKS, "").toLowerCase();
58
+ }
59
+ function splitWords(text) {
60
+ return foldText(text).split(NON_WORD).filter(Boolean);
61
+ }
62
+ var collapseSpaces = (text) => text.trim().replace(/\s+/g, " ");
63
+ function resolveSearchConfig(search, defaults) {
64
+ var _a, _b, _c, _d;
65
+ const ignoreWords = (_b = (_a = search.ignoreWords) != null ? _a : defaults == null ? void 0 : defaults.ignoreWords) != null ? _b : DEFAULT_IGNORE_WORDS;
66
+ return {
67
+ fields: search.fields.map(({ field, match }) => ({
68
+ field: String(field),
69
+ match: match != null ? match : "words"
70
+ })),
71
+ maxWords: (_d = (_c = search.maxWords) != null ? _c : defaults == null ? void 0 : defaults.maxWords) != null ? _d : DEFAULT_MAX_WORDS,
72
+ ignoreWords: [...new Set(ignoreWords.map(foldText))].sort()
73
+ };
74
+ }
75
+ function validateSearchSettings(settings, where) {
76
+ const { maxWords, ignoreWords } = settings;
77
+ if (maxWords !== void 0 && (!Number.isInteger(maxWords) || maxWords < 1)) {
78
+ throw new Error(`${where}: 'search.maxWords' must be a positive integer.`);
79
+ }
80
+ if (ignoreWords !== void 0 && (!Array.isArray(ignoreWords) || ignoreWords.some((word) => typeof word !== "string"))) {
81
+ throw new Error(
82
+ `${where}: 'search.ignoreWords' must be an array of strings.`
83
+ );
84
+ }
85
+ }
86
+ function searchConfigHash(config) {
87
+ const input = JSON.stringify(config);
88
+ let h1 = 3735928559;
89
+ let h2 = 1103547991;
90
+ for (let i = 0; i < input.length; i++) {
91
+ const char = input.charCodeAt(i);
92
+ h1 = Math.imul(h1 ^ char, 2654435761);
93
+ h2 = Math.imul(h2 ^ char, 1597334677);
94
+ }
95
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507);
96
+ h1 ^= Math.imul(h2 ^ h2 >>> 13, 3266489909);
97
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507);
98
+ h2 ^= Math.imul(h1 ^ h1 >>> 13, 3266489909);
99
+ return (4294967296 * (2097151 & h2) + (h1 >>> 0)).toString(16);
100
+ }
101
+ function fieldValues(data, field) {
102
+ const value = data == null ? void 0 : data[field];
103
+ const values = Array.isArray(value) ? value : [value];
104
+ return values.filter((v) => typeof v === "string" || typeof v === "number").map(String);
105
+ }
106
+ function indexedWords(data, config) {
107
+ const ignore = new Set(config.ignoreWords);
108
+ const words = /* @__PURE__ */ new Set();
109
+ for (const { field } of config.fields) {
110
+ for (const value of fieldValues(data, field)) {
111
+ for (const word of splitWords(value)) {
112
+ if (word.length < MIN_WORD_LENGTH || ignore.has(word)) continue;
113
+ words.add(word);
114
+ if (words.size === config.maxWords) return [...words];
115
+ }
116
+ }
117
+ }
118
+ return [...words];
119
+ }
120
+ function planSearch(query, ignoreWords) {
121
+ var _a;
122
+ const ignore = new Set(ignoreWords);
123
+ const parsed = [];
124
+ const termPattern = /"([^"]+)"|(\S+)/g;
125
+ for (let match = termPattern.exec(query); match; match = termPattern.exec(query)) {
126
+ parsed.push({ text: (_a = match[1]) != null ? _a : match[2], quoted: match[1] !== void 0 });
127
+ }
128
+ const terms = [];
129
+ let trailing;
130
+ parsed.forEach(({ text, quoted }, i) => {
131
+ var _a2, _b;
132
+ const parts = splitWords(text);
133
+ const words = parts.filter(
134
+ (word) => word.length >= MIN_WORD_LENGTH && !ignore.has(word)
135
+ );
136
+ if (quoted || parts.length > 1) {
137
+ terms.push({ words, phrase: collapseSpaces(foldText(text)) });
138
+ } else if (words.length) {
139
+ terms.push({ words });
140
+ } else if (i === parsed.length - 1 && ((_b = (_a2 = parts[0]) == null ? void 0 : _a2.length) != null ? _b : 0) >= MIN_WORD_LENGTH) {
141
+ trailing = parts[0];
142
+ }
143
+ });
144
+ const required = terms.flatMap((term) => term.words);
145
+ if (!required.length && trailing) {
146
+ return { anchor: trailing, terms: [...terms, { words: [trailing] }] };
147
+ }
148
+ const anchor = required.reduce(
149
+ (longest, word) => !longest || word.length > longest.length ? word : longest,
150
+ void 0
151
+ );
152
+ return { anchor, terms };
153
+ }
154
+ function matchesSearch(data, plan, config) {
155
+ if (!plan.anchor) return false;
156
+ const words = indexedWords(data, config);
157
+ const values = config.fields.flatMap(
158
+ ({ field }) => fieldValues(data, field).map((value) => collapseSpaces(foldText(value)))
159
+ );
160
+ return plan.terms.every(
161
+ ({ words: termWords, phrase }) => termWords.every((word) => words.some((w) => w.startsWith(word))) && (!phrase || values.some((value) => value.includes(phrase)))
162
+ );
163
+ }
164
+
165
+ // utils/index.ts
40
166
  function resolveEffectiveMutualSchema(mutualSchema, createMutualSchema) {
41
167
  if (!createMutualSchema) return mutualSchema;
42
168
  if (!mutualSchema) return createMutualSchema;
@@ -51,6 +177,25 @@ function makeSchema(config, effectiveMutualSchema) {
51
177
  return finalSchema;
52
178
  }
53
179
  var createEntityConfig = (config) => {
180
+ var _a;
181
+ if (config.search) {
182
+ if (config.searchableFields) {
183
+ throw new Error(
184
+ `${config.name}: 'search' and 'searchableFields' can't both be set. 'searchableFields' scans every entity on each search; 'search' looks matches up by word. Keep one.`
185
+ );
186
+ }
187
+ if (!((_a = config.search.fields) == null ? void 0 : _a.length)) {
188
+ throw new Error(`${config.name}: 'search.fields' needs at least one field.`);
189
+ }
190
+ for (const { field, match } of config.search.fields) {
191
+ if (match !== void 0 && match !== "words") {
192
+ throw new Error(
193
+ `${config.name}: 'search.fields' entry '${String(field)}' has an unknown match '${match}'. Supported: 'words'.`
194
+ );
195
+ }
196
+ }
197
+ validateSearchSettings(config.search, String(config.name));
198
+ }
54
199
  const { mutualSchema, createMutualSchema } = config.mutual || {};
55
200
  const effectiveMutualSchema = resolveEffectiveMutualSchema(
56
201
  mutualSchema,
@@ -89,378 +234,20 @@ var createMutualConfig = (config) => {
89
234
  mutualDataSchema: config.asEntity.finalSchema
90
235
  });
91
236
  };
92
-
93
- // utils/api-key-policy.ts
94
- var FULL_API_KEY_POLICY = "full";
95
- var ACCESS_LEVELS = ["none", "read", "write"];
96
- var SYSTEM_FIELDS = ["$entityId", "$createdAt"];
97
- var ENTITY_GRANT_KEYS = [
98
- "read",
99
- "list",
100
- "create",
101
- "update",
102
- "write",
103
- "delete",
104
- "tags",
105
- "mutuals"
106
- ];
107
- var MUTUAL_GRANT_KEYS = ["read", "create", "update", "write", "delete"];
108
- var POLICY_KEYS = ["entities", "routes"];
109
- var hasOwn = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
110
- var toAccess = (list) => list === void 0 ? null : list === "*" ? "*" : new Set(list);
111
- var union = (...accesses) => {
112
- let fields = null;
113
- for (const access of accesses) {
114
- if (access === null) continue;
115
- if (access === "*") return "*";
116
- fields = /* @__PURE__ */ new Set([...fields != null ? fields : [], ...access]);
117
- }
118
- return fields;
119
- };
120
- var withoutSystemFields = (access) => access === null || access === "*" ? access : new Set([...access].filter((field) => !SYSTEM_FIELDS.includes(field)));
121
- var HIDDEN = {
122
- access: {
123
- visible: false,
124
- read: null,
125
- list: false,
126
- create: null,
127
- update: null,
128
- delete: false,
129
- tags: null
130
- },
131
- mutualDefault: "none",
132
- mutuals: /* @__PURE__ */ new Map()
133
- };
134
- var compileEntityGrant = (grant) => {
135
- var _a;
136
- if (grant === void 0 || grant === "none") return HIDDEN;
137
- if (grant === "read" || grant === "write") {
138
- const write = grant === "write";
139
- return {
140
- access: {
141
- visible: true,
142
- read: "*",
143
- list: true,
144
- create: write ? "*" : null,
145
- update: write ? "*" : null,
146
- delete: write,
147
- tags: "*"
148
- },
149
- mutualDefault: grant,
150
- mutuals: /* @__PURE__ */ new Map()
151
- };
152
- }
153
- const create = union(toAccess(grant.create), toAccess(grant.write));
154
- const update = union(toAccess(grant.update), toAccess(grant.write));
155
- const read = union(toAccess(grant.read), withoutSystemFields(create), update);
156
- const _b = (_a = grant.mutuals) != null ? _a : {}, { "*": mutualDefault = "none" } = _b, mutuals = __objRest(_b, ["*"]);
157
- return {
158
- access: {
159
- visible: true,
160
- read,
161
- list: grant.list === true,
162
- create,
163
- update,
164
- delete: grant.delete === true,
165
- tags: grant.tags !== void 0 ? toAccess(grant.tags) : read === "*" ? "*" : null
166
- },
167
- mutualDefault,
168
- mutuals: new Map(Object.entries(mutuals))
169
- };
170
- };
171
- var compileMutualGrant = (grant) => {
172
- if (grant === "none" || grant === "read" || grant === "write") {
173
- const write = grant === "write";
174
- return {
175
- read: grant === "none" ? null : "*",
176
- create: write ? "*" : null,
177
- update: write ? "*" : null,
178
- delete: write
179
- };
180
- }
181
- const create = union(toAccess(grant.create), toAccess(grant.write));
182
- const update = union(toAccess(grant.update), toAccess(grant.write));
183
- return {
184
- read: union(toAccess(grant.read), create, update),
185
- create,
186
- update,
187
- delete: grant.delete === true
188
- };
189
- };
190
- var compileApiKeyPolicy = (name, policy) => {
191
- var _a, _b;
192
- const full = name === FULL_API_KEY_POLICY;
193
- const entities = full ? { "*": "write" } : policy === "read" || policy === "write" ? { "*": policy } : (_a = policy == null ? void 0 : policy.entities) != null ? _a : {};
194
- const routes = new Set(
195
- !full && typeof policy === "object" ? (_b = policy.routes) != null ? _b : [] : []
196
- );
197
- const cache = /* @__PURE__ */ new Map();
198
- const compiled = (entityType) => {
199
- const grantKey = hasOwn(entities, entityType) ? entityType : "*";
200
- let entry = cache.get(grantKey);
201
- if (!entry) {
202
- entry = compileEntityGrant(
203
- hasOwn(entities, grantKey) ? entities[grantKey] : void 0
204
- );
205
- cache.set(grantKey, entry);
206
- }
207
- return entry;
208
- };
209
- return {
210
- name,
211
- full,
212
- entity: (entityType) => compiled(entityType).access,
213
- mutual: (byEntityType, entityType) => {
214
- var _a2;
215
- const from = compiled(byEntityType);
216
- if (!from.access.visible || !compiled(entityType).access.visible) {
217
- return null;
218
- }
219
- return compileMutualGrant(
220
- (_a2 = from.mutuals.get(entityType)) != null ? _a2 : from.mutualDefault
221
- );
222
- },
223
- allowsRoute: (permission) => full || routes.has(permission)
224
- };
225
- };
226
- var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
227
- var quoteList = (items) => [...items].map((item) => `'${item}'`).join(", ");
228
- var validateApiKeyPolicies = (policies, entityConfigs) => {
229
- var _a, _b, _c, _d;
230
- const errors = [];
231
- if (!isPlainObject(policies)) {
232
- return ["API key policies must be an object keyed by policy name"];
233
- }
234
- const entityNames = Object.keys(entityConfigs);
235
- const isEntityType = (name) => hasOwn(entityConfigs, name);
236
- const mutualFieldNames = (config) => {
237
- var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
238
- return /* @__PURE__ */ new Set([
239
- ...Object.keys((_b2 = (_a2 = config.mutual) == null ? void 0 : _a2.mutualFields) != null ? _b2 : {}),
240
- ...Object.keys((_e = (_d2 = (_c2 = config.mutual) == null ? void 0 : _c2.mutualSchema) == null ? void 0 : _d2.shape) != null ? _e : {}),
241
- ...Object.keys((_h = (_g = (_f = config.mutual) == null ? void 0 : _f.createMutualSchema) == null ? void 0 : _g.shape) != null ? _h : {})
242
- ]);
243
- };
244
- const ownFields = (config) => {
245
- var _a2, _b2, _c2, _d2;
246
- return /* @__PURE__ */ new Set([
247
- ...Object.keys((_b2 = (_a2 = config.baseSchema) == null ? void 0 : _a2.shape) != null ? _b2 : {}),
248
- ...Object.keys((_d2 = (_c2 = config.createSchema) == null ? void 0 : _c2.shape) != null ? _d2 : {})
249
- ]);
250
- };
251
- const mutualConfig = (byEntityType, entityType) => {
252
- var _a2;
253
- const declared = (from, to) => {
254
- var _a3, _b2, _c2, _d2;
255
- return (_d2 = Object.values((_c2 = (_b2 = (_a3 = entityConfigs[from]) == null ? void 0 : _a3.mutual) == null ? void 0 : _b2.mutualFields) != null ? _c2 : {}).find(
256
- (field) => field.entityType === to && field.mutual
257
- )) == null ? void 0 : _d2.mutual;
258
- };
259
- return (_a2 = declared(byEntityType, entityType)) != null ? _a2 : declared(entityType, byEntityType);
260
- };
261
- const checkFieldList = (where, list, allowed, describe) => {
262
- if (list === "*") return;
263
- if (!Array.isArray(list) || !list.every((field) => typeof field === "string")) {
264
- errors.push(`${where} must be '*' or an array of field names`);
265
- return;
266
- }
267
- for (const field of list) {
268
- const problem = describe(field);
269
- if (problem) errors.push(`${where}: ${problem}`);
270
- else if (allowed && !allowed.has(field)) {
271
- errors.push(`${where}: unknown field '${field}'`);
272
- }
273
- }
274
- };
275
- const checkUnknownKeys = (where, value, known) => {
276
- for (const key of Object.keys(value)) {
277
- if (!known.includes(key)) {
278
- errors.push(
279
- `${where}: unknown key '${key}' (expected ${quoteList(known)})`
280
- );
281
- }
282
- }
283
- };
284
- const checkLevel = (where, value) => {
285
- if (!ACCESS_LEVELS.includes(value)) {
286
- errors.push(`${where} must be one of ${quoteList(ACCESS_LEVELS)}`);
287
- }
288
- };
289
- const checkMutualGrant = (where, grant, byEntityType, entityType) => {
290
- var _a2, _b2;
291
- if (typeof grant === "string") return checkLevel(where, grant);
292
- if (!isPlainObject(grant)) {
293
- errors.push(`${where} must be an access level or an object`);
294
- return;
295
- }
296
- checkUnknownKeys(where, grant, MUTUAL_GRANT_KEYS);
297
- const dataFields = (_b2 = (_a2 = mutualConfig(byEntityType, entityType)) == null ? void 0 : _a2.mutualDataSchema) == null ? void 0 : _b2.shape;
298
- const allowed = dataFields ? new Set(Object.keys(dataFields)) : void 0;
299
- for (const key of ["read", "create", "update", "write"]) {
300
- if (grant[key] === void 0) continue;
301
- checkFieldList(`${where}.${key}`, grant[key], allowed, () => void 0);
302
- }
303
- if (grant.delete !== void 0 && typeof grant.delete !== "boolean") {
304
- errors.push(`${where}.delete must be a boolean`);
305
- }
306
- };
307
- const checkEntityGrant = (where, grant, entityType) => {
308
- var _a2;
309
- const config = entityConfigs[entityType];
310
- if (typeof grant === "string") return checkLevel(where, grant);
311
- if (!isPlainObject(grant)) {
312
- errors.push(`${where} must be an access level or an object`);
313
- return;
314
- }
315
- checkUnknownKeys(where, grant, ENTITY_GRANT_KEYS);
316
- const fields = ownFields(config);
317
- const mutualFields = mutualFieldNames(config);
318
- const fieldListErrors = errors.length;
319
- for (const key of ["read", "create", "update", "write"]) {
320
- if (grant[key] === void 0) continue;
321
- const allowsSystemFields = key === "create" || key === "write";
322
- const allowed = allowsSystemFields ? /* @__PURE__ */ new Set([...fields, ...SYSTEM_FIELDS]) : fields;
323
- checkFieldList(`${where}.${key}`, grant[key], allowed, (field) => {
324
- if (SYSTEM_FIELDS.includes(field)) {
325
- return allowsSystemFields ? void 0 : `'${field}' can only be granted in 'create' or 'write'`;
326
- }
327
- if (mutualFields.has(field) && !fields.has(field)) {
328
- return `'${field}' is a relationship field; grant it under 'mutuals' instead`;
329
- }
330
- return void 0;
331
- });
332
- }
333
- if (grant.delete !== void 0 && typeof grant.delete !== "boolean") {
334
- errors.push(`${where}.delete must be a boolean`);
335
- }
336
- if (grant.list !== void 0 && typeof grant.list !== "boolean") {
337
- errors.push(`${where}.list must be a boolean`);
338
- } else if (grant.list === true && errors.length === fieldListErrors) {
339
- const { read } = compileEntityGrant(grant).access;
340
- if (read === null || read !== "*" && read.size === 0) {
341
- errors.push(
342
- `${where}.list needs fields to read; a listing would return no data`
343
- );
344
- }
345
- }
346
- if (grant.tags !== void 0) {
347
- checkFieldList(
348
- `${where}.tags`,
349
- grant.tags,
350
- new Set(((_a2 = config.tags) != null ? _a2 : []).map((tag) => tag.name)),
351
- () => void 0
352
- );
353
- }
354
- if (grant.mutuals !== void 0) {
355
- if (!isPlainObject(grant.mutuals)) {
356
- errors.push(`${where}.mutuals must be an object`);
357
- return;
358
- }
359
- for (const [target, mutualGrant] of Object.entries(grant.mutuals)) {
360
- const mutualWhere = `${where}.mutuals.${target}`;
361
- if (target === "*") {
362
- checkLevel(mutualWhere, mutualGrant);
363
- } else if (!isEntityType(target)) {
364
- errors.push(`${mutualWhere}: unknown entity type '${target}'`);
365
- } else {
366
- checkMutualGrant(mutualWhere, mutualGrant, entityType, target);
367
- }
368
- }
369
- }
370
- };
371
- const checkCreateIsSatisfiable = (where, policy, entityType) => {
372
- var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
373
- const config = entityConfigs[entityType];
374
- const { create } = policy.entity(entityType);
375
- if (create === null) return;
376
- if (create !== "*") {
377
- const shape = __spreadValues(__spreadValues({}, (_a2 = config.baseSchema) == null ? void 0 : _a2.shape), (_b2 = config.createSchema) == null ? void 0 : _b2.shape);
378
- const missing = Object.entries(shape).filter(([field, schema]) => !schema.isOptional() && !create.has(field)).map(([field]) => field);
379
- if (missing.length) {
380
- errors.push(
381
- `${where}: create omits required field(s) ${quoteList(missing)}, so a key with this policy could never create one`
382
- );
383
- }
384
- }
385
- const requiredMutuals = (_e = (_d2 = (_c2 = config.mutual) == null ? void 0 : _c2.createMutualSchema) == null ? void 0 : _d2.shape) != null ? _e : {};
386
- for (const [field, schema] of Object.entries(
387
- requiredMutuals
388
- )) {
389
- const target = (_h = (_g = (_f = config.mutual) == null ? void 0 : _f.mutualFields) == null ? void 0 : _g[field]) == null ? void 0 : _h.entityType;
390
- if (schema.isOptional() || !target) continue;
391
- if (!((_i = policy.mutual(entityType, target)) == null ? void 0 : _i.create)) {
392
- errors.push(
393
- `${where}: create needs create on ${entityType}\u2192${target}, because createMutualSchema requires '${field}'`
394
- );
395
- }
396
- }
397
- };
398
- for (const [name, policy] of Object.entries(policies)) {
399
- const where = `policy '${name}'`;
400
- const errorsBefore = errors.length;
401
- if (name === FULL_API_KEY_POLICY) {
402
- errors.push(`${where} is built in and cannot be redefined`);
403
- continue;
404
- }
405
- if (policy === "read" || policy === "write") continue;
406
- if (!isPlainObject(policy)) {
407
- errors.push(`${where} must be 'read', 'write' or an object`);
408
- continue;
409
- }
410
- checkUnknownKeys(where, policy, POLICY_KEYS);
411
- if (policy.routes !== void 0 && (!Array.isArray(policy.routes) || !policy.routes.every(
412
- (permission) => typeof permission === "string" && permission.length
413
- ))) {
414
- errors.push(`${where}.routes must be an array of permission names`);
415
- }
416
- const entities = (_a = policy.entities) != null ? _a : {};
417
- if (!isPlainObject(entities)) {
418
- errors.push(`${where}.entities must be an object`);
419
- continue;
420
- }
421
- for (const [entityType, grant] of Object.entries(entities)) {
422
- const entityWhere = `${where}.entities.${entityType}`;
423
- if (entityType === "*") {
424
- checkLevel(entityWhere, grant);
425
- } else if (!isEntityType(entityType)) {
426
- errors.push(`${entityWhere}: unknown entity type '${entityType}'`);
427
- } else {
428
- checkEntityGrant(entityWhere, grant, entityType);
429
- }
430
- }
431
- if (errors.length > errorsBefore) continue;
432
- const compiled = compileApiKeyPolicy(name, policy);
433
- for (const entityType of entityNames) {
434
- const entityWhere = `${where}.entities.${entityType}`;
435
- checkCreateIsSatisfiable(entityWhere, compiled, entityType);
436
- for (const target of entityNames) {
437
- const asEntity = (_c = (_b = mutualConfig(entityType, target)) == null ? void 0 : _b.asEntity) == null ? void 0 : _c.name;
438
- if (asEntity && ((_d = compiled.mutual(entityType, target)) == null ? void 0 : _d.create) && !compiled.entity(asEntity).create) {
439
- errors.push(
440
- `${entityWhere}: create on ${entityType}\u2192${target} also creates a '${asEntity}' entity, so it needs create on '${asEntity}'`
441
- );
442
- }
443
- }
444
- }
445
- }
446
- return errors;
447
- };
448
- var VALIDATE_API_KEY_POLICIES = /* @__PURE__ */ Symbol.for("monorise.validateApiKeyPolicies");
449
- var defineApiKeyPolicies = (policies) => {
450
- Object.defineProperty(policies, VALIDATE_API_KEY_POLICIES, {
451
- value: (entityConfigs) => validateApiKeyPolicies(policies, entityConfigs),
452
- enumerable: false
453
- });
454
- return policies;
455
- };
456
237
  export {
238
+ DEFAULT_IGNORE_WORDS,
239
+ DEFAULT_MAX_WORDS,
457
240
  Entity,
458
- FULL_API_KEY_POLICY,
459
- compileApiKeyPolicy,
460
241
  createEntityConfig,
461
242
  createMutualConfig,
462
- defineApiKeyPolicies,
243
+ foldText,
244
+ indexedWords,
245
+ matchesSearch,
246
+ planSearch,
463
247
  resolveEffectiveMutualSchema,
464
- validateApiKeyPolicies
248
+ resolveSearchConfig,
249
+ searchConfigHash,
250
+ splitWords,
251
+ validateSearchSettings
465
252
  };
466
253
  //# sourceMappingURL=index.js.map