@neetru/sdk 3.6.0 → 3.8.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +66 -1
  3. package/dist/ai.cjs +298 -391
  4. package/dist/ai.d.cts +1 -1
  5. package/dist/ai.d.ts +1 -1
  6. package/dist/ai.mjs +298 -391
  7. package/dist/auth.cjs +3717 -5005
  8. package/dist/auth.d.cts +1 -1
  9. package/dist/auth.d.ts +1 -1
  10. package/dist/auth.mjs +3714 -5002
  11. package/dist/build-guard.cjs +101 -119
  12. package/dist/build-guard.mjs +91 -109
  13. package/dist/catalog.cjs +220 -225
  14. package/dist/catalog.d.cts +1 -1
  15. package/dist/catalog.d.ts +1 -1
  16. package/dist/catalog.mjs +220 -225
  17. package/dist/checkout.cjs +307 -323
  18. package/dist/checkout.d.cts +1 -1
  19. package/dist/checkout.d.ts +1 -1
  20. package/dist/checkout.mjs +306 -322
  21. package/dist/db-react.cjs +59 -87
  22. package/dist/db-react.d.cts +1 -1
  23. package/dist/db-react.d.ts +1 -1
  24. package/dist/db-react.mjs +56 -84
  25. package/dist/db.cjs +2128 -3014
  26. package/dist/db.d.cts +1 -1
  27. package/dist/db.d.ts +1 -1
  28. package/dist/db.mjs +2141 -3027
  29. package/dist/entitlements.cjs +19 -20
  30. package/dist/entitlements.d.cts +1 -1
  31. package/dist/entitlements.d.ts +1 -1
  32. package/dist/entitlements.mjs +19 -20
  33. package/dist/errors.cjs +16 -12
  34. package/dist/errors.d.cts +59 -3
  35. package/dist/errors.d.ts +59 -3
  36. package/dist/errors.mjs +15 -12
  37. package/dist/firestore-compat.cjs +241 -297
  38. package/dist/firestore-compat.d.cts +1 -1
  39. package/dist/firestore-compat.d.ts +1 -1
  40. package/dist/firestore-compat.mjs +215 -271
  41. package/dist/index.cjs +3942 -5134
  42. package/dist/index.d.cts +181 -5
  43. package/dist/index.d.ts +181 -5
  44. package/dist/index.mjs +4040 -5239
  45. package/dist/mobile.cjs +459 -344
  46. package/dist/mobile.d.cts +59 -4
  47. package/dist/mobile.d.ts +59 -4
  48. package/dist/mobile.mjs +459 -344
  49. package/dist/mocks.cjs +319 -447
  50. package/dist/mocks.d.cts +1 -1
  51. package/dist/mocks.d.ts +1 -1
  52. package/dist/mocks.mjs +313 -441
  53. package/dist/notifications.cjs +296 -317
  54. package/dist/notifications.d.cts +1 -1
  55. package/dist/notifications.d.ts +1 -1
  56. package/dist/notifications.mjs +295 -316
  57. package/dist/react.cjs +557 -707
  58. package/dist/react.d.cts +1 -1
  59. package/dist/react.d.ts +1 -1
  60. package/dist/react.mjs +547 -697
  61. package/dist/support.cjs +402 -328
  62. package/dist/support.d.cts +29 -3
  63. package/dist/support.d.ts +29 -3
  64. package/dist/support.mjs +401 -328
  65. package/dist/telemetry.cjs +267 -304
  66. package/dist/telemetry.d.cts +1 -1
  67. package/dist/telemetry.d.ts +1 -1
  68. package/dist/telemetry.mjs +267 -304
  69. package/dist/{types-Du_iioJ7.d.cts → types-D-9bjlM0.d.cts} +74 -1
  70. package/dist/{types-BPATkXYu.d.ts → types-bVztFQTI.d.ts} +74 -1
  71. package/dist/usage.cjs +233 -230
  72. package/dist/usage.d.cts +1 -1
  73. package/dist/usage.d.ts +1 -1
  74. package/dist/usage.mjs +233 -230
  75. package/dist/webhooks.cjs +328 -362
  76. package/dist/webhooks.d.cts +1 -1
  77. package/dist/webhooks.d.ts +1 -1
  78. package/dist/webhooks.mjs +325 -359
  79. package/package.json +5 -3
  80. package/dist/ai.cjs.map +0 -1
  81. package/dist/ai.mjs.map +0 -1
  82. package/dist/auth.cjs.map +0 -1
  83. package/dist/auth.mjs.map +0 -1
  84. package/dist/build-guard.cjs.map +0 -1
  85. package/dist/build-guard.mjs.map +0 -1
  86. package/dist/catalog.cjs.map +0 -1
  87. package/dist/catalog.mjs.map +0 -1
  88. package/dist/checkout.cjs.map +0 -1
  89. package/dist/checkout.mjs.map +0 -1
  90. package/dist/db-react.cjs.map +0 -1
  91. package/dist/db-react.mjs.map +0 -1
  92. package/dist/db.cjs.map +0 -1
  93. package/dist/db.mjs.map +0 -1
  94. package/dist/entitlements.cjs.map +0 -1
  95. package/dist/entitlements.mjs.map +0 -1
  96. package/dist/errors.cjs.map +0 -1
  97. package/dist/errors.mjs.map +0 -1
  98. package/dist/firestore-compat.cjs.map +0 -1
  99. package/dist/firestore-compat.mjs.map +0 -1
  100. package/dist/index.cjs.map +0 -1
  101. package/dist/index.mjs.map +0 -1
  102. package/dist/mobile.cjs.map +0 -1
  103. package/dist/mobile.mjs.map +0 -1
  104. package/dist/mocks.cjs.map +0 -1
  105. package/dist/mocks.mjs.map +0 -1
  106. package/dist/notifications.cjs.map +0 -1
  107. package/dist/notifications.mjs.map +0 -1
  108. package/dist/react.cjs.map +0 -1
  109. package/dist/react.mjs.map +0 -1
  110. package/dist/support.cjs.map +0 -1
  111. package/dist/support.mjs.map +0 -1
  112. package/dist/telemetry.cjs.map +0 -1
  113. package/dist/telemetry.mjs.map +0 -1
  114. package/dist/usage.cjs.map +0 -1
  115. package/dist/usage.mjs.map +0 -1
  116. package/dist/webhooks.cjs.map +0 -1
  117. package/dist/webhooks.mjs.map +0 -1
