@noy-db/hub 0.2.0-pre.5 → 0.2.0-pre.6

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.
Files changed (73) hide show
  1. package/dist/attestation/index.d.cts +1 -1
  2. package/dist/attestation/index.d.ts +1 -1
  3. package/dist/blobs/index.d.cts +2 -2
  4. package/dist/blobs/index.d.ts +2 -2
  5. package/dist/bundle/index.cjs +53 -6
  6. package/dist/bundle/index.cjs.map +1 -1
  7. package/dist/bundle/index.d.cts +3 -3
  8. package/dist/bundle/index.d.ts +3 -3
  9. package/dist/bundle/index.js +1 -1
  10. package/dist/{chunk-YZ6JETII.js → chunk-JICBEFBT.js} +176 -1
  11. package/dist/chunk-JICBEFBT.js.map +1 -0
  12. package/dist/{chunk-BT7544RM.js → chunk-W277AG6N.js} +14 -9
  13. package/dist/chunk-W277AG6N.js.map +1 -0
  14. package/dist/consent/index.d.cts +2 -2
  15. package/dist/consent/index.d.ts +2 -2
  16. package/dist/derivations/index.d.cts +3 -3
  17. package/dist/derivations/index.d.ts +3 -3
  18. package/dist/{dev-unlock--ahUTrhc.d.ts → dev-unlock-Cvo-xCQC.d.ts} +1 -1
  19. package/dist/{dev-unlock-BIwt2V3p.d.cts → dev-unlock-Dy1qVpkL.d.cts} +1 -1
  20. package/dist/guards/index.d.cts +3 -3
  21. package/dist/guards/index.d.ts +3 -3
  22. package/dist/{hash-CJEFQxSD.d.ts → hash-BAlWR4WD.d.ts} +1 -1
  23. package/dist/{hash-BQVrGV-t.d.cts → hash-BgEQklQc.d.cts} +1 -1
  24. package/dist/history/index.d.cts +3 -3
  25. package/dist/history/index.d.ts +3 -3
  26. package/dist/i18n/index.cjs +75 -10
  27. package/dist/i18n/index.cjs.map +1 -1
  28. package/dist/i18n/index.d.cts +2 -2
  29. package/dist/i18n/index.d.ts +2 -2
  30. package/dist/i18n/index.js +11 -9
  31. package/dist/index.cjs +176 -114
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +9 -9
  34. package/dist/index.d.ts +9 -9
  35. package/dist/index.js +8 -10
  36. package/dist/index.js.map +1 -1
  37. package/dist/materialized-views/index.d.cts +3 -3
  38. package/dist/materialized-views/index.d.ts +3 -3
  39. package/dist/{noydb-6TADQIYH.js → noydb-FY2666NY.js} +3 -3
  40. package/dist/overlay-views/index.d.cts +3 -3
  41. package/dist/overlay-views/index.d.ts +3 -3
  42. package/dist/periods/index.d.cts +2 -2
  43. package/dist/periods/index.d.ts +2 -2
  44. package/dist/session/index.d.cts +3 -3
  45. package/dist/session/index.d.ts +3 -3
  46. package/dist/shadow/index.d.cts +2 -2
  47. package/dist/shadow/index.d.ts +2 -2
  48. package/dist/store/index.d.cts +2 -2
  49. package/dist/store/index.d.ts +2 -2
  50. package/dist/sync/index.d.cts +1 -1
  51. package/dist/sync/index.d.ts +1 -1
  52. package/dist/team/index.d.cts +2 -2
  53. package/dist/team/index.d.ts +2 -2
  54. package/dist/tx/index.d.cts +2 -2
  55. package/dist/tx/index.d.ts +2 -2
  56. package/dist/{types-BeKi0hCx.d.cts → types-DVlvNn2c.d.cts} +22 -5
  57. package/dist/{types-BV4AZKmx.d.ts → types-DlnZh1_i.d.ts} +22 -5
  58. package/dist/{ulid-CQc0eBxE.d.ts → ulid-CzPONlhG.d.ts} +1 -1
  59. package/dist/{ulid-Cvljl7ZZ.d.cts → ulid-r98nkjVd.d.cts} +1 -1
  60. package/dist/{with-derivation-BWcwmevt.d.ts → with-derivation-B98shCV8.d.ts} +1 -1
  61. package/dist/{with-derivation-BkOBDhsu.d.cts → with-derivation-BMQ9pIHe.d.cts} +1 -1
  62. package/dist/{with-guard-BD4Hyu8s.d.cts → with-guard-DUnC3JDN.d.cts} +1 -1
  63. package/dist/{with-guard-Du54s3Ti.d.ts → with-guard-DmT50nVG.d.ts} +1 -1
  64. package/dist/{with-materialized-view-B5W4wFAC.d.ts → with-materialized-view-Bp_M3sNG.d.ts} +1 -1
  65. package/dist/{with-materialized-view-BCPPZdjC.d.cts → with-materialized-view-eMTZ65_J.d.cts} +1 -1
  66. package/dist/{with-overlayed-view-B8RrlLsG.d.cts → with-overlayed-view-BoY6PB3n.d.cts} +1 -1
  67. package/dist/{with-overlayed-view-Cw-h9p9N.d.ts → with-overlayed-view-zzSnRQmS.d.ts} +1 -1
  68. package/package.json +3 -3
  69. package/dist/chunk-BT7544RM.js.map +0 -1
  70. package/dist/chunk-NONMIU6C.js +0 -118
  71. package/dist/chunk-NONMIU6C.js.map +0 -1
  72. package/dist/chunk-YZ6JETII.js.map +0 -1
  73. /package/dist/{noydb-6TADQIYH.js.map → noydb-FY2666NY.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { I as I18nStrategy } from '../types-BeKi0hCx.cjs';
2
- export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nTextDescriptor, f as I18nTextOptions, g as applyI18nLocale, h as dictCollectionName, i as dictKey, j as i18nText, k as isDictCollectionName, l as isDictKeyDescriptor, m as isI18nTextDescriptor, r as resolveI18nText, v as validateI18nTextValue } from '../types-BeKi0hCx.cjs';
1
+ import { I as I18nStrategy } from '../types-DVlvNn2c.cjs';
2
+ export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nTextDescriptor, f as I18nTextOptions, g as applyI18nLocale, h as dictCollectionName, i as dictKey, j as getAtPath, k as i18nText, l as isDictCollectionName, m as isDictKeyDescriptor, n as isI18nTextDescriptor, r as resolveI18nText, s as setAtPathInPlace, v as validateI18nTextValue } from '../types-DVlvNn2c.cjs';
3
3
  export { D as DictKeyInUseError, a as DictKeyMissingError, L as LocaleNotSpecifiedError, M as MissingTranslationError, R as ReservedCollectionNameError, T as TranslatorNotConfiguredError } from '../index-5I0MZ0jQ.cjs';
