@voidhash/mimic-sdk 1.0.0-beta.18
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/LICENSE.md +663 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +19 -0
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/effect/CollectionHandle.cjs +93 -0
- package/dist/effect/CollectionHandle.d.cts +31 -0
- package/dist/effect/CollectionHandle.d.cts.map +1 -0
- package/dist/effect/CollectionHandle.d.mts +31 -0
- package/dist/effect/CollectionHandle.d.mts.map +1 -0
- package/dist/effect/CollectionHandle.mjs +94 -0
- package/dist/effect/CollectionHandle.mjs.map +1 -0
- package/dist/effect/DatabaseHandle.cjs +61 -0
- package/dist/effect/DatabaseHandle.d.cts +25 -0
- package/dist/effect/DatabaseHandle.d.cts.map +1 -0
- package/dist/effect/DatabaseHandle.d.mts +25 -0
- package/dist/effect/DatabaseHandle.d.mts.map +1 -0
- package/dist/effect/DatabaseHandle.mjs +62 -0
- package/dist/effect/DatabaseHandle.mjs.map +1 -0
- package/dist/effect/HttpTransport.cjs +18 -0
- package/dist/effect/HttpTransport.d.cts +15 -0
- package/dist/effect/HttpTransport.d.cts.map +1 -0
- package/dist/effect/HttpTransport.d.mts +15 -0
- package/dist/effect/HttpTransport.d.mts.map +1 -0
- package/dist/effect/HttpTransport.mjs +19 -0
- package/dist/effect/HttpTransport.mjs.map +1 -0
- package/dist/effect/MimicSDK.cjs +84 -0
- package/dist/effect/MimicSDK.d.cts +40 -0
- package/dist/effect/MimicSDK.d.cts.map +1 -0
- package/dist/effect/MimicSDK.d.mts +40 -0
- package/dist/effect/MimicSDK.d.mts.map +1 -0
- package/dist/effect/MimicSDK.mjs +71 -0
- package/dist/effect/MimicSDK.mjs.map +1 -0
- package/dist/effect/errors.cjs +7 -0
- package/dist/effect/errors.d.cts +15 -0
- package/dist/effect/errors.d.cts.map +1 -0
- package/dist/effect/errors.d.mts +15 -0
- package/dist/effect/errors.d.mts.map +1 -0
- package/dist/effect/errors.mjs +8 -0
- package/dist/effect/errors.mjs.map +1 -0
- package/dist/effect/index.cjs +35 -0
- package/dist/effect/index.d.cts +8 -0
- package/dist/effect/index.d.mts +8 -0
- package/dist/effect/index.mjs +8 -0
- package/dist/effect/types.d.cts +34 -0
- package/dist/effect/types.d.cts.map +1 -0
- package/dist/effect/types.d.mts +34 -0
- package/dist/effect/types.d.mts.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +5 -0
- package/dist/promise/CollectionHandle.cjs +49 -0
- package/dist/promise/CollectionHandle.d.cts +32 -0
- package/dist/promise/CollectionHandle.d.cts.map +1 -0
- package/dist/promise/CollectionHandle.d.mts +32 -0
- package/dist/promise/CollectionHandle.d.mts.map +1 -0
- package/dist/promise/CollectionHandle.mjs +50 -0
- package/dist/promise/CollectionHandle.mjs.map +1 -0
- package/dist/promise/DatabaseHandle.cjs +38 -0
- package/dist/promise/DatabaseHandle.d.cts +22 -0
- package/dist/promise/DatabaseHandle.d.cts.map +1 -0
- package/dist/promise/DatabaseHandle.d.mts +22 -0
- package/dist/promise/DatabaseHandle.d.mts.map +1 -0
- package/dist/promise/DatabaseHandle.mjs +39 -0
- package/dist/promise/DatabaseHandle.mjs.map +1 -0
- package/dist/promise/MimicSDK.cjs +55 -0
- package/dist/promise/MimicSDK.d.cts +40 -0
- package/dist/promise/MimicSDK.d.cts.map +1 -0
- package/dist/promise/MimicSDK.d.mts +40 -0
- package/dist/promise/MimicSDK.d.mts.map +1 -0
- package/dist/promise/MimicSDK.mjs +56 -0
- package/dist/promise/MimicSDK.mjs.map +1 -0
- package/package.json +44 -0
- package/src/effect/CollectionHandle.ts +120 -0
- package/src/effect/DatabaseHandle.ts +76 -0
- package/src/effect/HttpTransport.ts +43 -0
- package/src/effect/MimicSDK.ts +118 -0
- package/src/effect/errors.ts +7 -0
- package/src/effect/index.ts +15 -0
- package/src/effect/types.ts +35 -0
- package/src/index.ts +12 -0
- package/src/promise/CollectionHandle.ts +67 -0
- package/src/promise/DatabaseHandle.ts +50 -0
- package/src/promise/MimicSDK.ts +69 -0
- package/src/promise/index.ts +3 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toPropertyKey } from "./toPropertyKey.mjs";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/defineProperty.js
|
|
4
|
+
function _defineProperty(e, r, t) {
|
|
5
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6
|
+
value: t,
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
configurable: !0,
|
|
9
|
+
writable: !0
|
|
10
|
+
}) : e[r] = t, e;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { _defineProperty };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_defineProperty = require('./defineProperty.cjs');
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
|
|
4
|
+
function ownKeys(e, r) {
|
|
5
|
+
var t = Object.keys(e);
|
|
6
|
+
if (Object.getOwnPropertySymbols) {
|
|
7
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
8
|
+
r && (o = o.filter(function(r$1) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
10
|
+
})), t.push.apply(t, o);
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function _objectSpread2(e) {
|
|
15
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
16
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
17
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
18
|
+
require_defineProperty._defineProperty(e, r$1, t[r$1]);
|
|
19
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
20
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports._objectSpread2 = _objectSpread2;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { _defineProperty } from "./defineProperty.mjs";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
|
|
4
|
+
function ownKeys(e, r) {
|
|
5
|
+
var t = Object.keys(e);
|
|
6
|
+
if (Object.getOwnPropertySymbols) {
|
|
7
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
8
|
+
r && (o = o.filter(function(r$1) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
10
|
+
})), t.push.apply(t, o);
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function _objectSpread2(e) {
|
|
15
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
16
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
17
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
18
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
19
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
20
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { _objectSpread2 };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_typeof = require('./typeof.cjs');
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/toPrimitive.js
|
|
4
|
+
function toPrimitive(t, r) {
|
|
5
|
+
if ("object" != require_typeof._typeof(t) || !t) return t;
|
|
6
|
+
var e = t[Symbol.toPrimitive];
|
|
7
|
+
if (void 0 !== e) {
|
|
8
|
+
var i = e.call(t, r || "default");
|
|
9
|
+
if ("object" != require_typeof._typeof(i)) return i;
|
|
10
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
11
|
+
}
|
|
12
|
+
return ("string" === r ? String : Number)(t);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.toPrimitive = toPrimitive;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.mjs";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/toPrimitive.js
|
|
4
|
+
function toPrimitive(t, r) {
|
|
5
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
6
|
+
var e = t[Symbol.toPrimitive];
|
|
7
|
+
if (void 0 !== e) {
|
|
8
|
+
var i = e.call(t, r || "default");
|
|
9
|
+
if ("object" != _typeof(i)) return i;
|
|
10
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
11
|
+
}
|
|
12
|
+
return ("string" === r ? String : Number)(t);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { toPrimitive };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_typeof = require('./typeof.cjs');
|
|
2
|
+
const require_toPrimitive = require('./toPrimitive.cjs');
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/toPropertyKey.js
|
|
5
|
+
function toPropertyKey(t) {
|
|
6
|
+
var i = require_toPrimitive.toPrimitive(t, "string");
|
|
7
|
+
return "symbol" == require_typeof._typeof(i) ? i : i + "";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.toPropertyKey = toPropertyKey;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.mjs";
|
|
2
|
+
import { toPrimitive } from "./toPrimitive.mjs";
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/toPropertyKey.js
|
|
5
|
+
function toPropertyKey(t) {
|
|
6
|
+
var i = toPrimitive(t, "string");
|
|
7
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { toPropertyKey };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/typeof.js
|
|
3
|
+
function _typeof(o) {
|
|
4
|
+
"@babel/helpers - typeof";
|
|
5
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
6
|
+
return typeof o$1;
|
|
7
|
+
} : function(o$1) {
|
|
8
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
9
|
+
}, _typeof(o);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, '_typeof', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _typeof;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
5
|
+
return typeof o$1;
|
|
6
|
+
} : function(o$1) {
|
|
7
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _typeof };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (all, symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
|
|
19
|
+
exports.__export = __export;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (all, symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __export };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const require_defineProperty = require('../_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs');
|
|
2
|
+
let effect = require("effect");
|
|
3
|
+
let effect_unstable_rpc = require("effect/unstable/rpc");
|
|
4
|
+
let _voidhash_mimic_protocol = require("@voidhash/mimic-protocol");
|
|
5
|
+
|
|
6
|
+
//#region src/effect/CollectionHandle.ts
|
|
7
|
+
const makeClient = () => effect_unstable_rpc.RpcClient.make(_voidhash_mimic_protocol.MimicRpcs);
|
|
8
|
+
var CollectionHandle = class {
|
|
9
|
+
constructor(id, databaseId, schema) {
|
|
10
|
+
require_defineProperty._defineProperty(this, "id", void 0);
|
|
11
|
+
require_defineProperty._defineProperty(this, "databaseId", void 0);
|
|
12
|
+
require_defineProperty._defineProperty(this, "schema", void 0);
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.databaseId = databaseId;
|
|
15
|
+
this.schema = schema;
|
|
16
|
+
}
|
|
17
|
+
create(data, options) {
|
|
18
|
+
const collectionId = this.id;
|
|
19
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
20
|
+
return yield* (yield* makeClient()).CreateDocument({
|
|
21
|
+
collectionId,
|
|
22
|
+
id: options === null || options === void 0 ? void 0 : options.id,
|
|
23
|
+
data
|
|
24
|
+
});
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
get(documentId) {
|
|
28
|
+
const collectionId = this.id;
|
|
29
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
30
|
+
return yield* (yield* makeClient()).GetDocument({
|
|
31
|
+
collectionId,
|
|
32
|
+
documentId
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
update(documentId, data) {
|
|
37
|
+
const collectionId = this.id;
|
|
38
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
39
|
+
const result = yield* (yield* makeClient()).UpdateDocument({
|
|
40
|
+
collectionId,
|
|
41
|
+
documentId,
|
|
42
|
+
data
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
id: result.id,
|
|
46
|
+
version: result.version
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
set(documentId, data) {
|
|
51
|
+
const collectionId = this.id;
|
|
52
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
53
|
+
const result = yield* (yield* makeClient()).SetDocument({
|
|
54
|
+
collectionId,
|
|
55
|
+
documentId,
|
|
56
|
+
data
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
id: result.id,
|
|
60
|
+
version: result.version
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
delete(documentId) {
|
|
65
|
+
const collectionId = this.id;
|
|
66
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
67
|
+
yield* (yield* makeClient()).DeleteDocument({
|
|
68
|
+
collectionId,
|
|
69
|
+
documentId
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
list() {
|
|
74
|
+
const collectionId = this.id;
|
|
75
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
76
|
+
return yield* (yield* makeClient()).ListDocuments({ collectionId });
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
createDocumentToken(documentId, permission, expiresInSeconds) {
|
|
80
|
+
const collectionId = this.id;
|
|
81
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
82
|
+
return { token: (yield* (yield* makeClient()).CreateDocumentToken({
|
|
83
|
+
collectionId,
|
|
84
|
+
documentId,
|
|
85
|
+
permission,
|
|
86
|
+
expiresInSeconds
|
|
87
|
+
})).token };
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.CollectionHandle = CollectionHandle;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CreatedDocumentToken, DocumentSnapshot } from "./types.cjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { RpcClient } from "effect/unstable/rpc";
|
|
4
|
+
import * as effect_unstable_rpc_RpcClientError0 from "effect/unstable/rpc/RpcClientError";
|
|
5
|
+
import { Primitive } from "@voidhash/mimic";
|
|
6
|
+
|
|
7
|
+
//#region src/effect/CollectionHandle.d.ts
|
|
8
|
+
declare class CollectionHandle<TSchema extends Primitive.AnyPrimitive> {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly databaseId: string;
|
|
11
|
+
readonly schema: TSchema;
|
|
12
|
+
constructor(id: string, databaseId: string, schema: TSchema);
|
|
13
|
+
create(data: Primitive.InferSetInput<TSchema>, options?: {
|
|
14
|
+
id?: string;
|
|
15
|
+
}): Effect.Effect<DocumentSnapshot<Primitive.InferState<TSchema>>, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
16
|
+
get(documentId: string): Effect.Effect<DocumentSnapshot<Primitive.InferState<TSchema>>, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
17
|
+
update(documentId: string, data: Primitive.InferUpdateInput<TSchema>): Effect.Effect<{
|
|
18
|
+
id: string;
|
|
19
|
+
version: number;
|
|
20
|
+
}, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
21
|
+
set(documentId: string, data: Primitive.InferSetInput<TSchema>): Effect.Effect<{
|
|
22
|
+
id: string;
|
|
23
|
+
version: number;
|
|
24
|
+
}, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
25
|
+
delete(documentId: string): Effect.Effect<void, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
26
|
+
list(): Effect.Effect<DocumentSnapshot<Primitive.InferState<TSchema>>[], string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
27
|
+
createDocumentToken(documentId: string, permission: "read" | "write", expiresInSeconds?: number): Effect.Effect<CreatedDocumentToken, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CollectionHandle };
|
|
31
|
+
//# sourceMappingURL=CollectionHandle.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionHandle.d.cts","names":[],"sources":["../../src/effect/CollectionHandle.ts"],"sourcesContent":[],"mappings":";;;;;;;cAQa,iCAAiC,SAAA,CAAU;;;EAA3C,SAAA,MAAA,EAGM,OAHU;EAAiB,WAAU,CAAA,EAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,MAAA,EAKF,OALE;EAGrC,MAAA,CAAA,IAAA,EAQJ,SAAA,CAAU,aARN,CAQoB,OARpB,CAAA,EAAA,OAQoB,CARpB,EAAA;IAEmC,EAAA,CAAA,EAAA,MAAA;EAMf,CAAA,CAAA,EAAmC,MAAA,CAAA,MAAnC,CAAmC,gBAAnC,CAAmC,SAAA,CAAA,UAAnC,CAAmC,OAAnC,CAAA,CAAA,EAAA,MAAA,GAAmC,mCAAA,CAAA,cAAnC,EAAmC,SAAA,CAAA,QAAnC,CAAA;EAAxB,GAAA,CAAA,UAAU,EAAA,MAAA,CAAA,EAeD,MAAA,CAAA,MAfC,CAeD,gBAfC,CAeD,SAAA,CAAA,UAfC,CAeD,OAfC,CAAA,CAAA,EAAA,MAAA,GAeD,mCAAA,CAAA,cAfC,EAeD,SAAA,CAAA,QAfC,CAAA;EAAiD,MAAA,CAAA,UAAA,EAAA,MAAA,EAAA,IAAA,EA6BvC,SAAA,CAAU,gBA7B6B,CA6BZ,OA7BY,CAAA,CAAA,EA6BJ,MAAA,CAAA,MA7BI,CAAA;IAAA,EAAA,EAAA,MAAA;IAAA,OAAA,EAAA,MAAA;EAAA,CAAA,EAAA,MAAA,GA6Bb,mCAAA,CAAA,cA7Ba,oBAAA,CAAA;EAAA,GAAA,CAAA,UAAA,EAAA,MAAA,EAAA,IAAA,EA4C1C,SAAA,CAAU,aA5CgC,CA4ClB,OA5CkB,CAAA,CAAA,EA4CV,MAAA,CAAA,MA5CU,CAAA;IAAA,EAAA,EAAA,MAAA;IAelD,OAAA,EAAA,MAAA;EAAA,CAAA,EAAA,MAAA,GA6B+B,mCAAA,CAAA,cA7B/B,oBAAA,CAAA;EAAA,MAAA,CAAA,UAAA,EAAA,MAAA,CAAA,EA4CG,MAAA,CAAA,MA5CH,CAAA,IAAA,EAAA,MAAA,GA6BwC,mCAAA,CAerC,cA5CH,EA4CG,SAAA,CAAA,QA5CH,CAAA;EAAA,IAAA,CAAA,CAAA,EAyDlB,MAAA,CAAA,MAzDkB,CAyDlB,gBAzDkB,CAyDlB,SAAA,CAAA,UAzDkB,CAyDlB,OAzDkB,CAAA,CAAA,EAAA,EAAA,MAAA,GAyDlB,mCAAA,CAAA,cAzDkB,EAyDlB,SAAA,CAAA,QAzDkB,CAAA;EAAA,mBAAA,CAAA,UAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,GAAA,OAAA,EAAA,gBAAA,CAAA,EAAA,MAAA,CAAA,EAsEyE,MAAA,CAAA,MAtEzE,CAsEyE,oBAtEzE,EAAA,MAAA,GAsEyE,mCAAA,CAAA,cAtEzE,EAsEyE,SAAA,CAAA,QAtEzE,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CreatedDocumentToken, DocumentSnapshot } from "./types.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { RpcClient } from "effect/unstable/rpc";
|
|
4
|
+
import { Primitive } from "@voidhash/mimic";
|
|
5
|
+
import * as effect_unstable_rpc_RpcClientError3 from "effect/unstable/rpc/RpcClientError";
|
|
6
|
+
|
|
7
|
+
//#region src/effect/CollectionHandle.d.ts
|
|
8
|
+
declare class CollectionHandle<TSchema extends Primitive.AnyPrimitive> {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly databaseId: string;
|
|
11
|
+
readonly schema: TSchema;
|
|
12
|
+
constructor(id: string, databaseId: string, schema: TSchema);
|
|
13
|
+
create(data: Primitive.InferSetInput<TSchema>, options?: {
|
|
14
|
+
id?: string;
|
|
15
|
+
}): Effect.Effect<DocumentSnapshot<Primitive.InferState<TSchema>>, string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
16
|
+
get(documentId: string): Effect.Effect<DocumentSnapshot<Primitive.InferState<TSchema>>, string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
17
|
+
update(documentId: string, data: Primitive.InferUpdateInput<TSchema>): Effect.Effect<{
|
|
18
|
+
id: string;
|
|
19
|
+
version: number;
|
|
20
|
+
}, string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
21
|
+
set(documentId: string, data: Primitive.InferSetInput<TSchema>): Effect.Effect<{
|
|
22
|
+
id: string;
|
|
23
|
+
version: number;
|
|
24
|
+
}, string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
25
|
+
delete(documentId: string): Effect.Effect<void, string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
26
|
+
list(): Effect.Effect<DocumentSnapshot<Primitive.InferState<TSchema>>[], string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
27
|
+
createDocumentToken(documentId: string, permission: "read" | "write", expiresInSeconds?: number): Effect.Effect<CreatedDocumentToken, string | effect_unstable_rpc_RpcClientError3.RpcClientError, RpcClient.Protocol>;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { CollectionHandle };
|
|
31
|
+
//# sourceMappingURL=CollectionHandle.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionHandle.d.mts","names":[],"sources":["../../src/effect/CollectionHandle.ts"],"sourcesContent":[],"mappings":";;;;;;;cAQa,iCAAiC,SAAA,CAAU;;;EAA3C,SAAA,MAAA,EAGM,OAHU;EAAiB,WAAU,CAAA,EAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,MAAA,EAKF,OALE;EAGrC,MAAA,CAAA,IAAA,EAQJ,SAAA,CAAU,aARN,CAQoB,OARpB,CAAA,EAAA,OAQoB,CARpB,EAAA;IAEmC,EAAA,CAAA,EAAA,MAAA;EAMf,CAAA,CAAA,EAAmC,MAAA,CAAA,MAAnC,CAAmC,gBAAnC,CAAmC,SAAA,CAAA,UAAnC,CAAmC,OAAnC,CAAA,CAAA,EAAA,MAAA,GAAmC,mCAAA,CAAA,cAAnC,EAAmC,SAAA,CAAA,QAAnC,CAAA;EAAxB,GAAA,CAAA,UAAU,EAAA,MAAA,CAAA,EAeD,MAAA,CAAA,MAfC,CAeD,gBAfC,CAeD,SAAA,CAAA,UAfC,CAeD,OAfC,CAAA,CAAA,EAAA,MAAA,GAeD,mCAAA,CAAA,cAfC,EAeD,SAAA,CAAA,QAfC,CAAA;EAAiD,MAAA,CAAA,UAAA,EAAA,MAAA,EAAA,IAAA,EA6BvC,SAAA,CAAU,gBA7B6B,CA6BZ,OA7BY,CAAA,CAAA,EA6BJ,MAAA,CAAA,MA7BI,CAAA;IAAA,EAAA,EAAA,MAAA;IAAA,OAAA,EAAA,MAAA;EAAA,CAAA,EAAA,MAAA,GA6Bb,mCAAA,CAAA,cA7Ba,oBAAA,CAAA;EAAA,GAAA,CAAA,UAAA,EAAA,MAAA,EAAA,IAAA,EA4C1C,SAAA,CAAU,aA5CgC,CA4ClB,OA5CkB,CAAA,CAAA,EA4CV,MAAA,CAAA,MA5CU,CAAA;IAAA,EAAA,EAAA,MAAA;IAelD,OAAA,EAAA,MAAA;EAAA,CAAA,EAAA,MAAA,GA6B+B,mCAAA,CAAA,cA7B/B,oBAAA,CAAA;EAAA,MAAA,CAAA,UAAA,EAAA,MAAA,CAAA,EA4CG,MAAA,CAAA,MA5CH,CAAA,IAAA,EAAA,MAAA,GA6BwC,mCAAA,CAerC,cA5CH,EA4CG,SAAA,CAAA,QA5CH,CAAA;EAAA,IAAA,CAAA,CAAA,EAyDlB,MAAA,CAAA,MAzDkB,CAyDlB,gBAzDkB,CAyDlB,SAAA,CAAA,UAzDkB,CAyDlB,OAzDkB,CAAA,CAAA,EAAA,EAAA,MAAA,GAyDlB,mCAAA,CAAA,cAzDkB,EAyDlB,SAAA,CAAA,QAzDkB,CAAA;EAAA,mBAAA,CAAA,UAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,GAAA,OAAA,EAAA,gBAAA,CAAA,EAAA,MAAA,CAAA,EAsEyE,MAAA,CAAA,MAtEzE,CAsEyE,oBAtEzE,EAAA,MAAA,GAsEyE,mCAAA,CAAA,cAtEzE,EAsEyE,SAAA,CAAA,QAtEzE,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { RpcClient } from "effect/unstable/rpc";
|
|
4
|
+
import { MimicRpcs } from "@voidhash/mimic-protocol";
|
|
5
|
+
|
|
6
|
+
//#region src/effect/CollectionHandle.ts
|
|
7
|
+
const makeClient = () => RpcClient.make(MimicRpcs);
|
|
8
|
+
var CollectionHandle = class {
|
|
9
|
+
constructor(id, databaseId, schema) {
|
|
10
|
+
_defineProperty(this, "id", void 0);
|
|
11
|
+
_defineProperty(this, "databaseId", void 0);
|
|
12
|
+
_defineProperty(this, "schema", void 0);
|
|
13
|
+
this.id = id;
|
|
14
|
+
this.databaseId = databaseId;
|
|
15
|
+
this.schema = schema;
|
|
16
|
+
}
|
|
17
|
+
create(data, options) {
|
|
18
|
+
const collectionId = this.id;
|
|
19
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
20
|
+
return yield* (yield* makeClient()).CreateDocument({
|
|
21
|
+
collectionId,
|
|
22
|
+
id: options === null || options === void 0 ? void 0 : options.id,
|
|
23
|
+
data
|
|
24
|
+
});
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
get(documentId) {
|
|
28
|
+
const collectionId = this.id;
|
|
29
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
30
|
+
return yield* (yield* makeClient()).GetDocument({
|
|
31
|
+
collectionId,
|
|
32
|
+
documentId
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
update(documentId, data) {
|
|
37
|
+
const collectionId = this.id;
|
|
38
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
39
|
+
const result = yield* (yield* makeClient()).UpdateDocument({
|
|
40
|
+
collectionId,
|
|
41
|
+
documentId,
|
|
42
|
+
data
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
id: result.id,
|
|
46
|
+
version: result.version
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
set(documentId, data) {
|
|
51
|
+
const collectionId = this.id;
|
|
52
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
53
|
+
const result = yield* (yield* makeClient()).SetDocument({
|
|
54
|
+
collectionId,
|
|
55
|
+
documentId,
|
|
56
|
+
data
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
id: result.id,
|
|
60
|
+
version: result.version
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
delete(documentId) {
|
|
65
|
+
const collectionId = this.id;
|
|
66
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
67
|
+
yield* (yield* makeClient()).DeleteDocument({
|
|
68
|
+
collectionId,
|
|
69
|
+
documentId
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
list() {
|
|
74
|
+
const collectionId = this.id;
|
|
75
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
76
|
+
return yield* (yield* makeClient()).ListDocuments({ collectionId });
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
createDocumentToken(documentId, permission, expiresInSeconds) {
|
|
80
|
+
const collectionId = this.id;
|
|
81
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
82
|
+
return { token: (yield* (yield* makeClient()).CreateDocumentToken({
|
|
83
|
+
collectionId,
|
|
84
|
+
documentId,
|
|
85
|
+
permission,
|
|
86
|
+
expiresInSeconds
|
|
87
|
+
})).token };
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { CollectionHandle };
|
|
94
|
+
//# sourceMappingURL=CollectionHandle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CollectionHandle.mjs","names":[],"sources":["../../src/effect/CollectionHandle.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { Primitive } from \"@voidhash/mimic\";\nimport { RpcClient } from \"effect/unstable/rpc\";\nimport { MimicRpcs } from \"@voidhash/mimic-protocol\";\nimport type { DocumentSnapshot, CreatedDocumentToken } from \"./types\";\n\nconst makeClient = () => RpcClient.make(MimicRpcs);\n\nexport class CollectionHandle<TSchema extends Primitive.AnyPrimitive> {\n readonly id: string;\n readonly databaseId: string;\n readonly schema: TSchema;\n\n constructor(id: string, databaseId: string, schema: TSchema) {\n this.id = id;\n this.databaseId = databaseId;\n this.schema = schema;\n }\n\n create(data: Primitive.InferSetInput<TSchema>, options?: { id?: string }) {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n const result = yield* client.CreateDocument({\n collectionId,\n id: options?.id,\n data,\n });\n return result as unknown as DocumentSnapshot<Primitive.InferState<TSchema>>;\n }),\n );\n }\n\n get(documentId: string) {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n const result = yield* client.GetDocument({\n collectionId,\n documentId,\n });\n return result as unknown as DocumentSnapshot<Primitive.InferState<TSchema>>;\n }),\n );\n }\n\n update(documentId: string, data: Primitive.InferUpdateInput<TSchema>) {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n const result = yield* client.UpdateDocument({\n collectionId,\n documentId,\n data,\n });\n return { id: result.id, version: result.version };\n }),\n );\n }\n\n set(documentId: string, data: Primitive.InferSetInput<TSchema>) {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n const result = yield* client.SetDocument({\n collectionId,\n documentId,\n data,\n });\n return { id: result.id, version: result.version };\n }),\n );\n }\n\n delete(documentId: string) {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n yield* client.DeleteDocument({\n collectionId,\n documentId,\n });\n }),\n );\n }\n\n list() {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n const result = yield* client.ListDocuments({\n collectionId,\n });\n return result as unknown as DocumentSnapshot<Primitive.InferState<TSchema>>[];\n }),\n );\n }\n\n createDocumentToken(documentId: string, permission: \"read\" | \"write\", expiresInSeconds?: number) {\n const collectionId = this.id;\n return Effect.scoped(\n Effect.gen(function* () {\n const client = yield* makeClient();\n const result = yield* client.CreateDocumentToken({\n collectionId,\n documentId,\n permission,\n expiresInSeconds,\n });\n return { token: result.token } as CreatedDocumentToken;\n }),\n );\n }\n}\n"],"mappings":";;;;;;AAMA,MAAM,mBAAmB,UAAU,KAAK,UAAU;AAElD,IAAa,mBAAb,MAAsE;CAKpE,YAAY,IAAY,YAAoB,QAAiB;wBAJpD;wBACA;wBACA;AAGP,OAAK,KAAK;AACV,OAAK,aAAa;AAClB,OAAK,SAAS;;CAGhB,OAAO,MAAwC,SAA2B;EACxE,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;AAOtB,UALe,QADA,OAAO,YAAY,EACL,eAAe;IAC1C;IACA,sDAAI,QAAS;IACb;IACD,CAAC;IAEF,CACH;;CAGH,IAAI,YAAoB;EACtB,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;AAMtB,UAJe,QADA,OAAO,YAAY,EACL,YAAY;IACvC;IACA;IACD,CAAC;IAEF,CACH;;CAGH,OAAO,YAAoB,MAA2C;EACpE,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;GAEtB,MAAM,SAAS,QADA,OAAO,YAAY,EACL,eAAe;IAC1C;IACA;IACA;IACD,CAAC;AACF,UAAO;IAAE,IAAI,OAAO;IAAI,SAAS,OAAO;IAAS;IACjD,CACH;;CAGH,IAAI,YAAoB,MAAwC;EAC9D,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;GAEtB,MAAM,SAAS,QADA,OAAO,YAAY,EACL,YAAY;IACvC;IACA;IACA;IACD,CAAC;AACF,UAAO;IAAE,IAAI,OAAO;IAAI,SAAS,OAAO;IAAS;IACjD,CACH;;CAGH,OAAO,YAAoB;EACzB,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;AAEtB,WADe,OAAO,YAAY,EACpB,eAAe;IAC3B;IACA;IACD,CAAC;IACF,CACH;;CAGH,OAAO;EACL,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;AAKtB,UAHe,QADA,OAAO,YAAY,EACL,cAAc,EACzC,cACD,CAAC;IAEF,CACH;;CAGH,oBAAoB,YAAoB,YAA8B,kBAA2B;EAC/F,MAAM,eAAe,KAAK;AAC1B,SAAO,OAAO,OACZ,OAAO,IAAI,aAAa;AAQtB,UAAO,EAAE,QANM,QADA,OAAO,YAAY,EACL,oBAAoB;IAC/C;IACA;IACA;IACA;IACD,CAAC,EACqB,OAAO;IAC9B,CACH"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_defineProperty = require('../_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs');
|
|
2
|
+
const require_CollectionHandle = require('./CollectionHandle.cjs');
|
|
3
|
+
let effect = require("effect");
|
|
4
|
+
let effect_unstable_rpc = require("effect/unstable/rpc");
|
|
5
|
+
let _voidhash_mimic_protocol = require("@voidhash/mimic-protocol");
|
|
6
|
+
let _voidhash_mimic = require("@voidhash/mimic");
|
|
7
|
+
|
|
8
|
+
//#region src/effect/DatabaseHandle.ts
|
|
9
|
+
const makeClient = () => effect_unstable_rpc.RpcClient.make(_voidhash_mimic_protocol.MimicRpcs);
|
|
10
|
+
var DatabaseHandle = class {
|
|
11
|
+
constructor(id, name, description) {
|
|
12
|
+
require_defineProperty._defineProperty(this, "id", void 0);
|
|
13
|
+
require_defineProperty._defineProperty(this, "name", void 0);
|
|
14
|
+
require_defineProperty._defineProperty(this, "description", void 0);
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.description = description;
|
|
18
|
+
}
|
|
19
|
+
createCollection(name, schema) {
|
|
20
|
+
const databaseId = this.id;
|
|
21
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
22
|
+
const client = yield* makeClient();
|
|
23
|
+
const schemaJson = _voidhash_mimic.SchemaJSON.toJSON(schema);
|
|
24
|
+
const result = yield* client.CreateCollection({
|
|
25
|
+
databaseId,
|
|
26
|
+
name,
|
|
27
|
+
schemaJson
|
|
28
|
+
});
|
|
29
|
+
return new require_CollectionHandle.CollectionHandle(result.id, result.databaseId, schema);
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
listCollections() {
|
|
33
|
+
const databaseId = this.id;
|
|
34
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
35
|
+
return yield* (yield* makeClient()).ListCollections({ databaseId });
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
deleteCollection(id) {
|
|
39
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
40
|
+
yield* (yield* makeClient()).DeleteCollection({ id });
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
collection(id, schema) {
|
|
44
|
+
return new require_CollectionHandle.CollectionHandle(id, this.id, schema);
|
|
45
|
+
}
|
|
46
|
+
updateCollectionSchema(collectionId, schemaJson) {
|
|
47
|
+
return effect.Effect.scoped(effect.Effect.gen(function* () {
|
|
48
|
+
const result = yield* (yield* makeClient()).UpdateCollectionSchema({
|
|
49
|
+
id: collectionId,
|
|
50
|
+
schemaJson
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
id: result.id,
|
|
54
|
+
schemaVersion: result.schemaVersion
|
|
55
|
+
};
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.DatabaseHandle = DatabaseHandle;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CollectionInfo } from "./types.cjs";
|
|
2
|
+
import { CollectionHandle } from "./CollectionHandle.cjs";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { RpcClient } from "effect/unstable/rpc";
|
|
5
|
+
import * as effect_unstable_rpc_RpcClientError6 from "effect/unstable/rpc/RpcClientError";
|
|
6
|
+
import { Primitive } from "@voidhash/mimic";
|
|
7
|
+
|
|
8
|
+
//#region src/effect/DatabaseHandle.d.ts
|
|
9
|
+
declare class DatabaseHandle {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
constructor(id: string, name: string, description: string);
|
|
14
|
+
createCollection<TSchema extends Primitive.AnyPrimitive>(name: string, schema: TSchema): Effect.Effect<CollectionHandle<TSchema>, string | effect_unstable_rpc_RpcClientError6.RpcClientError, RpcClient.Protocol>;
|
|
15
|
+
listCollections(): Effect.Effect<CollectionInfo[], string | effect_unstable_rpc_RpcClientError6.RpcClientError, RpcClient.Protocol>;
|
|
16
|
+
deleteCollection(id: string): Effect.Effect<void, string | effect_unstable_rpc_RpcClientError6.RpcClientError, RpcClient.Protocol>;
|
|
17
|
+
collection<TSchema extends Primitive.AnyPrimitive>(id: string, schema: TSchema): CollectionHandle<TSchema>;
|
|
18
|
+
updateCollectionSchema(collectionId: string, schemaJson: unknown): Effect.Effect<{
|
|
19
|
+
id: string;
|
|
20
|
+
schemaVersion: number;
|
|
21
|
+
}, string | effect_unstable_rpc_RpcClientError6.RpcClientError, RpcClient.Protocol>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { DatabaseHandle };
|
|
25
|
+
//# sourceMappingURL=DatabaseHandle.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseHandle.d.cts","names":[],"sources":["../../src/effect/DatabaseHandle.ts"],"sourcesContent":[],"mappings":";;;;;;;;cASa,cAAA;;;EAAA,SAAA,WAAc,EAAA,MAAA;EAWQ,WAAU,CAAA,EAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,WAAA,EAAA,MAAA;EAAoC,gBAAA,CAAA,gBAA9C,SAAA,CAAU,YAAoC,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAO,MAAA,CAAA,MAAP,CAAO,gBAAP,CAAO,OAAP,CAAA,EAAA,MAAA,GAAO,mCAAA,CAAA,cAAP,EAAO,SAAA,CAAA,QAAP,CAAA;EAAO,eAAA,CAAA,CAAA,EAgBvE,MAAA,CAAA,MAhBuE,CAgBvE,cAhBuE,EAAA,EAAA,MAAA,GAgBvE,mCAAA,CAAA,cAhBuE,EAgBvE,SAAA,CAAA,QAhBuE,CAAA;EAAA,gBAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EA2B3D,MAAA,CAAA,MA3B2D,CAAA,IAAA,EAAA,MAAA,GAgBvE,mCAAA,CAWY,cA3B2D,EA2B3D,SAAA,CAAA,QA3B2D,CAAA;EAAA,UAAA,CAAA,gBAoC3D,SAAA,CAAU,YApCiD,CAAA,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAsC5E,OAtC4E,CAAA,EAuCnF,gBAvCmF,CAuClE,OAvCkE,CAAA;EAAA,sBAAA,CAAA,YAAA,EAAA,MAAA,EAAA,UAAA,EAAA,OAAA,CAAA,EA2CtB,MAAA,CAAA,MA3CsB,CAAA;IAAA,EAAA,EAAA,MAAA;IAgBvE,aAAA,EAAA,MAAA;EAAA,CAAA,EAAA,MAAA,GAuBI,mCAAA,CAAA,cAvBJ,oBAAA,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CollectionInfo } from "./types.mjs";
|
|
2
|
+
import { CollectionHandle } from "./CollectionHandle.mjs";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { RpcClient } from "effect/unstable/rpc";
|
|
5
|
+
import { Primitive } from "@voidhash/mimic";
|
|
6
|
+
import * as effect_unstable_rpc_RpcClientError0 from "effect/unstable/rpc/RpcClientError";
|
|
7
|
+
|
|
8
|
+
//#region src/effect/DatabaseHandle.d.ts
|
|
9
|
+
declare class DatabaseHandle {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
constructor(id: string, name: string, description: string);
|
|
14
|
+
createCollection<TSchema extends Primitive.AnyPrimitive>(name: string, schema: TSchema): Effect.Effect<CollectionHandle<TSchema>, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
15
|
+
listCollections(): Effect.Effect<CollectionInfo[], string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
16
|
+
deleteCollection(id: string): Effect.Effect<void, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
17
|
+
collection<TSchema extends Primitive.AnyPrimitive>(id: string, schema: TSchema): CollectionHandle<TSchema>;
|
|
18
|
+
updateCollectionSchema(collectionId: string, schemaJson: unknown): Effect.Effect<{
|
|
19
|
+
id: string;
|
|
20
|
+
schemaVersion: number;
|
|
21
|
+
}, string | effect_unstable_rpc_RpcClientError0.RpcClientError, RpcClient.Protocol>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { DatabaseHandle };
|
|
25
|
+
//# sourceMappingURL=DatabaseHandle.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseHandle.d.mts","names":[],"sources":["../../src/effect/DatabaseHandle.ts"],"sourcesContent":[],"mappings":";;;;;;;;cASa,cAAA;;;EAAA,SAAA,WAAc,EAAA,MAAA;EAWQ,WAAU,CAAA,EAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,WAAA,EAAA,MAAA;EAAoC,gBAAA,CAAA,gBAA9C,SAAA,CAAU,YAAoC,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAO,MAAA,CAAA,MAAP,CAAO,gBAAP,CAAO,OAAP,CAAA,EAAA,MAAA,GAAO,mCAAA,CAAA,cAAP,EAAO,SAAA,CAAA,QAAP,CAAA;EAAO,eAAA,CAAA,CAAA,EAgBvE,MAAA,CAAA,MAhBuE,CAgBvE,cAhBuE,EAAA,EAAA,MAAA,GAgBvE,mCAAA,CAAA,cAhBuE,EAgBvE,SAAA,CAAA,QAhBuE,CAAA;EAAA,gBAAA,CAAA,EAAA,EAAA,MAAA,CAAA,EA2B3D,MAAA,CAAA,MA3B2D,CAAA,IAAA,EAAA,MAAA,GAgBvE,mCAAA,CAWY,cA3B2D,EA2B3D,SAAA,CAAA,QA3B2D,CAAA;EAAA,UAAA,CAAA,gBAoC3D,SAAA,CAAU,YApCiD,CAAA,CAAA,EAAA,EAAA,MAAA,EAAA,MAAA,EAsC5E,OAtC4E,CAAA,EAuCnF,gBAvCmF,CAuClE,OAvCkE,CAAA;EAAA,sBAAA,CAAA,YAAA,EAAA,MAAA,EAAA,UAAA,EAAA,OAAA,CAAA,EA2CtB,MAAA,CAAA,MA3CsB,CAAA;IAAA,EAAA,EAAA,MAAA;IAgBvE,aAAA,EAAA,MAAA;EAAA,CAAA,EAAA,MAAA,GAuBI,mCAAA,CAAA,cAvBJ,oBAAA,CAAA"}
|