@roko-app/instant-admin 0.0.0-stage → 1.0.67-roko.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/.tshy/build.json +8 -0
- package/.tshy/commonjs.json +16 -0
- package/.tshy/esm.json +15 -0
- package/LICENSE +202 -0
- package/README.md +43 -2
- package/dist/commonjs/__types__/typeUtils.d.ts +20 -0
- package/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/dist/commonjs/__types__/typeUtils.js +5 -0
- package/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/dist/commonjs/__types__/typesTests.d.ts +2 -0
- package/dist/commonjs/__types__/typesTests.d.ts.map +1 -0
- package/dist/commonjs/__types__/typesTests.js +88 -0
- package/dist/commonjs/__types__/typesTests.js.map +1 -0
- package/dist/commonjs/index.d.ts +608 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +1050 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/polyfill.d.ts +17 -0
- package/dist/commonjs/polyfill.d.ts.map +1 -0
- package/dist/commonjs/polyfill.js +26 -0
- package/dist/commonjs/polyfill.js.map +1 -0
- package/dist/commonjs/subscribe.d.ts +39 -0
- package/dist/commonjs/subscribe.d.ts.map +1 -0
- package/dist/commonjs/subscribe.js +306 -0
- package/dist/commonjs/subscribe.js.map +1 -0
- package/dist/commonjs/version.d.ts +3 -0
- package/dist/commonjs/version.d.ts.map +1 -0
- package/dist/commonjs/version.js +5 -0
- package/dist/commonjs/version.js.map +1 -0
- package/dist/esm/__types__/typeUtils.d.ts +20 -0
- package/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/dist/esm/__types__/typeUtils.js +4 -0
- package/dist/esm/__types__/typeUtils.js.map +1 -0
- package/dist/esm/__types__/typesTests.d.ts +2 -0
- package/dist/esm/__types__/typesTests.d.ts.map +1 -0
- package/dist/esm/__types__/typesTests.js +86 -0
- package/dist/esm/__types__/typesTests.js.map +1 -0
- package/dist/esm/index.d.ts +608 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +1037 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/polyfill.d.ts +17 -0
- package/dist/esm/polyfill.d.ts.map +1 -0
- package/dist/esm/polyfill.js +22 -0
- package/dist/esm/polyfill.js.map +1 -0
- package/dist/esm/subscribe.d.ts +39 -0
- package/dist/esm/subscribe.d.ts.map +1 -0
- package/dist/esm/subscribe.js +300 -0
- package/dist/esm/subscribe.js.map +1 -0
- package/dist/esm/version.d.ts +3 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +44 -3
- package/src/__types__/typeUtils.ts +39 -0
- package/src/__types__/typesTests.ts +139 -0
- package/src/index.ts +1731 -0
- package/src/polyfill.ts +39 -0
- package/src/subscribe.ts +442 -0
- package/src/version.ts +3 -0
- package/tsconfig.dev.json +14 -0
- package/tsconfig.json +11 -0
- package/tsconfig.test.json +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,eAAe,OAAO,CAAC","sourcesContent":["import { version } from '@instantdb/version';\n\nexport default version;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roko-app/instant-admin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.67-roko.1",
|
|
4
|
+
"description": "Admin SDK for Instant DB (Roko DB build of @instantdb/admin)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"homepage": "https://github.com/ErionTp/roko-db",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ErionTp/roko-db.git"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/commonjs/index.js",
|
|
13
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
14
|
+
"module": "./dist/esm/index.js",
|
|
15
|
+
"unpkg": "standalone/index.umd.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
".": {
|
|
19
|
+
"import": {
|
|
20
|
+
"types": "./dist/esm/index.d.ts",
|
|
21
|
+
"default": "./dist/esm/index.js"
|
|
22
|
+
},
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
25
|
+
"default": "./dist/commonjs/index.js"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"tshy": {
|
|
30
|
+
"selfLink": false,
|
|
31
|
+
"main": true,
|
|
32
|
+
"module": true,
|
|
33
|
+
"project": "./tsconfig.json",
|
|
34
|
+
"exports": {
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
".": "./src/index.ts"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@instantdb/core": "npm:@roko-app/instant-core@1.0.67-roko.1",
|
|
41
|
+
"@instantdb/version": "npm:@roko-app/instant-version@1.0.67-roko.1",
|
|
42
|
+
"@instantdb/webhooks": "npm:@roko-app/instant-webhooks@1.0.67-roko.1",
|
|
43
|
+
"cookie": "^1.1.1",
|
|
44
|
+
"@instantdb/eventsource": "4.1.0-2",
|
|
45
|
+
"uuid": "^11.1.0"
|
|
46
|
+
}
|
|
6
47
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Type testing utils from
|
|
2
|
+
// https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
|
|
3
|
+
|
|
4
|
+
export type Expect<T extends true> = T;
|
|
5
|
+
export type ExpectTrue<T extends true> = T;
|
|
6
|
+
export type ExpectFalse<T extends false> = T;
|
|
7
|
+
export type IsTrue<T extends true> = T;
|
|
8
|
+
export type IsFalse<T extends false> = T;
|
|
9
|
+
|
|
10
|
+
export type Equal<X, Y> =
|
|
11
|
+
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
|
12
|
+
? true
|
|
13
|
+
: false;
|
|
14
|
+
export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
|
|
15
|
+
|
|
16
|
+
// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
|
|
17
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
18
|
+
export type NotAny<T> = true extends IsAny<T> ? false : true;
|
|
19
|
+
|
|
20
|
+
export type Debug<T> = { [K in keyof T]: T[K] };
|
|
21
|
+
export type MergeInsertions<T> = T extends object
|
|
22
|
+
? { [K in keyof T]: MergeInsertions<T[K]> }
|
|
23
|
+
: T;
|
|
24
|
+
|
|
25
|
+
export type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
|
|
26
|
+
|
|
27
|
+
export type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE
|
|
28
|
+
? true
|
|
29
|
+
: false;
|
|
30
|
+
export type ExpectValidArgs<
|
|
31
|
+
FUNC extends (...args: any[]) => any,
|
|
32
|
+
ARGS extends any[],
|
|
33
|
+
> = ARGS extends Parameters<FUNC> ? true : false;
|
|
34
|
+
|
|
35
|
+
export type UnionToIntersection<U> = (
|
|
36
|
+
U extends any ? (k: U) => void : never
|
|
37
|
+
) extends (k: infer I) => void
|
|
38
|
+
? I
|
|
39
|
+
: never;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { Equal, Expect, IsAny, NotAny } from './typeUtils.ts';
|
|
2
|
+
import { i, init } from '../index.ts';
|
|
3
|
+
|
|
4
|
+
const schema = i.schema({
|
|
5
|
+
entities: {
|
|
6
|
+
tbl: i.entity({
|
|
7
|
+
d: i.date().indexed(),
|
|
8
|
+
dOptional: i.date().optional(),
|
|
9
|
+
}),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
async function _testUseDatesTest() {
|
|
14
|
+
const db = init({
|
|
15
|
+
schema,
|
|
16
|
+
appId: '123',
|
|
17
|
+
useDateObjects: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const data = await db.query({ tbl: {} });
|
|
21
|
+
const item = data?.tbl[0];
|
|
22
|
+
if (item) {
|
|
23
|
+
type t = typeof item.d;
|
|
24
|
+
type _cases = [Expect<NotAny<t>>, Expect<Equal<t, Date>>];
|
|
25
|
+
|
|
26
|
+
type tOpt = typeof item.dOptional;
|
|
27
|
+
type _cases_2 = [
|
|
28
|
+
Expect<NotAny<tOpt>>,
|
|
29
|
+
Expect<Equal<tOpt, Date | undefined>>,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function _testUseDatesFalseTest() {
|
|
35
|
+
const db = init({
|
|
36
|
+
schema,
|
|
37
|
+
appId: '123',
|
|
38
|
+
useDateObjects: false,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const data = await db.query({ tbl: {} });
|
|
42
|
+
const item = data?.tbl[0];
|
|
43
|
+
if (item) {
|
|
44
|
+
type t = typeof item.d;
|
|
45
|
+
type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];
|
|
46
|
+
|
|
47
|
+
type tOpt = typeof item.dOptional;
|
|
48
|
+
type _cases_2 = [
|
|
49
|
+
Expect<NotAny<tOpt>>,
|
|
50
|
+
Expect<Equal<tOpt, string | number | undefined>>,
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function _testUseDatesUndefinedTest() {
|
|
56
|
+
const db = init({
|
|
57
|
+
schema,
|
|
58
|
+
appId: '123',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const data = await db.query({ tbl: {} });
|
|
62
|
+
const item = data?.tbl[0];
|
|
63
|
+
if (item) {
|
|
64
|
+
type t = typeof item.d;
|
|
65
|
+
type _cases = [Expect<NotAny<t>>, Expect<Equal<t, string | number>>];
|
|
66
|
+
|
|
67
|
+
type tOpt = typeof item.dOptional;
|
|
68
|
+
type _cases_2 = [
|
|
69
|
+
Expect<NotAny<tOpt>>,
|
|
70
|
+
Expect<Equal<tOpt, string | number | undefined>>,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function _testDataNoSchema() {
|
|
76
|
+
const db = init({
|
|
77
|
+
appId: '123',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const data = await db.query({ tbl: {} });
|
|
81
|
+
const item = data?.tbl[0];
|
|
82
|
+
if (item) {
|
|
83
|
+
type t = typeof item.d;
|
|
84
|
+
type _cases = [Expect<IsAny<t>>, Expect<Equal<typeof item.id, string>>];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function _testSubscribe() {
|
|
89
|
+
// No useDateObjects
|
|
90
|
+
init({
|
|
91
|
+
appId: '123',
|
|
92
|
+
schema,
|
|
93
|
+
}).subscribeQuery({ tbl: {} }, (payload) => {
|
|
94
|
+
if (payload.type === 'ok') {
|
|
95
|
+
const item = payload.data.tbl[0];
|
|
96
|
+
if (item) {
|
|
97
|
+
type _cases = [
|
|
98
|
+
Expect<Equal<typeof item.id, string>>,
|
|
99
|
+
Expect<Equal<typeof item.d, string | number>>,
|
|
100
|
+
Expect<Equal<typeof item.dOptional, string | number | undefined>>,
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// UseDateObjects
|
|
107
|
+
init({
|
|
108
|
+
appId: '123',
|
|
109
|
+
schema,
|
|
110
|
+
useDateObjects: true,
|
|
111
|
+
}).subscribeQuery({ tbl: {} }, (payload) => {
|
|
112
|
+
if (payload.type === 'ok') {
|
|
113
|
+
const item = payload.data.tbl[0];
|
|
114
|
+
if (item) {
|
|
115
|
+
type _cases = [
|
|
116
|
+
Expect<Equal<typeof item.id, string>>,
|
|
117
|
+
Expect<Equal<typeof item.d, Date>>,
|
|
118
|
+
Expect<Equal<typeof item.dOptional, Date | undefined>>,
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// No schema
|
|
125
|
+
init({
|
|
126
|
+
appId: '123',
|
|
127
|
+
}).subscribeQuery({ tbl: {} }, (payload) => {
|
|
128
|
+
if (payload.type === 'ok') {
|
|
129
|
+
const item = payload.data.tbl[0];
|
|
130
|
+
if (item) {
|
|
131
|
+
type _cases = [
|
|
132
|
+
Expect<Equal<typeof item.id, string>>,
|
|
133
|
+
Expect<IsAny<typeof item.d>>,
|
|
134
|
+
Expect<IsAny<typeof item.dOptional>>,
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|