4
4
  import '../lazy-builder-DXlSCNCJ.cjs';
5
5
  import '../predicate-B0IKeBXx.cjs';
@@ -1,5 +1,5 @@
1
- import { I as I18nStrategy } from '../types-BV4AZKmx.js';
2
- export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nTextDescriptor, f as I18nTextOptions, g as applyI18nLocale, h as dictCollectionName, i as dictKey, j as i18nText, k as isDictCollectionName, l as isDictKeyDescriptor, m as isI18nTextDescriptor, r as resolveI18nText, v as validateI18nTextValue } from '../types-BV4AZKmx.js';
1
+ import { I as I18nStrategy } from '../types-DlnZh1_i.js';
2
+ export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nTextDescriptor, f as I18nTextOptions, g as applyI18nLocale, h as dictCollectionName, i as dictKey, j as getAtPath, k as i18nText, l as isDictCollectionName, m as isDictKeyDescriptor, n as isI18nTextDescriptor, r as resolveI18nText, s as setAtPathInPlace, v as validateI18nTextValue } from '../types-DlnZh1_i.js';
3
3
  export { D as DictKeyInUseError, a as DictKeyMissingError, L as LocaleNotSpecifiedError, M as MissingTranslationError, R as ReservedCollectionNameError, T as TranslatorNotConfiguredError } from '../index-fIPPh5dg.js';