package/dist/db-react.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ var n = require('react');
4
4
 
5
5
  function _interopNamespace(e) {
6
6
  if (e && e.__esModule) return e;
@@ -20,129 +20,101 @@ function _interopNamespace(e) {
20
20
  return Object.freeze(n);
21
21
  }
22
22
 
23
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
23
+ var n__namespace = /*#__PURE__*/_interopNamespace(n);
24
24
 
25
25
  // src/db/react.ts
26
- function isNeetruClient(input) {
27
- const maybe = input;
28
- if (typeof maybe.syncState !== "undefined") return false;
29
- const db = maybe.db;
30
- return !!db && typeof db.syncState !== "undefined" && typeof db.onSyncStateChanged === "function";
26
+ function f(e) {
27
+ let t = e;
28
+ if (typeof t.syncState < "u") return false;
29
+ let s = t.db;
30
+ return !!s && typeof s.syncState < "u" && typeof s.onSyncStateChanged == "function";
31
31
  }
32
- function resolveSyncStateSource(input) {
33
- return isNeetruClient(input) ? input.db : input;
32
+ function i(e) {
33
+ return f(e) ? e.db : e;
34
34
  }
35
- function serializeQuery(query) {
36
- if (!query) return "";
35
+ function S(e) {
36
+ if (!e) return "";
37
37
  try {
38
- return JSON.stringify(query, Object.keys(query).sort());
38
+ return JSON.stringify(e, Object.keys(e).sort());
39
39
  } catch {
40
- return String(query);
40
+ return String(e);
41
41
  }
42
42
  }
43
- function useDocument(ref, id) {
44
- const [state, setState] = React__namespace.useState({
43
+ function d(e, t) {
44
+ let [s, c] = n__namespace.useState({
45
45
  data: null,
46
46
  loading: true,
47
47
  fromCache: true,
48
48
  stale: false
49
- });
50
- const mountedRef = React__namespace.useRef(true);
51
- React__namespace.useEffect(() => {
52
- mountedRef.current = true;
53
- setState({ data: null, loading: true, fromCache: true, stale: false });
54
- const docRef = ref.doc(id);
55
- const unsubscribe = docRef.onSnapshot(
56
- (snap) => {
57
- if (!mountedRef.current) return;
58
- if (snap === null || snap.docs.length === 0) {
59
- setState({
60
- data: null,
61
- loading: false,
62
- fromCache: snap?.fromCache ?? true,
63
- stale: snap?.stale ?? false
64
- });
65
- } else {
66
- setState({
67
- data: snap.docs[0]?.data ?? null,
68
- loading: false,
69
- fromCache: snap.fromCache,
70
- stale: snap.stale
71
- });
72
- }
49
+ }), o = n__namespace.useRef(true);
50
+ return n__namespace.useEffect(() => {
51
+ o.current = true, c({ data: null, loading: true, fromCache: true, stale: false });
52
+ let a = e.doc(t).onSnapshot(
53
+ (r) => {
54
+ o.current && (r === null || r.docs.length === 0 ? c({
55
+ data: null,
56
+ loading: false,
57
+ fromCache: r?.fromCache ?? true,
58
+ stale: r?.stale ?? false
59
+ }) : c({
60
+ data: r.docs[0]?.data ?? null,
61
+ loading: false,
62
+ fromCache: r.fromCache,
63
+ stale: r.stale
64
+ }));
73
65
  }
74
66
  );
75
67
  return () => {
76
- mountedRef.current = false;
77
- unsubscribe();
68
+ o.current = false, a();
78
69
  };
79
- }, [ref, id]);
80
- return state;
70
+ }, [e, t]), s;
81
71
  }
82
- function useCollection(ref, query) {
83
- const [state, setState] = React__namespace.useState({
72
+ function y(e, t) {
73
+ let [s, c] = n__namespace.useState({
84
74
  docs: [],
85
75
  loading: true,
86
76
  fromCache: true,
87
77
  stale: false,
88
78
  hasPendingWrites: false
89
- });
90
- const mountedRef = React__namespace.useRef(true);
91
- const queryKey = serializeQuery(query);
92
- const queryRef = React__namespace.useRef(query);
93
- queryRef.current = query;
94
- React__namespace.useEffect(() => {
95
- mountedRef.current = true;
96
- setState({
79
+ }), o = n__namespace.useRef(true), u = S(t), a = n__namespace.useRef(t);
80
+ return a.current = t, n__namespace.useEffect(() => {
81
+ o.current = true, c({
97
82
  docs: [],
98
83
  loading: true,
99
84
  fromCache: true,
100
85
  stale: false,
101
86
  hasPendingWrites: false
102
87
  });
103
- const unsubscribe = ref.onSnapshot(
104
- queryRef.current,
105
- (snap) => {
106
- if (!mountedRef.current) return;
107
- setState({
108
- docs: snap.docs,
88
+ let r = e.onSnapshot(
89
+ a.current,
90
+ (l) => {
91
+ o.current && c({
92
+ docs: l.docs,
109
93
  loading: false,
110
- fromCache: snap.fromCache,
111
- stale: snap.stale,
112
- hasPendingWrites: snap.hasPendingWrites
94
+ fromCache: l.fromCache,
95
+ stale: l.stale,
96
+ hasPendingWrites: l.hasPendingWrites
113
97
  });
114
98
  }
115
99
  );
116
100
  return () => {
117
- mountedRef.current = false;
118
- unsubscribe();
101
+ o.current = false, r();
119
102
  };
120
- }, [ref, queryKey]);
121
- return state;
103
+ }, [e, u]), s;
122
104
  }
123
- function useSyncState(input) {
124
- const source = resolveSyncStateSource(input);
125
- const [state, setState] = React__namespace.useState(() => source.syncState);
126
- const mountedRef = React__namespace.useRef(true);
127
- React__namespace.useEffect(() => {
128
- mountedRef.current = true;
129
- if (mountedRef.current) {
130
- setState(source.syncState);
131
- }
132
- const unsubscribe = source.onSyncStateChanged((s) => {
133
- if (!mountedRef.current) return;
134
- setState(s);
105
+ function b(e) {
106
+ let t = i(e), [s, c] = n__namespace.useState(() => t.syncState), o = n__namespace.useRef(true);
107
+ return n__namespace.useEffect(() => {
108
+ o.current = true, o.current && c(t.syncState);
109
+ let u = t.onSyncStateChanged((a) => {
110
+ o.current && c(a);
135
111
  });
136
112
  return () => {
137
- mountedRef.current = false;
138
- unsubscribe();
113
+ o.current = false, u();
139
114
  };
140
- }, [source]);
141
- return state;
115
+ }, [t]), s;
142
116
  }
143
117
 
144
- exports.useCollection = useCollection;
145
- exports.useDocument = useDocument;
146
- exports.useSyncState = useSyncState;
147
- //# sourceMappingURL=db-react.cjs.map
148
- //# sourceMappingURL=db-react.cjs.map
118
+ exports.useCollection = y;
119
+ exports.useDocument = d;
120
+ exports.useSyncState = b;
@@ -1,4 +1,4 @@
1
- import { aq as SyncState, av as Unsubscribe, F as DbDoc, W as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-Du_iioJ7.cjs';
1
+ import { ar as SyncState, aw as Unsubscribe, F as DbDoc, X as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-D-9bjlM0.cjs';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { aq as SyncState, av as Unsubscribe, F as DbDoc, W as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-BPATkXYu.js';
1
+ import { ar as SyncState, aw as Unsubscribe, F as DbDoc, X as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-bVztFQTI.js';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.js';
4
4
 
package/dist/db-react.mjs CHANGED
@@ -1,124 +1,96 @@
1
- import * as React from 'react';
1
+ import * as n from 'react';
2
2
 
3
3
  // src/db/react.ts
4
- function isNeetruClient(input) {
5
- const maybe = input;
6
- if (typeof maybe.syncState !== "undefined") return false;
7
- const db = maybe.db;
8
- return !!db && typeof db.syncState !== "undefined" && typeof db.onSyncStateChanged === "function";
4
+ function f(e) {
5
+ let t = e;
6
+ if (typeof t.syncState < "u") return false;
7
+ let s = t.db;
8
+ return !!s && typeof s.syncState < "u" && typeof s.onSyncStateChanged == "function";
9
9
  }
10
- function resolveSyncStateSource(input) {
11
- return isNeetruClient(input) ? input.db : input;
10
+ function i(e) {
11
+ return f(e) ? e.db : e;
12
12
  }
13
- function serializeQuery(query) {
14
- if (!query) return "";
13
+ function S(e) {
14
+ if (!e) return "";
15
15
  try {
16
- return JSON.stringify(query, Object.keys(query).sort());
16
+ return JSON.stringify(e, Object.keys(e).sort());
17
17
  } catch {
18
- return String(query);
18
+ return String(e);
19
19
  }
20
20
  }
21
- function useDocument(ref, id) {
22
- const [state, setState] = React.useState({
21
+ function d(e, t) {
22
+ let [s, c] = n.useState({
23
23
  data: null,
24
24
  loading: true,
25
25
  fromCache: true,
26
26
  stale: false
27
- });
28
- const mountedRef = React.useRef(true);
29
- React.useEffect(() => {
30
- mountedRef.current = true;
31
- setState({ data: null, loading: true, fromCache: true, stale: false });
32
- const docRef = ref.doc(id);
33
- const unsubscribe = docRef.onSnapshot(
34
- (snap) => {
35
- if (!mountedRef.current) return;
36
- if (snap === null || snap.docs.length === 0) {
37
- setState({
38
- data: null,
39
- loading: false,
40
- fromCache: snap?.fromCache ?? true,
41
- stale: snap?.stale ?? false
42
- });
43
- } else {
44
- setState({
45
- data: snap.docs[0]?.data ?? null,
46
- loading: false,
47
- fromCache: snap.fromCache,
48
- stale: snap.stale
49
- });
50
- }
27
+ }), o = n.useRef(true);
28
+ return n.useEffect(() => {
29
+ o.current = true, c({ data: null, loading: true, fromCache: true, stale: false });
30
+ let a = e.doc(t).onSnapshot(
31
+ (r) => {
32
+ o.current && (r === null || r.docs.length === 0 ? c({
33
+ data: null,
34
+ loading: false,
35
+ fromCache: r?.fromCache ?? true,
36
+ stale: r?.stale ?? false
37
+ }) : c({
38
+ data: r.docs[0]?.data ?? null,
39
+ loading: false,
40
+ fromCache: r.fromCache,
41
+ stale: r.stale
42
+ }));
51
43
  }
52
44
  );
53
45
  return () => {
54
- mountedRef.current = false;
55
- unsubscribe();
46
+ o.current = false, a();
56
47
  };
57
- }, [ref, id]);
58
- return state;
48
+ }, [e, t]), s;
59
49
  }
60
- function useCollection(ref, query) {
61
- const [state, setState] = React.useState({
50
+ function y(e, t) {
51
+ let [s, c] = n.useState({
62
52
  docs: [],
63
53
  loading: true,
64
54
  fromCache: true,
65
55
  stale: false,
66
56
  hasPendingWrites: false
67
- });
68
- const mountedRef = React.useRef(true);
69
- const queryKey = serializeQuery(query);
70
- const queryRef = React.useRef(query);
71
- queryRef.current = query;
72
- React.useEffect(() => {
73
- mountedRef.current = true;
74
- setState({
57
+ }), o = n.useRef(true), u = S(t), a = n.useRef(t);
58
+ return a.current = t, n.useEffect(() => {
59
+ o.current = true, c({
75
60
  docs: [],
76
61
  loading: true,
77
62
  fromCache: true,
78
63
  stale: false,
79
64
  hasPendingWrites: false
80
65
  });
81
- const unsubscribe = ref.onSnapshot(
82
- queryRef.current,
83
- (snap) => {
84
- if (!mountedRef.current) return;
85
- setState({
86
- docs: snap.docs,
66
+ let r = e.onSnapshot(
67
+ a.current,
68
+ (l) => {
69
+ o.current && c({
70
+ docs: l.docs,
87
71
  loading: false,
88
- fromCache: snap.fromCache,
89
- stale: snap.stale,
90
- hasPendingWrites: snap.hasPendingWrites
72
+ fromCache: l.fromCache,
73
+ stale: l.stale,
74
+ hasPendingWrites: l.hasPendingWrites
91
75
  });
92
76
  }
93
77
  );
94
78
  return () => {
95
- mountedRef.current = false;
96
- unsubscribe();
79
+ o.current = false, r();
97
80
  };
98
- }, [ref, queryKey]);
99
- return state;
81
+ }, [e, u]), s;
100
82
  }
101
- function useSyncState(input) {
102
- const source = resolveSyncStateSource(input);
103
- const [state, setState] = React.useState(() => source.syncState);
104
- const mountedRef = React.useRef(true);
105
- React.useEffect(() => {
106
- mountedRef.current = true;
107
- if (mountedRef.current) {
108
- setState(source.syncState);
109
- }
110
- const unsubscribe = source.onSyncStateChanged((s) => {
111
- if (!mountedRef.current) return;
112
- setState(s);
83
+ function b(e) {
84
+ let t = i(e), [s, c] = n.useState(() => t.syncState), o = n.useRef(true);
85
+ return n.useEffect(() => {
86
+ o.current = true, o.current && c(t.syncState);
87
+ let u = t.onSyncStateChanged((a) => {
88
+ o.current && c(a);
113
89
  });
114
90
  return () => {
115
- mountedRef.current = false;
116
- unsubscribe();
91
+ o.current = false, u();
117
92
  };
118
- }, [source]);
119
- return state;
93
+ }, [t]), s;
120
94
  }
121
95
 
122
- export { useCollection, useDocument, useSyncState };
123
- //# sourceMappingURL=db-react.mjs.map
124
- //# sourceMappingURL=db-react.mjs.map
96
+ export { y as useCollection, d as useDocument, b as useSyncState };