@firebase/database-compat 0.1.1-2021823172527 → 0.1.2-canary.0b3ca78eb

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 (61) hide show
  1. package/CHANGELOG.md +19 -8
  2. package/dist/database-compat/src/index.d.ts +0 -9
  3. package/dist/database-compat/src/index.node.d.ts +0 -53
  4. package/dist/database-compat/src/index.standalone.d.ts +52 -0
  5. package/dist/index.esm2017.js +5 -6
  6. package/dist/index.esm2017.js.map +1 -1
  7. package/dist/index.esm5.js +2 -3
  8. package/dist/index.esm5.js.map +1 -1
  9. package/dist/index.js +10 -77
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.standalone.js +15150 -0
  12. package/dist/index.standalone.js.map +1 -0
  13. package/dist/node-esm/database-compat/src/api/Database.d.ts +72 -0
  14. package/dist/node-esm/database-compat/src/api/Reference.d.ts +201 -0
  15. package/{karma.conf.js → dist/node-esm/database-compat/src/api/TransactionResult.d.ts} +26 -34
  16. package/dist/node-esm/database-compat/src/api/internal.d.ts +39 -0
  17. package/dist/node-esm/database-compat/src/api/onDisconnect.d.ts +27 -0
  18. package/dist/node-esm/database-compat/src/index.d.ts +32 -0
  19. package/dist/node-esm/database-compat/src/index.node.d.ts +14 -0
  20. package/dist/node-esm/database-compat/src/index.standalone.d.ts +52 -0
  21. package/{src/util/util.ts → dist/node-esm/database-compat/src/util/util.d.ts} +17 -25
  22. package/dist/node-esm/database-compat/src/util/validation.d.ts +18 -0
  23. package/{src/api/TransactionResult.ts → dist/node-esm/database-compat/test/browser/crawler_support.test.d.ts} +17 -34
  24. package/dist/node-esm/database-compat/test/database.test.d.ts +17 -0
  25. package/dist/node-esm/database-compat/test/datasnapshot.test.d.ts +17 -0
  26. package/dist/node-esm/database-compat/test/helpers/events.d.ts +34 -0
  27. package/dist/node-esm/database-compat/test/helpers/util.d.ts +42 -0
  28. package/dist/node-esm/database-compat/test/info.test.d.ts +17 -0
  29. package/dist/node-esm/database-compat/test/order.test.d.ts +17 -0
  30. package/dist/node-esm/database-compat/test/order_by.test.d.ts +17 -0
  31. package/dist/node-esm/database-compat/test/promise.test.d.ts +17 -0
  32. package/dist/node-esm/database-compat/test/query.test.d.ts +17 -0
  33. package/dist/node-esm/database-compat/test/servervalues.test.d.ts +17 -0
  34. package/dist/node-esm/database-compat/test/transaction.test.d.ts +17 -0
  35. package/dist/node-esm/index.js +868 -0
  36. package/dist/node-esm/index.js.map +1 -0
  37. package/dist/node-esm/package.json +1 -0
  38. package/package.json +34 -9
  39. package/standalone/package.json +7 -0
  40. package/.eslintrc.js +0 -64
  41. package/rollup.config.js +0 -125
  42. package/src/api/Database.ts +0 -123
  43. package/src/api/Reference.ts +0 -790
  44. package/src/api/internal.ts +0 -91
  45. package/src/api/onDisconnect.ts +0 -112
  46. package/src/index.node.ts +0 -142
  47. package/src/index.ts +0 -88
  48. package/src/util/validation.ts +0 -59
  49. package/test/browser/crawler_support.test.ts +0 -206
  50. package/test/database.test.ts +0 -306
  51. package/test/datasnapshot.test.ts +0 -249
  52. package/test/helpers/events.ts +0 -258
  53. package/test/helpers/util.ts +0 -177
  54. package/test/info.test.ts +0 -222
  55. package/test/order.test.ts +0 -592
  56. package/test/order_by.test.ts +0 -530
  57. package/test/promise.test.ts +0 -261
  58. package/test/query.test.ts +0 -4670
  59. package/test/servervalues.test.ts +0 -152
  60. package/test/transaction.test.ts +0 -1534
  61. package/tsconfig.json +0 -11