4
4
  import '../lazy-builder-D1MyR1qH.js';
5
5
  import '../predicate-B0IKeBXx.js';
@@ -1,18 +1,18 @@
1
- import {
2
- applyI18nLocale,
3
- i18nText,
4
- isI18nTextDescriptor,
5
- resolveI18nText,
6
- validateI18nTextValue
7
- } from "../chunk-NONMIU6C.js";
8
1
  import {
9
2
  DICT_COLLECTION_PREFIX,
10
3
  DictionaryHandle,
4
+ applyI18nLocale,
11
5
  dictCollectionName,
12
6
  dictKey,
7
+ getAtPath,
8
+ i18nText,
13
9
  isDictCollectionName,
14
- isDictKeyDescriptor
15
- } from "../chunk-YZ6JETII.js";
10
+ isDictKeyDescriptor,
11
+ isI18nTextDescriptor,
12
+ resolveI18nText,
13
+ setAtPathInPlace,
14
+ validateI18nTextValue
15
+ } from "../chunk-JICBEFBT.js";
16
16
  import "../chunk-T6MTNGBM.js";
17
17
  import "../chunk-Z6FNBOTC.js";
18
18
  import "../chunk-5OVIFUQE.js";
@@ -59,11 +59,13 @@ export {
59
59
  applyI18nLocale,
60
60
  dictCollectionName,
61
61
  dictKey,
62
+ getAtPath,
62
63
  i18nText,
63
64
  isDictCollectionName,
64
65
  isDictKeyDescriptor,
65
66
  isI18nTextDescriptor,
66
67
  resolveI18nText,
68
+ setAtPathInPlace,
67
69
  validateI18nTextValue,
68
70
  withI18n
69
71
  };
package/dist/index.cjs CHANGED
@@ -9677,6 +9677,173 @@ var NO_CRDT = {
9677
9677
  }
9678
9678
  };
9679
9679
 
