@instantdb/admin 0.22.96-experimental.drewh-ts-target.20761590091.1 → 0.22.96-experimental.surgical.20765334274.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/dist/commonjs/__types__/typesTests.js +82 -63
- package/dist/commonjs/__types__/typesTests.js.map +1 -1
- package/dist/commonjs/index.js +453 -472
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/subscribe.js +19 -17
- package/dist/commonjs/subscribe.js.map +1 -1
- package/dist/esm/__types__/typesTests.js +82 -63
- package/dist/esm/__types__/typesTests.js.map +1 -1
- package/dist/esm/index.js +453 -472
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/subscribe.js +19 -17
- package/dist/esm/subscribe.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
const index_ts_1 = require("../index.js");
|
|
4
13
|
const schema = index_ts_1.i.schema({
|
|
@@ -9,80 +18,90 @@ const schema = index_ts_1.i.schema({
|
|
|
9
18
|
}),
|
|
10
19
|
},
|
|
11
20
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
function _testUseDatesTest() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const db = (0, index_ts_1.init)({
|
|
24
|
+
schema,
|
|
25
|
+
appId: '123',
|
|
26
|
+
useDateObjects: true,
|
|
27
|
+
});
|
|
28
|
+
const data = yield db.query({ tbl: {} });
|
|
29
|
+
const item = data === null || data === void 0 ? void 0 : data.tbl[0];
|
|
30
|
+
if (item) {
|
|
31
|
+
}
|
|
17
32
|
});
|
|
18
|
-
const data = await db.query({ tbl: {} });
|
|
19
|
-
const item = data?.tbl[0];
|
|
20
|
-
if (item) {
|
|
21
|
-
}
|
|
22
33
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
function _testUseDatesFalseTest() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const db = (0, index_ts_1.init)({
|
|
37
|
+
schema,
|
|
38
|
+
appId: '123',
|
|
39
|
+
useDateObjects: false,
|
|
40
|
+
});
|
|
41
|
+
const data = yield db.query({ tbl: {} });
|
|
42
|
+
const item = data === null || data === void 0 ? void 0 : data.tbl[0];
|
|
43
|
+
if (item) {
|
|
44
|
+
}
|
|
28
45
|
});
|
|
29
|
-
const data = await db.query({ tbl: {} });
|
|
30
|
-
const item = data?.tbl[0];
|
|
31
|
-
if (item) {
|
|
32
|
-
}
|
|
33
46
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
function _testUseDatesUndefinedTest() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const db = (0, index_ts_1.init)({
|
|
50
|
+
schema,
|
|
51
|
+
appId: '123',
|
|
52
|
+
});
|
|
53
|
+
const data = yield db.query({ tbl: {} });
|
|
54
|
+
const item = data === null || data === void 0 ? void 0 : data.tbl[0];
|
|
55
|
+
if (item) {
|
|
56
|
+
}
|
|
38
57
|
});
|
|
39
|
-
const data = await db.query({ tbl: {} });
|
|
40
|
-
const item = data?.tbl[0];
|
|
41
|
-
if (item) {
|
|
42
|
-
}
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
function _testDataNoSchema() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const db = (0, index_ts_1.init)({
|
|
62
|
+
appId: '123',
|
|
63
|
+
});
|
|
64
|
+
const data = yield db.query({ tbl: {} });
|
|
65
|
+
const item = data === null || data === void 0 ? void 0 : data.tbl[0];
|
|
66
|
+
if (item) {
|
|
67
|
+
}
|
|
47
68
|
});
|
|
48
|
-
const data = await db.query({ tbl: {} });
|
|
49
|
-
const item = data?.tbl[0];
|
|
50
|
-
if (item) {
|
|
51
|
-
}
|
|
52
69
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
function _testSubscribe() {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
// No useDateObjects
|
|
73
|
+
(0, index_ts_1.init)({
|
|
74
|
+
appId: '123',
|
|
75
|
+
schema,
|
|
76
|
+
}).subscribeQuery({ tbl: {} }, (payload) => {
|
|
77
|
+
if (payload.type === 'ok') {
|
|
78
|
+
const item = payload.data.tbl[0];
|
|
79
|
+
if (item) {
|
|
80
|
+
}
|
|
62
81
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
});
|
|
83
|
+
// UseDateObjects
|
|
84
|
+
(0, index_ts_1.init)({
|
|
85
|
+
appId: '123',
|
|
86
|
+
schema,
|
|
87
|
+
useDateObjects: true,
|
|
88
|
+
}).subscribeQuery({ tbl: {} }, (payload) => {
|
|
89
|
+
if (payload.type === 'ok') {
|
|
90
|
+
const item = payload.data.tbl[0];
|
|
91
|
+
if (item) {
|
|
92
|
+
}
|
|
74
93
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
});
|
|
95
|
+
// No schema
|
|
96
|
+
(0, index_ts_1.init)({
|
|
97
|
+
appId: '123',
|
|
98
|
+
}).subscribeQuery({ tbl: {} }, (payload) => {
|
|
99
|
+
if (payload.type === 'ok') {
|
|
100
|
+
const item = payload.data.tbl[0];
|
|
101
|
+
if (item) {
|
|
102
|
+
}
|
|
84
103
|
}
|
|
85
|
-
}
|
|
104
|
+
});
|
|
86
105
|
});
|
|
87
106
|
}
|
|
88
107
|
//# sourceMappingURL=typesTests.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesTests.js","sourceRoot":"","sources":["../../../src/__types__/typesTests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"typesTests.js","sourceRoot":"","sources":["../../../src/__types__/typesTests.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,0CAAsC;AAEtC,MAAM,MAAM,GAAG,YAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE;QACR,GAAG,EAAE,YAAC,CAAC,MAAM,CAAC;YACZ,CAAC,EAAE,YAAC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE;YACrB,SAAS,EAAE,YAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;SAC/B,CAAC;KACH;CACF,CAAC,CAAC;AAEH,SAAe,iBAAiB;;QAC9B,MAAM,EAAE,GAAG,IAAA,eAAI,EAAC;YACd,MAAM;YACN,KAAK,EAAE,KAAK;YACZ,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;QACz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Utils.ts';\nimport { i, init } from '../index.ts';\n\nconst schema = i.schema({\n entities: {\n tbl: i.entity({\n d: i.date().indexed(),\n dOptional: i.date().optional(),\n }),\n },\n});\n\nasync function _testUseDatesTest() {\n const db = init({\n schema,\n appId: '123',\n useDateObjects: true,\n });\n\n const data = await db.query({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, Date>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, Date | undefined>>,\n ];\n }\n}\n\nasync function _testUseDatesFalseTest() {\n const db = init({\n schema,\n appId: '123',\n useDateObjects: false,\n });\n\n const data = await db.query({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, string | number | undefined>>,\n ];\n }\n}\n\nasync function _testUseDatesUndefinedTest() {\n const db = init({\n schema,\n appId: '123',\n });\n\n const data = await db.query({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];\n\n type tOpt = typeof item.dOptional;\n type _cases_2 = [\n Expect<NotAny<tOpt>>,\n Expect<Equal<tOpt, string | number | undefined>>,\n ];\n }\n}\n\nasync function _testDataNoSchema() {\n const db = init({\n appId: '123',\n });\n\n const data = await db.query({ tbl: {} });\n const item = data?.tbl[0];\n if (item) {\n type t = typeof item.d;\n type _cases = [Expect<IsAny<t>>, Expect<Equal<typeof item.id, string>>];\n }\n}\n\nasync function _testSubscribe() {\n // No useDateObjects\n init({\n appId: '123',\n schema,\n }).subscribeQuery({ tbl: {} }, (payload) => {\n if (payload.type === 'ok') {\n const item = payload.data.tbl[0];\n if (item) {\n type _cases = [\n Expect<Equal<typeof item.id, string>>,\n Expect<Equal<typeof item.d, string | number>>,\n Expect<Equal<typeof item.dOptional, string | number | undefined>>,\n ];\n }\n }\n });\n\n // UseDateObjects\n init({\n appId: '123',\n schema,\n useDateObjects: true,\n }).subscribeQuery({ tbl: {} }, (payload) => {\n if (payload.type === 'ok') {\n const item = payload.data.tbl[0];\n if (item) {\n type _cases = [\n Expect<Equal<typeof item.id, string>>,\n Expect<Equal<typeof item.d, Date>>,\n Expect<Equal<typeof item.dOptional, Date | undefined>>,\n ];\n }\n }\n });\n\n // No schema\n init({\n appId: '123',\n }).subscribeQuery({ tbl: {} }, (payload) => {\n if (payload.type === 'ok') {\n const item = payload.data.tbl[0];\n if (item) {\n type _cases = [\n Expect<Equal<typeof item.id, string>>,\n Expect<IsAny<typeof item.d>>,\n Expect<IsAny<typeof item.dOptional>>,\n ];\n }\n }\n });\n}\n"]}
|