@esposter/shared 2.35.0 → 2.36.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/index.js CHANGED
@@ -33,7 +33,7 @@ var __copyProps$1 = (to, from, except, desc) => {
33
33
  }
34
34
  return to;
35
35
  };
36
- var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
36
+ var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp$1.call(mod, "default") ? __defProp$1(target, "default", {
37
37
  value: mod,
38
38
  enumerable: true
39
39
  }) : target, mod));
@@ -109,6 +109,12 @@ var NotInitializedError = class extends Error {
109
109
  this.name = "NotInitializedError";
110
110
  }
111
111
  };
112
+ var WordFilteredError = class extends Error {
113
+ constructor(message) {
114
+ super(message);
115
+ this.name = "WordFilteredError";
116
+ }
117
+ };
112
118
  let MentionType = /* @__PURE__ */ function(MentionType) {
113
119
  MentionType["Role"] = "role";
114
120
  MentionType["User"] = "user";
@@ -140,10 +146,13 @@ const RoutePath = {
140
146
  PostUpdate: (id) => `/post/update/${id}`,
141
147
  PrivacyPolicy: "/privacy-policy",
142
148
  Resource: (id) => `/resources/${id}`,
149
+ ResourceItems: (id) => `/resources/${id}/items`,
143
150
  Resources: "/resources",
144
151
  ResourcesAll: "/resources/all",
145
152
  ResourcesCreate: "/resources/create",
146
153
  ResourcesCreateType: (type) => `/resources/create/${type}`,
154
+ ResourcesRecycleBin: "/resources/recycle-bin",
155
+ User: (id) => `/user/${id}`,
147
156
  UserSettings: "/user/settings",
148
157
  View: (type, id) => `/view/${type}/${id}`
149
158
  };
@@ -6762,9 +6771,7 @@ var init_Tokenizer = __esmMin((() => {
6762
6771
  case State.InProcessingInstruction:
6763
6772
  this.stateInProcessingInstruction(c);
6764
6773
  break;
6765
- case State.InEntity:
6766
- this.stateInEntity();
6767
- break;
6774
+ case State.InEntity: this.stateInEntity();
6768
6775
  }
6769
6776
  this.index++;
6770
6777
  }
@@ -7833,7 +7840,8 @@ var init_dist$4 = __esmMin((() => {
7833
7840
  if (this.elementCB) this.elementCB(element);
7834
7841
  }
7835
7842
  onopentag(name, attribs) {
7836
- const element = new Element(name, attribs, void 0, this.options.xmlMode ? ElementType.Tag : void 0);
7843
+ const type = this.options.xmlMode ? ElementType.Tag : void 0;
7844
+ const element = new Element(name, attribs, void 0, type);
7837
7845
  this.addNode(element);
7838
7846
  this.tagStack.push(element);
7839
7847
  }
@@ -9314,7 +9322,7 @@ var require_css_syntax_error = /* @__PURE__ */ __commonJSMin$1(((exports, module
9314
9322
  let subLineStart = Math.max(0, this.column - padding);
9315
9323
  let subLineEnd = Math.max(this.column + padding, this.endColumn + padding);
9316
9324
  let subLine = line.slice(subLineStart, subLineEnd);
9317
- let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " ");
9325
+ let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, 19)).replace(/[^\t]/g, " ");
9318
9326
  return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing + mark("^");
9319
9327
  }
9320
9328
  let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " ");
@@ -9335,6 +9343,7 @@ var require_css_syntax_error = /* @__PURE__ */ __commonJSMin$1(((exports, module
9335
9343
  var require_stringifier = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
9336
9344
  const STYLE_TAG = /(<)(\/?style\b)/gi;
9337
9345
  const COMMENT_OPEN = /(<)(!--)/g;
9346
+ const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/;
9338
9347
  function escapeHTMLInCSS(str) {
9339
9348
  if (typeof str !== "string") return str;
9340
9349
  if (!str.includes("<")) return str;
@@ -9360,9 +9369,10 @@ var require_stringifier = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
9360
9369
  function atruleStart(str, node) {
9361
9370
  let name = "@" + node.name;
9362
9371
  let params = node.params ? str.rawValue(node, "params") : "";
9363
- if (typeof node.raws.afterName !== "undefined") name += node.raws.afterName;
9364
- else if (params) name += " ";
9365
- return name + params;
9372
+ let afterName = node.raws.afterName;
9373
+ if (typeof afterName === "undefined") afterName = params ? " " : "";
9374
+ else if (afterName === "" && params && !AT_NAME_END.test(params[0])) afterName = " ";
9375
+ return name + afterName + params;
9366
9376
  }
9367
9377
  function pushBody(str, stack, node) {
9368
9378
  let nodes = node.nodes;
@@ -9373,11 +9383,16 @@ var require_stringifier = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
9373
9383
  }
9374
9384
  let semicolon = str.raw(node, "semicolon");
9375
9385
  let isDocument = node.type === "document";
9376
- for (let i = nodes.length - 1; i >= 0; i--) stack.push({
9377
- document: isDocument,
9378
- node: nodes[i],
9379
- semicolon: last !== i || semicolon
9380
- });
9386
+ for (let i = nodes.length - 1; i >= 0; i--) {
9387
+ let child = nodes[i];
9388
+ let childSemicolon = last !== i || semicolon;
9389
+ if (!childSemicolon && i < nodes.length - 1 && (child.type === "atrule" && !child.nodes || child.type === "decl" && child.prop.startsWith("--"))) childSemicolon = true;
9390
+ stack.push({
9391
+ document: isDocument,
9392
+ node: child,
9393
+ semicolon: childSemicolon
9394
+ });
9395
+ }
9381
9396
  }
9382
9397
  function pushBlock(str, stack, node, start) {
9383
9398
  let between = str.raw(node, "between", "beforeOpen");
@@ -9622,6 +9637,7 @@ var require_stringifier = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
9622
9637
  return value;
9623
9638
  }
9624
9639
  root(node) {
9640
+ if (node.source && node.source.input.hasBOM) this.builder("", node, "start");
9625
9641
  this.body(node);
9626
9642
  if (node.raws.after) {
9627
9643
  let after = node.raws.after;
@@ -9804,7 +9820,9 @@ var require_node = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
9804
9820
  set(node, prop, value) {
9805
9821
  if (node[prop] === value) return true;
9806
9822
  node[prop] = value;
9807
- if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || prop === "text") node.markDirty();
9823
+ if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" ||
9824
+ /* c8 ignore next */
9825
+ prop === "text") node.markDirty();
9808
9826
  return true;
9809
9827
  }
9810
9828
  };
@@ -10494,11 +10512,10 @@ var require_previous_map = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
10494
10512
  }
10495
10513
  loadFile(path, cssFile, trusted) {
10496
10514
  if (!trusted && !this.unsafeMap) {
10497
- if (!/\.map$/i.test(path)) return;
10498
- if (cssFile) {
10499
- let relativePath = relative(dirname(cssFile), path);
10500
- if (relativePath === ".." || relativePath.startsWith(".." + sep) || isAbsolute(relativePath)) return;
10501
- }
10515
+ if (!/\.map$/i.test(path)) return void 0;
10516
+ if (!cssFile) return void 0;
10517
+ let rel = relative(dirname(cssFile), path);
10518
+ if (rel === ".." || rel.startsWith(".." + sep) || isAbsolute(rel)) return;
10502
10519
  }
10503
10520
  this.root = dirname(path);
10504
10521
  if (existsSync(path)) {
@@ -10793,6 +10810,7 @@ var require_list = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
10793
10810
  ]);
10794
10811
  },
10795
10812
  split(string, separators, last) {
10813
+ if (!string) return [];
10796
10814
  let array = [];
10797
10815
  let current = "";
10798
10816
  let split = false;
@@ -11381,33 +11399,31 @@ var require_tokenize = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
11381
11399
  ];
11382
11400
  pos = next;
11383
11401
  break;
11384
- default:
11385
- if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
11386
- next = css.indexOf("*/", pos + 2) + 1;
11387
- if (next === 0) if (ignore || ignoreUnclosed) next = css.length;
11388
- else unclosed("comment");
11389
- currentToken = [
11390
- "comment",
11391
- css.slice(pos, next + 1),
11392
- pos,
11393
- next
11394
- ];
11395
- pos = next;
11396
- } else {
11397
- RE_WORD_END.lastIndex = pos + 1;
11398
- RE_WORD_END.test(css);
11399
- if (RE_WORD_END.lastIndex === 0) next = css.length - 1;
11400
- else next = RE_WORD_END.lastIndex - 2;
11401
- currentToken = [
11402
- "word",
11403
- css.slice(pos, next + 1),
11404
- pos,
11405
- next
11406
- ];
11407
- buffer.push(currentToken);
11408
- pos = next;
11409
- }
11410
- break;
11402
+ default: if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
11403
+ next = css.indexOf("*/", pos + 2) + 1;
11404
+ if (next === 0) if (ignore || ignoreUnclosed) next = css.length;
11405
+ else unclosed("comment");
11406
+ currentToken = [
11407
+ "comment",
11408
+ css.slice(pos, next + 1),
11409
+ pos,
11410
+ next
11411
+ ];
11412
+ pos = next;
11413
+ } else {
11414
+ RE_WORD_END.lastIndex = pos + 1;
11415
+ RE_WORD_END.test(css);
11416
+ if (RE_WORD_END.lastIndex === 0) next = css.length - 1;
11417
+ else next = RE_WORD_END.lastIndex - 2;
11418
+ currentToken = [
11419
+ "word",
11420
+ css.slice(pos, next + 1),
11421
+ pos,
11422
+ next
11423
+ ];
11424
+ buffer.push(currentToken);
11425
+ pos = next;
11426
+ }
11411
11427
  }