9680
+ // src/i18n/core.ts
9681
+ init_errors();
9682
+ function i18nText(options) {
9683
+ return { _noydbI18nText: true, options };
9684
+ }
9685
+ function isI18nTextDescriptor(x) {
9686
+ return typeof x === "object" && x !== null && x._noydbI18nText === true;
9687
+ }
9688
+ function validateI18nTextValue(value, field, descriptor) {
9689
+ const { options } = descriptor;
9690
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
9691
+ throw new MissingTranslationError(
9692
+ field,
9693
+ options.languages,
9694
+ `Field "${field}" must be a { [locale]: string } map, got ${typeof value}.`
9695
+ );
9696
+ }
9697
+ const map = value;
9698
+ for (const [locale, v] of Object.entries(map)) {
9699
+ if (typeof v !== "string") {
9700
+ throw new MissingTranslationError(
9701
+ field,
9702
+ [locale],
9703
+ `Field "${field}": locale "${locale}" must be a string, got ${typeof v}.`
9704
+ );
9705
+ }
9706
+ }
9707
+ const { required } = options;
9708
+ if (required === "all") {
9709
+ const missing = options.languages.filter(
9710
+ (lang) => !(lang in map) || map[lang] === ""
9711
+ );
9712
+ if (missing.length > 0) {
9713
+ throw new MissingTranslationError(
9714
+ field,
9715
+ missing,
9716
+ `Field "${field}" requires all declared languages. Missing: ${missing.join(", ")}.`
9717
+ );
9718
+ }
9719
+ } else if (required === "any") {
9720
+ const present = options.languages.some(
9721
+ (lang) => lang in map && map[lang] !== ""
9722
+ );
9723
+ if (!present) {
9724
+ throw new MissingTranslationError(
9725
+ field,
9726
+ options.languages,
9727
+ `Field "${field}" requires at least one declared language. None present.`
9728
+ );
9729
+ }
9730
+ } else {
9731
+ const requiredList = required;
9732
+ const missing = requiredList.filter(
9733
+ (lang) => !(lang in map) || map[lang] === ""
9734
+ );
9735
+ if (missing.length > 0) {
9736
+ throw new MissingTranslationError(
9737
+ field,
9738
+ missing,
9739
+ `Field "${field}" requires: ${requiredList.join(", ")}. Missing: ${missing.join(", ")}.`
9740
+ );
9741
+ }
9742
+ }
9743
+ }
9744
+ function resolveI18nText(value, locale, fallback, field) {
9745
+ if (locale === "raw") {
9746
+ return value;
9747
+ }
9748
+ if (!locale) {
9749
+ throw new LocaleNotSpecifiedError(field ?? "<unknown>");
9750
+ }
9751
+ if (value[locale] !== void 0 && value[locale] !== "") {
9752
+ return value[locale];
9753
+ }
9754
+ const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
9755
+ for (const fb of chain) {
9756
+ if (fb === "any") {
9757
+ const any = Object.values(value).find((v) => v !== "");
9758
+ if (any !== void 0) return any;
9759
+ } else if (value[fb] !== void 0 && value[fb] !== "") {
9760
+ return value[fb];
9761
+ }
9762
+ }
9763
+ throw new LocaleNotSpecifiedError(
9764
+ field ?? "<unknown>",
9765
+ `No translation available for locale "${locale}"` + (chain.length > 0 ? ` or fallback chain [${chain.join(", ")}]` : "") + "."
9766
+ );
9767
+ }
9768
+ function getAtPath(obj, path) {
9769
+ const arrayIdx = path.indexOf("[].");
9770
+ if (arrayIdx !== -1) {
9771
+ const arrayKey = path.slice(0, arrayIdx);
9772
+ const restPath = path.slice(arrayIdx + 3);
9773
+ const arr = obj[arrayKey];
9774
+ if (!Array.isArray(arr)) return [];
9775
+ return arr.flatMap((item) => {
9776
+ if (!item || typeof item !== "object" || Array.isArray(item)) return [];
9777
+ return getAtPath(item, restPath);
9778
+ });
9779
+ }
9780
+ const dotIdx = path.indexOf(".");
9781
+ if (dotIdx !== -1) {
9782
+ const head = path.slice(0, dotIdx);
9783
+ const rest = path.slice(dotIdx + 1);
9784
+ const nested = obj[head];
9785
+ if (!nested || typeof nested !== "object" || Array.isArray(nested)) return [];
9786
+ return getAtPath(nested, rest);
9787
+ }
9788
+ const val = obj[path];
9789
+ return val !== void 0 ? [val] : [];
9790
+ }
9791
+ function setAtPathInPlace(obj, path, value) {
9792
+ const dotIdx = path.indexOf(".");
9793
+ if (dotIdx !== -1) {
9794
+ const head = path.slice(0, dotIdx);
9795
+ const rest = path.slice(dotIdx + 1);
9796
+ const nested = obj[head];
9797
+ if (!nested || typeof nested !== "object" || Array.isArray(nested)) return;
9798
+ setAtPathInPlace(nested, rest, value);
9799
+ return;
9800
+ }
9801
+ obj[path] = value;
9802
+ }
9803
+ function applyAtPath(obj, path, locale, fallback) {
9804
+ const arrayIdx = path.indexOf("[].");
9805
+ if (arrayIdx !== -1) {
9806
+ const arrayKey = path.slice(0, arrayIdx);
9807
+ const restPath = path.slice(arrayIdx + 3);
9808
+ const arr = obj[arrayKey];
9809
+ if (!Array.isArray(arr)) return obj;
9810
+ return {
9811
+ ...obj,
9812
+ [arrayKey]: arr.map((item) => {
9813
+ if (!item || typeof item !== "object" || Array.isArray(item)) return item;
9814
+ return applyAtPath(item, restPath, locale, fallback);
9815
+ })
9816
+ };
9817
+ }
9818
+ const dotIdx = path.indexOf(".");
9819
+ if (dotIdx !== -1) {
9820
+ const head = path.slice(0, dotIdx);
9821
+ const rest = path.slice(dotIdx + 1);
9822
+ const nested = obj[head];
9823
+ if (!nested || typeof nested !== "object" || Array.isArray(nested)) return obj;
9824
+ return {
9825
+ ...obj,
9826
+ [head]: applyAtPath(nested, rest, locale, fallback)
9827
+ };
9828
+ }
9829
+ const raw = obj[path];
9830
+ if (raw === void 0 || raw === null) return obj;
9831
+ if (typeof raw !== "object" || Array.isArray(raw)) return obj;
9832
+ return {
9833
+ ...obj,
9834
+ [path]: resolveI18nText(raw, locale, fallback, path)
9835
+ };
9836
+ }
9837
+ function applyI18nLocale(record, i18nFields, locale, fallback) {
9838
+ const fieldNames = Object.keys(i18nFields);
9839
+ if (fieldNames.length === 0) return record;
9840
+ let result = record;
9841
+ for (const field of fieldNames) {
9842
+ result = applyAtPath(result, field, locale, fallback);
9843
+ }
9844
+ return result;
9845
+ }
9846
+
9680
9847
  // src/i18n/strategy.ts