@@ -1,152 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- import { expect } from 'chai';
19
-
20
- import { Database } from '../src/api/Database';
21
- import { Reference } from '../src/api/Reference';
22
-
23
- import { getRandomNode } from './helpers/util';
24
-
25
- describe('ServerValue tests', () => {
26
- it('resolves timestamps locally', async () => {
27
- const node = getRandomNode() as Reference;
28
- const start = Date.now();
29
- const values: number[] = [];
30
- node.on('value', snap => {
31
- expect(typeof snap.val()).to.equal('number');
32
- values.push(snap.val() as number);
33
- });
34
- await node.set(Database.ServerValue.TIMESTAMP);
35
- node.off('value');
36
-
37
- // By the time the write is acknowledged, we should have a local and
38
- // server version of the timestamp.
39
- expect(values.length).to.equal(2);
40
- values.forEach(serverTime => {
41
- const delta = Math.abs(serverTime - start);
42
- expect(delta).to.be.lessThan(1000);
43
- });
44
- });
45
-
46
- it('handles increments without listeners', async () => {
47
- // Ensure that increments don't explode when the SyncTree must return a null
48
- // node (i.e. ChildrenNode.EMPTY_NODE) because there is not yet any synced
49
- // data.
50
- const node = getRandomNode() as Reference;
51
- await node.set(Database.ServerValue.increment(1));
52
- });
53
-
54
- describe('handles increments', () => {
55
- for (const mode of ['offline', 'online']) {
56
- const maybeAwait = async (p: Promise<any>) => {
57
- if (mode === 'online') {
58
- await p;
59
- }
60
- };
61
-
62
- it(mode, async () => {
63
- const node = getRandomNode() as Reference;
64
- if (mode === 'offline') {
65
- node.database.goOffline();
66
- }
67
-
68
- const addOne = Database.ServerValue.increment(1);
69
-
70
- const values: any = [];
71
- const expected: any = [];
72
- node.on('value', snap => values.push(snap.val()));
73
-
74
- // null -> increment(x) = x
75
- maybeAwait(node.set(addOne));
76
- expected.push(1);
77
-
78
- // x -> increment(y) = x + y
79
- maybeAwait(node.set(5));
80
- maybeAwait(node.set(addOne));
81
- expected.push(5);
82
- expected.push(6);
83
-
84
- // str -> increment(x) = x
85
- maybeAwait(node.set('hello'));
86
- maybeAwait(node.set(addOne));
87
- expected.push('hello');
88
- expected.push(1);
89
-
90
- // obj -> increment(x) = x
91
- maybeAwait(node.set({ 'hello': 'world' }));
92
- maybeAwait(node.set(addOne));
93
- expected.push({ 'hello': 'world' });
94
- expected.push(1);
95
-
96
- node.off('value');
97
- expect(values).to.deep.equal(expected);
98
- node.database.goOnline();
99
- });
100
- }
101
- });
102
-
103
- it('handles sparse updates', async () => {
104
- const node = getRandomNode() as Reference;
105
-
106
- let value: any = null;
107
- let events = 0;
108
- node.on('value', snap => {
109
- value = snap.val();
110
- events++;
111
- });
112
-
113
- await node.update({
114
- 'child/increment': Database.ServerValue.increment(1),
115
- 'literal': 5
116
- });
117
- expect(value).to.deep.equal({
118
- 'literal': 5,
119
- 'child': {
120
- 'increment': 1
121
- }
122
- });
123
-
124
- await node.update({
125
- 'child/increment': Database.ServerValue.increment(41)
126
- });
127
- expect(value).to.deep.equal({
128
- 'literal': 5,
129
- 'child': {
130
- 'increment': 42
131
- }
132
- });
133
-
134
- node.off('value');
135
-
136
- expect(events).to.equal(2);
137
- });
138
-
139
- it('handles races', async () => {
140
- const node = getRandomNode() as Reference;
141
- const all: Array<Promise<any>> = [];
142
- const racers = 100;
143
-
144
- for (let i = 0; i < racers; i++) {
145
- all.push(node.set(Database.ServerValue.increment(1)));
146
- }
147
- await Promise.all(all);
148
-
149
- const snap = await node.once('value');
150
- expect(snap.val()).to.equal(racers);
151
- });
152
- });