11412
11428
  pos++;
11413
11429
  return currentToken;
@@ -11782,9 +11798,7 @@ var require_parser = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
11782
11798
  case "{":
11783
11799
  this.emptyRule(token);
11784
11800
  break;
11785
- default:
11786
- this.other(token);
11787
- break;
11801
+ default: this.other(token);
11788
11802
  }
11789
11803
  }
11790
11804
  this.endFile();
@@ -11904,11 +11918,14 @@ var require_parse = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
11904
11918
  Container.registerParse(parse);
11905
11919
  }));
11906
11920
  var require_warning = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
11921
+ let Container = require_container();
11922
+ let { my } = require_symbols();
11907
11923
  var Warning = class {
11908
11924
  constructor(text, opts = {}) {
11909
11925
  this.type = "warning";
11910
11926
  this.text = text;
11911
11927
  if (opts.node && opts.node.source) {
11928
+ if (!opts.node[my]) Container.rebuild(opts.node);
11912
11929
  let range = opts.node.rangeBy(opts);
11913
11930
  this.line = range.start.line;
11914
11931
  this.column = range.start.column;
@@ -12333,14 +12350,19 @@ var require_lazy_result = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
12333
12350
  }
12334
12351
  if (visit.iterator !== 0) {
12335
12352
  let iterator = visit.iterator;
12353
+ if (visit.descending) {
12354
+ visit.descending = false;
12355
+ node.indexes[iterator] += 1;
12356
+ }
12336
12357
  let child;
12337
12358
  while (child = node.nodes[node.indexes[iterator]]) {
12338
- node.indexes[iterator] += 1;
12339
12359
  if (!child[isClean]) {
12340
12360
  child[isClean] = true;
12361
+ visit.descending = true;
12341
12362
  stack.push(toStack(child));
12342
12363
  return;
12343
12364
  }
12365
+ node.indexes[iterator] += 1;
12344
12366
  }
12345
12367
  visit.iterator = 0;
12346
12368
  delete node.indexes[iterator];
@@ -12375,12 +12397,16 @@ var require_lazy_result = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
12375
12397
  let visitNode = visit.node;
12376
12398
  if (visit.iterator !== 0) {
12377
12399
  let iterator = visit.iterator;
12400
+ if (visit.descending) {
12401
+ visit.descending = false;
12402
+ visitNode.indexes[iterator] += 1;
12403
+ }
12378
12404
  let child;
12379
12405
  let descended = false;
12380
12406
  while (child = visitNode.nodes[visitNode.indexes[iterator]]) {
12381
- visitNode.indexes[iterator] += 1;
12382
12407
  if (!child[isClean]) {
12383
12408
  child[isClean] = true;
12409
+ visit.descending = true;
12384
12410
  stack.push({
12385
12411
  eventIndex: 0,
12386
12412
  events: getEvents(child),
@@ -12390,6 +12416,7 @@ var require_lazy_result = /* @__PURE__ */ __commonJSMin$1(((exports, module) =>
12390
12416
  descended = true;
12391
12417
  break;
12392
12418
  }
12419
+ visitNode.indexes[iterator] += 1;
12393
12420
  }
12394
12421
  if (descended) continue;
12395
12422
  visit.iterator = 0;
@@ -12525,7 +12552,7 @@ var require_processor = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
12525
12552
  let Root = require_root();
12526
12553
  var Processor = class {
12527
12554
  constructor(plugins = []) {
12528
- this.version = "8.5.19";
12555
+ this.version = "8.5.25";
12529
12556
  this.plugins = this.normalize(plugins);
12530
12557
  }
12531
12558
  normalize(plugins) {
@@ -14130,11 +14157,36 @@ const applyItemMetadataMixin = (Base) => class ItemWithMetadata extends Base {
14130
14157
  deletedAt = null;
14131
14158
  updatedAt = /* @__PURE__ */ new Date();
14132
14159
  };
14160
+ const chunk = (array, size) => {
14161
+ const chunks = [];
14162
+ for (let index = 0; index < array.length; index += size) chunks.push(array.slice(index, index + size));
14163
+ return chunks;
14164
+ };
14165
+ const ARRAY_SERIALIZATION_BYTES = 1;
14166
+ const chunkBySerializedSize = (items, maxBytes, maxCount) => {
14167
+ const textEncoder = new TextEncoder();
14168
+ const chunks = [];
14169
+ let currentChunk = [];
14170
+ let currentBytes = ARRAY_SERIALIZATION_BYTES;
14171
+ for (const item of items) {
14172
+ const itemBytes = textEncoder.encode(JSON.stringify(item)).length + 1;
14173
+ if (currentChunk.length > 0 && (currentChunk.length === maxCount || currentBytes + itemBytes > maxBytes)) {
14174
+ chunks.push(currentChunk);
14175
+ currentChunk = [];
14176
+ currentBytes = ARRAY_SERIALIZATION_BYTES;
14177
+ }
14178
+ currentChunk.push(item);
14179
+ currentBytes += itemBytes;
14180
+ }
14181
+ if (currentChunk.length > 0) chunks.push(currentChunk);
14182
+ return chunks;
14183
+ };
14133
14184
  const takeOne = (values, index = 0) => {
14134
14185
  return values[index];
14135
14186
  };
14136
14187
  const getIsServer = () => typeof window === "undefined";
14137
14188
  const ID_SEPARATOR = "|";
14189
+ const UUID_LENGTH = 36;
14138
14190
  const getOrCreate = (map, key, create) => {
14139
14191
  if (map.has(key)) return map.get(key);
14140
14192
  const value = create();
@@ -14164,7 +14216,28 @@ const jsonDateParse = (text) => JSON.parse(text, (_key, value) => {
14164
14216
  return parsedValue;
14165
14217
  });
14166
14218
  const mergeObjectsStrict = (...objects) => Object.assign({}, ...objects);
14219
+ const settleAll = async (tasks, concurrencyLimit = tasks.length) => {
14220
+ if (tasks.length === 0) return [];
14221
+ const values = [];
14222
+ for (const tasksChunk of chunk(tasks, concurrencyLimit)) {
14223
+ const results = await Promise.allSettled(tasksChunk.map((task) => Promise.resolve().then(task)));
14224
+ const reasons = [];
14225
+ for (const result of results) if (result.status === "rejected") reasons.push(result.reason);
14226
+ else values.push(result.value);
14227
+ if (reasons.length === 1) throw takeOne(reasons);
14228
+ else if (reasons.length > 1) throw new AggregateError(reasons, toAppError(takeOne(reasons)).message);
14229
+ }
14230
+ return values;
14231
+ };
14167
14232
  const capitalize = (string) => `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
14233
+ const EncodedSubDelimiterMap = {
14234
+ "!": "%21",
14235
+ "'": "%27",
14236
+ "(": "%28",
14237
+ ")": "%29",
14238
+ "*": "%2A"
14239
+ };
14240
+ const encodeUrlSubDelimiters = (value) => Object.entries(EncodedSubDelimiterMap).reduce((encoded, [subDelimiter, encodedSubDelimiter]) => encoded.replaceAll(subDelimiter, encodedSubDelimiter), value);
14168
14241
  const normalizeString = (value) => value?.trim() ?? "";
14169
14242
  const createNormalizedStringSchema = (maxLength, schema = z.string()) => schema.transform(normalizeString).pipe(z.string().max(maxLength));
14170
14243
  const streamToText = async (readable) => {
@@ -14208,4 +14281,4 @@ const exhaustiveGuard = (value) => {
14208
14281
  const createUniqueArraySchema = (schema, key) => schema.array().refine((array) => new Set(key === void 0 ? array : array.map((item) => item[key])).size === array.length, "Array items must be unique");
14209
14282
  const UUIDV4_REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/iu;
14210
14283
  const uuidValidateV4 = (uuid) => UUIDV4_REGEX.test(uuid);
14211
- export { AllSpecialValues, ForbiddenError, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, MAX_READ_LIMIT, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MentionType, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, Serializable, UUIDV4_REGEX, applyItemMetadataMixin, capitalize, checkIsPlainObject, classifyMentions, createExponentialBackoff, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, exhaustiveGuard, getIsServer, getMentions, getOrCreate, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };
14284
+ export { AllSpecialValues, ForbiddenError, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, MAX_READ_LIMIT, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MentionType, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, Serializable, UUIDV4_REGEX, UUID_LENGTH, WordFilteredError, applyItemMetadataMixin, capitalize, checkIsPlainObject, chunk, chunkBySerializedSize, classifyMentions, createExponentialBackoff, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, encodeUrlSubDelimiters, exhaustiveGuard, getIsServer, getMentions, getOrCreate, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, settleAll, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esposter/shared",
3
- "version": "2.35.0",
3
+ "version": "2.36.0",
4
4
  "description": "A library that contains shared typescript code.",
5
5
  "keywords": [
6
6
  "error-handling",
@@ -43,22 +43,22 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "neverthrow": "^8.2.0",
46
- "node-html-parser": "^9.0.0",
46
+ "node-html-parser": "^9.0.1",
47
47
  "sanitize-html": "^2.17.6"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@azure/data-tables": "^13.3.2",
51
- "@esposter/configuration": "2.35.0",
52
- "@types/node": "^26.1.1",
51
+ "@esposter/configuration": "2.36.0",
52
+ "@types/node": "^26.1.2",
53
53
  "@types/sanitize-html": "^2.16.1",
54
- "ctix": "^2.8.1",
55
- "rolldown": "^1.1.5",
54
+ "ctix": "^2.8.2",
55
+ "rolldown": "^1.2.1",
56
56
  "type-fest": "^5.8.0",
57
57
  "vitest": "^4.1.10",
58
- "vue": "^3.5.39"
58
+ "vue": "^3.5.40"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "zod": "^4.4.3"
62
62
  },
63
- "gitHead": "3cd4a45d586379867ceba91c23052d755d95ff8f"
63
+ "gitHead": "786902aca40292b2883de2ad1eb876ca32f6ac75"
64
64
  }