9681
9848
  function notEnabled(op) {
9682
9849
  return new Error(
@@ -12645,7 +12812,9 @@ var Collection = class {
12645
12812
  const obj = record;
12646
12813
  for (const [field, descriptor] of Object.entries(this.i18nFields)) {
12647
12814
  if (!descriptor.options.autoTranslate) continue;
12648
- const value = obj[field];
12815
+ const leafValues = getAtPath(obj, field);
12816
+ if (leafValues.length !== 1) continue;
12817
+ const value = leafValues[0];
12649
12818
  if (!value || typeof value !== "object" || Array.isArray(value)) continue;
12650
12819
  const map = value;
12651
12820
  const { languages, required } = descriptor.options;
@@ -12669,8 +12838,7 @@ var Collection = class {
12669
12838
  this.name
12670
12839
  );
12671
12840
  }
12672
- ;
12673
- record[field] = translated;
12841
+ setAtPathInPlace(obj, field, translated);
12674
12842
  }
12675
12843
  }
12676
12844
  if (this.i18nPutValidator !== void 0) {
@@ -16736,9 +16904,11 @@ var Vault = class {
16736
16904
  if (!record || typeof record !== "object") return;
16737
16905
  const obj = record;
16738
16906
  for (const [field, descriptor] of Object.entries(i18nFields)) {
16739
- const value = obj[field];
16740
- if (value === void 0 || value === null) continue;
16741
- this.i18nStrategy.validateI18nTextValue(value, field, descriptor);
16907
+ const values = getAtPath(obj, field);
16908
+ for (const value of values) {
16909
+ if (value === void 0 || value === null) continue;
16910
+ this.i18nStrategy.validateI18nTextValue(value, field, descriptor);
16911
+ }
16742
16912
  }
16743
16913
  }
16744
16914
  /**
@@ -22622,114 +22792,6 @@ function withOverlayedView(spec) {
22622
22792
  // src/index.ts
22623
22793
  init_errors();
22624
22794
  init_errors();
22625
-
22626
- // src/i18n/core.ts
22627
- init_errors();
22628
- function i18nText(options) {
22629
- return { _noydbI18nText: true, options };
22630
- }
22631
- function isI18nTextDescriptor(x) {
22632
- return typeof x === "object" && x !== null && x._noydbI18nText === true;
22633
- }
22634
- function validateI18nTextValue(value, field, descriptor) {
22635
- const { options } = descriptor;
22636
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
22637
- throw new MissingTranslationError(
22638
- field,
22639
- options.languages,
22640
- `Field "${field}" must be a { [locale]: string } map, got ${typeof value}.`
22641
- );
22642
- }
22643
- const map = value;
22644
- for (const [locale, v] of Object.entries(map)) {
22645
- if (typeof v !== "string") {
22646
- throw new MissingTranslationError(
22647
- field,
22648
- [locale],
22649
- `Field "${field}": locale "${locale}" must be a string, got ${typeof v}.`
22650
- );
22651
- }
22652
- }
22653
- const { required } = options;
22654
- if (required === "all") {
22655
- const missing = options.languages.filter(
22656
- (lang) => !(lang in map) || map[lang] === ""
22657
- );
22658
- if (missing.length > 0) {
22659
- throw new MissingTranslationError(
22660
- field,
22661
- missing,
22662
- `Field "${field}" requires all declared languages. Missing: ${missing.join(", ")}.`
22663
- );
22664
- }
22665
- } else if (required === "any") {
22666
- const present = options.languages.some(
22667
- (lang) => lang in map && map[lang] !== ""
22668
- );
22669
- if (!present) {
22670
- throw new MissingTranslationError(
22671
- field,
22672
- options.languages,
22673
- `Field "${field}" requires at least one declared language. None present.`
22674
- );
22675
- }
22676
- } else {
22677
- const requiredList = required;
22678
- const missing = requiredList.filter(
22679
- (lang) => !(lang in map) || map[lang] === ""
22680
- );
22681
- if (missing.length > 0) {
22682
- throw new MissingTranslationError(
22683
- field,
22684
- missing,
22685
- `Field "${field}" requires: ${requiredList.join(", ")}. Missing: ${missing.join(", ")}.`
22686
- );
22687
- }
22688
- }
22689
- }
22690
- function resolveI18nText(value, locale, fallback, field) {
22691
- if (locale === "raw") {
22692
- return value;
22693
- }
22694
- if (!locale) {
22695
- throw new LocaleNotSpecifiedError(field ?? "<unknown>");
22696
- }
22697
- if (value[locale] !== void 0 && value[locale] !== "") {
22698
- return value[locale];
22699
- }
22700
- const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
22701
- for (const fb of chain) {
22702
- if (fb === "any") {
22703
- const any = Object.values(value).find((v) => v !== "");
22704
- if (any !== void 0) return any;
22705
- } else if (value[fb] !== void 0 && value[fb] !== "") {
22706
- return value[fb];
22707
- }
22708
- }
22709
- throw new LocaleNotSpecifiedError(
22710
- field ?? "<unknown>",
22711
- `No translation available for locale "${locale}"` + (chain.length > 0 ? ` or fallback chain [${chain.join(", ")}]` : "") + "."
22712
- );
22713
- }
22714
- function applyI18nLocale(record, i18nFields, locale, fallback) {
22715
- const fieldNames = Object.keys(i18nFields);
22716
- if (fieldNames.length === 0) return record;
22717
- const result = { ...record };
22718
- for (const field of fieldNames) {
22719
- const raw = result[field];
22720
- if (raw === void 0 || raw === null) continue;
22721
- if (typeof raw !== "object" || Array.isArray(raw)) continue;
22722
- result[field] = resolveI18nText(
22723
- raw,
22724
- locale,
22725
- fallback,
22726
- field
22727
- );
22728
- }
22729
- return result;
22730
- }
22731
-
22732
- // src/index.ts
22733
22795
  init_errors();
22734
22796
 
22735
22797
  // src/team/sync-credentials.ts