@neetru/sdk 2.1.0 → 2.1.1
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/CHANGELOG.md +53 -1
- package/dist/auth.cjs +29 -7
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/auth.mjs +29 -7
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.d.cts +2 -2
- package/dist/catalog.d.ts +2 -2
- package/dist/checkout.d.cts +2 -2
- package/dist/checkout.d.ts +2 -2
- package/dist/{collection-ref-BBvTTXoG.d.cts → collection-ref-DqAAhuhX.d.cts} +56 -7
- package/dist/{collection-ref-BBvTTXoG.d.ts → collection-ref-DqAAhuhX.d.ts} +56 -7
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +29 -7
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +2 -2
- package/dist/db.d.ts +2 -2
- package/dist/db.mjs +29 -7
- package/dist/db.mjs.map +1 -1
- package/dist/entitlements.d.cts +2 -2
- package/dist/entitlements.d.ts +2 -2
- package/dist/index.cjs +49 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +49 -21
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.cjs +20 -14
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +2 -2
- package/dist/mocks.d.ts +2 -2
- package/dist/mocks.mjs +20 -14
- package/dist/mocks.mjs.map +1 -1
- package/dist/notifications.d.cts +2 -2
- package/dist/notifications.d.ts +2 -2
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/support.d.cts +2 -2
- package/dist/support.d.ts +2 -2
- package/dist/telemetry.d.cts +2 -2
- package/dist/telemetry.d.ts +2 -2
- package/dist/{types-Kmt4y1FQ.d.cts → types-Cfb-qeDg.d.cts} +1 -1
- package/dist/{types-B1jylbMC.d.ts → types-V1EfjR1p.d.ts} +1 -1
- package/dist/usage.d.cts +2 -2
- package/dist/usage.d.ts +2 -2
- package/dist/webhooks.d.cts +2 -2
- package/dist/webhooks.d.ts +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Planned (post-2.
|
|
10
|
+
### Planned (post-2.1)
|
|
11
11
|
- size-limit budget no CI (<12KB gz core com db namespace).
|
|
12
12
|
- CDN distribution (`cdn.neetru.com/sdk/v2/`).
|
|
13
13
|
- Endpoint batch `/api/v1/sdk/telemetry/batch` (substitui drenagem N×1 do `track()` por 1 request).
|
|
14
14
|
|
|
15
|
+
## [2.1.1] - 2026-05-25 — **DbDocRef identity + DbBatchOp discriminated union [patch]**
|
|
16
|
+
|
|
17
|
+
Dois fixes LOW reportados por pdv-agiliza (tickets `bug_97b3f0488d1c49cf8c5f94e5d544289b` + `bug_6aab9adc182640218652a65cdcb71b63`).
|
|
18
|
+
Sem breaking changes — todos os usos de `doc()` existentes continuam funcionando.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **`DbDocRef.id / .path / .collection`** (fix #13, ticket `bug_97b3f0488d1c49cf8c5f94e5d544289b`):
|
|
23
|
+
`DbDocRef` agora expõe três propriedades readonly de identidade:
|
|
24
|
+
- `id: string` — ID do documento dentro da coleção.
|
|
25
|
+
- `path: string` — Caminho completo `"colecao/docId"`.
|
|
26
|
+
- `collection: string` — Nome da coleção parent.
|
|
27
|
+
Análogo ao `DocumentReference.id/.path` do Firestore Web SDK. Elimina a necessidade
|
|
28
|
+
de adaptadores externos que reattachavam `collection + id` manualmente.
|
|
29
|
+
Implementado em `DbCollectionRefImpl.doc()` (offline), `createLazyCollectionRef.doc()`
|
|
30
|
+
(client-db) e `MockDb.doc()` (mocks).
|
|
31
|
+
|
|
32
|
+
- **`DbBatchOp` discriminated union** (fix #14, ticket `bug_6aab9adc182640218652a65cdcb71b63`):
|
|
33
|
+
`DbBatchOp` foi convertido de `interface` opaca (campo `op: 'add'|'set'|'update'|'remove'`
|
|
34
|
+
com `id?`/`data?` opcionais) para **discriminated union** pelo campo `kind`:
|
|
35
|
+
```ts
|
|
36
|
+
type DbBatchOp<T = Record<string, unknown>> =
|
|
37
|
+
| { kind: 'add'; data: Omit<T, 'id'> }
|
|
38
|
+
| { kind: 'set'; id: string; data: Omit<T, 'id'> }
|
|
39
|
+
| { kind: 'update'; id: string; data: Partial<Omit<T, 'id'>> }
|
|
40
|
+
| { kind: 'remove'; id: string };
|
|
41
|
+
```
|
|
42
|
+
O `.d.ts` público agora expõe claramente quais campos são obrigatórios por variante.
|
|
43
|
+
O campo `collection` foi removido da operação (sempre opera na coleção do `DbCollectionRef`).
|
|
44
|
+
|
|
45
|
+
### Migration (2.0.0 → 2.1.1)
|
|
46
|
+
|
|
47
|
+
Callers que usavam `batch()` devem trocar `op` por `kind` e remover o campo `collection`:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// antes (2.0.0)
|
|
51
|
+
col.batch([
|
|
52
|
+
{ op: 'add', collection: 'orders', data: { total: 10 } },
|
|
53
|
+
{ op: 'set', collection: 'orders', id: 'x', data: { total: 20 } },
|
|
54
|
+
{ op: 'update', collection: 'orders', id: 'y', data: { total: 30 } },
|
|
55
|
+
{ op: 'remove', collection: 'orders', id: 'z' },
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
// depois (2.1.1)
|
|
59
|
+
col.batch([
|
|
60
|
+
{ kind: 'add', data: { total: 10 } },
|
|
61
|
+
{ kind: 'set', id: 'x', data: { total: 20 } },
|
|
62
|
+
{ kind: 'update', id: 'y', data: { total: 30 } },
|
|
63
|
+
{ kind: 'remove', id: 'z' },
|
|
64
|
+
]);
|
|
65
|
+
```
|
|
66
|
+
|
|
15
67
|
## [2.0.0] - 2026-05-22 — **client.db NeetruDb (Documentos engine-aware + SQL) [M2]**
|
|
16
68
|
|
|
17
69
|
Major bump — breaking changes no namespace `db`. Liga todos os building blocks M2 na superfície pública.
|
package/dist/auth.cjs
CHANGED
|
@@ -2956,10 +2956,9 @@ var DbCollectionRefImpl = class {
|
|
|
2956
2956
|
const batchId = `batch-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
2957
2957
|
const busChanges = [];
|
|
2958
2958
|
for (const op of ops) {
|
|
2959
|
-
const
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
if (op.op === "add") {
|
|
2959
|
+
const collection = this._collection;
|
|
2960
|
+
if (op.kind === "add") {
|
|
2961
|
+
const data = op.data;
|
|
2963
2962
|
const mutation = await this._queue.enqueue({
|
|
2964
2963
|
collection,
|
|
2965
2964
|
op: "add",
|
|
@@ -2983,7 +2982,9 @@ var DbCollectionRefImpl = class {
|
|
|
2983
2982
|
}
|
|
2984
2983
|
});
|
|
2985
2984
|
busChanges.push({ type: "added", collection, doc: { id: docId, data } });
|
|
2986
|
-
} else if (op.
|
|
2985
|
+
} else if (op.kind === "set") {
|
|
2986
|
+
const id = op.id;
|
|
2987
|
+
const data = op.data;
|
|
2987
2988
|
const existing = await this._store.getDoc(collection, id);
|
|
2988
2989
|
const mutation = await this._queue.enqueue({
|
|
2989
2990
|
collection,
|
|
@@ -3012,7 +3013,9 @@ var DbCollectionRefImpl = class {
|
|
|
3012
3013
|
collection,
|
|
3013
3014
|
doc: { id, data }
|
|
3014
3015
|
});
|
|
3015
|
-
} else if (op.
|
|
3016
|
+
} else if (op.kind === "update") {
|
|
3017
|
+
const id = op.id;
|
|
3018
|
+
const data = op.data;
|
|
3016
3019
|
const existing = await this._store.getDoc(collection, id);
|
|
3017
3020
|
const merged = { ...existing?.data ?? {}, ...data };
|
|
3018
3021
|
const mutation = await this._queue.enqueue({
|
|
@@ -3041,7 +3044,8 @@ var DbCollectionRefImpl = class {
|
|
|
3041
3044
|
}
|
|
3042
3045
|
});
|
|
3043
3046
|
busChanges.push({ type: "modified", collection, doc: { id, data: merged } });
|
|
3044
|
-
} else if (op.
|
|
3047
|
+
} else if (op.kind === "remove") {
|
|
3048
|
+
const id = op.id;
|
|
3045
3049
|
const existing = await this._store.getDoc(collection, id);
|
|
3046
3050
|
await this._queue.enqueue({
|
|
3047
3051
|
collection,
|
|
@@ -3150,6 +3154,15 @@ var DbCollectionRefImpl = class {
|
|
|
3150
3154
|
assertValidId(id);
|
|
3151
3155
|
const self = this;
|
|
3152
3156
|
return {
|
|
3157
|
+
get id() {
|
|
3158
|
+
return id;
|
|
3159
|
+
},
|
|
3160
|
+
get path() {
|
|
3161
|
+
return `${self._collection}/${id}`;
|
|
3162
|
+
},
|
|
3163
|
+
get collection() {
|
|
3164
|
+
return self._collection;
|
|
3165
|
+
},
|
|
3153
3166
|
async get() {
|
|
3154
3167
|
return self._buildGetResult(id);
|
|
3155
3168
|
},
|
|
@@ -4283,6 +4296,15 @@ function createLazyCollectionRef(name, getDocsPromise) {
|
|
|
4283
4296
|
},
|
|
4284
4297
|
doc(id) {
|
|
4285
4298
|
return {
|
|
4299
|
+
get id() {
|
|
4300
|
+
return id;
|
|
4301
|
+
},
|
|
4302
|
+
get path() {
|
|
4303
|
+
return `${name}/${id}`;
|
|
4304
|
+
},
|
|
4305
|
+
get collection() {
|
|
4306
|
+
return name;
|
|
4307
|
+
},
|
|
4286
4308
|
async get() {
|
|
4287
4309
|
return (await getRef()).doc(id).get();
|
|
4288
4310
|
},
|