jazz-tools 0.7.0-alpha.0 → 0.7.0-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +8 -1
- package/CHANGELOG.md +8 -0
- package/dist/coValues/account.js +138 -0
- package/dist/coValues/account.js.map +1 -0
- package/dist/coValues/coList.js +196 -0
- package/dist/coValues/coList.js.map +1 -0
- package/dist/coValues/coMap.js +249 -0
- package/dist/coValues/coMap.js.map +1 -0
- package/dist/coValues/coStream.js +189 -0
- package/dist/coValues/coStream.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +17 -12
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +96 -0
- package/dist/coValues/group.js.map +1 -0
- package/dist/coValues/interfaces.js +58 -0
- package/dist/coValues/interfaces.js.map +1 -0
- package/dist/implementation/errors.js.map +1 -0
- package/dist/implementation/inspect.js +2 -0
- package/dist/implementation/inspect.js.map +1 -0
- package/dist/{refs.js → implementation/refs.js} +11 -13
- package/dist/implementation/refs.js.map +1 -0
- package/dist/implementation/schema.js +6 -0
- package/dist/implementation/schema.js.map +1 -0
- package/dist/{subscriptionScope.js → implementation/subscriptionScope.js} +1 -1
- package/dist/implementation/subscriptionScope.js.map +1 -0
- package/dist/index.js +23 -27
- package/dist/index.js.map +1 -1
- package/dist/internal.js +13 -0
- package/dist/internal.js.map +1 -0
- package/dist/tests/coList.test.js +26 -22
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +91 -43
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +35 -24
- package/dist/tests/coStream.test.js.map +1 -1
- package/package.json +11 -4
- package/src/coValues/account.ts +297 -0
- package/src/coValues/coList.ts +320 -0
- package/src/coValues/coMap.ts +447 -0
- package/src/coValues/coStream.ts +325 -0
- package/src/coValues/extensions/imageDef.ts +24 -16
- package/src/coValues/group.ts +187 -0
- package/src/coValues/interfaces.ts +216 -0
- package/src/implementation/inspect.ts +2 -0
- package/src/{refs.ts → implementation/refs.ts} +21 -32
- package/src/implementation/schema.ts +69 -0
- package/src/{subscriptionScope.ts → implementation/subscriptionScope.ts} +11 -13
- package/src/index.ts +22 -50
- package/src/internal.ts +15 -0
- package/src/tests/coList.test.ts +27 -25
- package/src/tests/coMap.test.ts +125 -50
- package/src/tests/coStream.test.ts +51 -38
- package/dist/coValueInterfaces.js +0 -8
- package/dist/coValueInterfaces.js.map +0 -1
- package/dist/coValues/account/account.js +0 -11
- package/dist/coValues/account/account.js.map +0 -1
- package/dist/coValues/account/accountOf.js +0 -150
- package/dist/coValues/account/accountOf.js.map +0 -1
- package/dist/coValues/account/migration.js +0 -4
- package/dist/coValues/account/migration.js.map +0 -1
- package/dist/coValues/coList/coList.js +0 -2
- package/dist/coValues/coList/coList.js.map +0 -1
- package/dist/coValues/coList/coListOf.js +0 -235
- package/dist/coValues/coList/coListOf.js.map +0 -1
- package/dist/coValues/coList/internalDocs.js +0 -2
- package/dist/coValues/coList/internalDocs.js.map +0 -1
- package/dist/coValues/coMap/coMap.js +0 -2
- package/dist/coValues/coMap/coMap.js.map +0 -1
- package/dist/coValues/coMap/coMapOf.js +0 -262
- package/dist/coValues/coMap/coMapOf.js.map +0 -1
- package/dist/coValues/coMap/internalDocs.js +0 -2
- package/dist/coValues/coMap/internalDocs.js.map +0 -1
- package/dist/coValues/coStream/coStream.js +0 -2
- package/dist/coValues/coStream/coStream.js.map +0 -1
- package/dist/coValues/coStream/coStreamOf.js +0 -244
- package/dist/coValues/coStream/coStreamOf.js.map +0 -1
- package/dist/coValues/construction.js +0 -34
- package/dist/coValues/construction.js.map +0 -1
- package/dist/coValues/group/group.js +0 -2
- package/dist/coValues/group/group.js.map +0 -1
- package/dist/coValues/group/groupOf.js +0 -109
- package/dist/coValues/group/groupOf.js.map +0 -1
- package/dist/coValues/resolution.js +0 -66
- package/dist/coValues/resolution.js.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/refs.js.map +0 -1
- package/dist/schemaHelpers.js +0 -14
- package/dist/schemaHelpers.js.map +0 -1
- package/dist/subscriptionScope.js.map +0 -1
- package/dist/tests/types.test.js +0 -33
- package/dist/tests/types.test.js.map +0 -1
- package/src/coValueInterfaces.ts +0 -105
- package/src/coValues/account/account.ts +0 -106
- package/src/coValues/account/accountOf.ts +0 -284
- package/src/coValues/account/migration.ts +0 -12
- package/src/coValues/coList/coList.ts +0 -57
- package/src/coValues/coList/coListOf.ts +0 -377
- package/src/coValues/coList/internalDocs.ts +0 -1
- package/src/coValues/coMap/coMap.ts +0 -110
- package/src/coValues/coMap/coMapOf.ts +0 -451
- package/src/coValues/coMap/internalDocs.ts +0 -1
- package/src/coValues/coStream/coStream.ts +0 -63
- package/src/coValues/coStream/coStreamOf.ts +0 -404
- package/src/coValues/construction.ts +0 -110
- package/src/coValues/group/group.ts +0 -27
- package/src/coValues/group/groupOf.ts +0 -183
- package/src/coValues/resolution.ts +0 -111
- package/src/schemaHelpers.ts +0 -72
- package/src/tests/types.test.ts +0 -37
- /package/dist/{errors.js → implementation/errors.js} +0 -0
- /package/src/{errors.ts → implementation/errors.ts} +0 -0
package/.eslintrc.cjs
CHANGED
@@ -19,6 +19,13 @@ module.exports = {
|
|
19
19
|
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
20
20
|
],
|
21
21
|
"@typescript-eslint/no-floating-promises": "error",
|
22
|
-
"@typescript-eslint/no-explicit-any": "warn"
|
22
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
23
|
+
"@typescript-eslint/consistent-type-imports": [
|
24
|
+
"error",
|
25
|
+
{
|
26
|
+
prefer: "type-imports",
|
27
|
+
disallowTypeAnnotations: false,
|
28
|
+
},
|
29
|
+
],
|
23
30
|
},
|
24
31
|
};
|
package/CHANGELOG.md
CHANGED
@@ -0,0 +1,138 @@
|
|
1
|
+
var _a;
|
2
|
+
import { LocalNode } from "cojson";
|
3
|
+
import { Context } from "effect";
|
4
|
+
import { CoValueBase, Profile, ValueRef, inspect } from "../internal.js";
|
5
|
+
export class Account extends CoValueBase {
|
6
|
+
get _schema() {
|
7
|
+
return this.constructor._schema;
|
8
|
+
}
|
9
|
+
get _owner() {
|
10
|
+
return this;
|
11
|
+
}
|
12
|
+
get _loadedAs() {
|
13
|
+
return this.isMe
|
14
|
+
? this
|
15
|
+
: _a.fromNode(this._raw.core.node);
|
16
|
+
}
|
17
|
+
get _refs() {
|
18
|
+
const profileID = this._raw.get("profile");
|
19
|
+
const rootID = this._raw.get("root");
|
20
|
+
return {
|
21
|
+
profile: profileID && (new ValueRef(profileID, this._loadedAs, this._schema.profile.ref())),
|
22
|
+
root: rootID &&
|
23
|
+
new ValueRef(rootID, this._loadedAs, this._schema.root.ref()),
|
24
|
+
};
|
25
|
+
}
|
26
|
+
constructor(init, options) {
|
27
|
+
super();
|
28
|
+
this.acceptInvite = (async (valueID, inviteSecret, coValueClass) => {
|
29
|
+
if (!this.isMe) {
|
30
|
+
throw new Error("Only a controlled account can accept invites");
|
31
|
+
}
|
32
|
+
await this._raw.acceptInvite(valueID, inviteSecret);
|
33
|
+
return coValueClass.load(valueID, {
|
34
|
+
as: this,
|
35
|
+
});
|
36
|
+
});
|
37
|
+
if (!("fromRaw" in options)) {
|
38
|
+
throw new Error("Can only construct account from raw or with .create()");
|
39
|
+
}
|
40
|
+
this.isMe = options.fromRaw.id == options.fromRaw.core.node.account.id;
|
41
|
+
Object.defineProperties(this, {
|
42
|
+
id: {
|
43
|
+
value: options.fromRaw.id,
|
44
|
+
enumerable: false,
|
45
|
+
},
|
46
|
+
_raw: { value: options.fromRaw, enumerable: false },
|
47
|
+
profile: {
|
48
|
+
get: () => {
|
49
|
+
const ref = this._refs.profile;
|
50
|
+
return ref ? ref.accessFrom(this) : undefined;
|
51
|
+
},
|
52
|
+
set: (value) => {
|
53
|
+
if (value) {
|
54
|
+
this._raw.set("profile", value.id);
|
55
|
+
}
|
56
|
+
},
|
57
|
+
},
|
58
|
+
root: {
|
59
|
+
get: () => {
|
60
|
+
const ref = this._refs.root;
|
61
|
+
return ref ? ref.accessFrom(this) : undefined;
|
62
|
+
},
|
63
|
+
set: (value) => {
|
64
|
+
if (value) {
|
65
|
+
this._raw.set("root", value.id);
|
66
|
+
}
|
67
|
+
},
|
68
|
+
},
|
69
|
+
});
|
70
|
+
if (this.isMe) {
|
71
|
+
this.sessionID =
|
72
|
+
options.fromRaw.core.node.currentSessionID;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
myRole() {
|
76
|
+
if (this.isMe) {
|
77
|
+
return "admin";
|
78
|
+
}
|
79
|
+
}
|
80
|
+
static async create(options) {
|
81
|
+
const { node } = await LocalNode.withNewlyCreatedAccount({
|
82
|
+
...options,
|
83
|
+
migration: async (rawAccount) => {
|
84
|
+
const account = new this(undefined, {
|
85
|
+
fromRaw: rawAccount,
|
86
|
+
});
|
87
|
+
await account.migrate?.();
|
88
|
+
},
|
89
|
+
});
|
90
|
+
return this.fromNode(node);
|
91
|
+
}
|
92
|
+
static async become(options) {
|
93
|
+
const node = await LocalNode.withLoadedAccount({
|
94
|
+
accountID: options.accountID,
|
95
|
+
accountSecret: options.accountSecret,
|
96
|
+
sessionID: options.sessionID,
|
97
|
+
peersToLoadFrom: options.peersToLoadFrom,
|
98
|
+
migration: async (rawAccount) => {
|
99
|
+
const account = new this(undefined, {
|
100
|
+
fromRaw: rawAccount,
|
101
|
+
});
|
102
|
+
await account.migrate?.();
|
103
|
+
},
|
104
|
+
});
|
105
|
+
return this.fromNode(node);
|
106
|
+
}
|
107
|
+
static fromNode(node) {
|
108
|
+
return new this(undefined, {
|
109
|
+
fromRaw: node.account,
|
110
|
+
});
|
111
|
+
}
|
112
|
+
toJSON() {
|
113
|
+
return {
|
114
|
+
id: this.id,
|
115
|
+
_type: this._type,
|
116
|
+
};
|
117
|
+
}
|
118
|
+
[inspect]() {
|
119
|
+
return this.toJSON();
|
120
|
+
}
|
121
|
+
static encoding(fields) {
|
122
|
+
this._schema || (this._schema = {});
|
123
|
+
Object.assign(this._schema, fields);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
_a = Account;
|
127
|
+
(() => {
|
128
|
+
_a._schema = {
|
129
|
+
profile: { ref: () => Profile },
|
130
|
+
root: { json: true },
|
131
|
+
};
|
132
|
+
})();
|
133
|
+
export class AccountCtx extends Context.Tag("Account")() {
|
134
|
+
}
|
135
|
+
export function isControlledAccount(account) {
|
136
|
+
return account.isMe;
|
137
|
+
}
|
138
|
+
//# sourceMappingURL=account.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAYnC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAYjC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzE,MAAM,OAAO,OAMT,SAAQ,WAAW;IAQnB,IAAI,OAAO;QAIP,OAAQ,IAAI,CAAC,WAA8B,CAAC,OAAO,CAAC;IACxD,CAAC;IAQD,IAAI,MAAM;QACN,OAAO,IAAe,CAAC;IAC3B,CAAC;IACD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,IAAI;YACZ,CAAC,CAAE,IAAqB;YACxB,CAAC,CAAC,EAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAKD,IAAI,KAAK;QAQL,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAE5B,CAAC;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAEpB,CAAC;QAChB,OAAO;YACH,OAAO,EAAE,SAAS,IAAI,CAAC,IAAI,QAAQ,CAC/B,SAAS,EACT,IAAI,CAAC,SAAS,EAEV,IAAI,CAAC,OAAO,CAAC,OAGhB,CAAC,GAAG,EAAE,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CAAC;IACxC,CAAC;CAGJ;;AAtOG;IACI,GAAK,OAAO,GAAG;QACX,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE;QAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KAChB,CAAC;AACb,CAAC,GAAA,CAAA;AA6OL,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAGnD;CAAG;AAEN,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACxB,CAAC"}
|
@@ -0,0 +1,196 @@
|
|
1
|
+
var _a;
|
2
|
+
import { RawAccount } from "cojson";
|
3
|
+
import { Account, CoValueBase, Group, ValueRef, inspect, makeRefs, } from "../internal.js";
|
4
|
+
import { Schema } from "@effect/schema";
|
5
|
+
export class CoList extends Array {
|
6
|
+
get _schema() {
|
7
|
+
return this.constructor._schema;
|
8
|
+
}
|
9
|
+
get _owner() {
|
10
|
+
return this._raw.group instanceof RawAccount
|
11
|
+
? Account.fromRaw(this._raw.group)
|
12
|
+
: Group.fromRaw(this._raw.group);
|
13
|
+
}
|
14
|
+
get _refs() {
|
15
|
+
return makeRefs((idx) => this._raw.get(idx), () => Array.from({ length: this._raw.entries().length }, (_, idx) => idx), this._loadedAs, (_idx) => this._schema._item.ref());
|
16
|
+
}
|
17
|
+
get _edits() {
|
18
|
+
throw new Error("Not implemented");
|
19
|
+
}
|
20
|
+
get _loadedAs() {
|
21
|
+
return Account.fromNode(this._raw.core.node);
|
22
|
+
}
|
23
|
+
constructor(init, options) {
|
24
|
+
if (typeof init === "number") {
|
25
|
+
// this might be called from an intrinsic, like map, trying to create an empty array
|
26
|
+
// passing `0` as the only parameter
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
28
|
+
return new Array(init);
|
29
|
+
}
|
30
|
+
super();
|
31
|
+
if (!options) {
|
32
|
+
throw new Error("Must provide options");
|
33
|
+
}
|
34
|
+
let raw;
|
35
|
+
if ("fromRaw" in options) {
|
36
|
+
raw = options.fromRaw;
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
const rawOwner = options.owner._raw;
|
40
|
+
const rawInit = init && this.toRawItems(init);
|
41
|
+
raw = rawOwner.createList(rawInit);
|
42
|
+
}
|
43
|
+
Object.defineProperties(this, {
|
44
|
+
id: {
|
45
|
+
value: raw.id,
|
46
|
+
enumerable: false,
|
47
|
+
},
|
48
|
+
_raw: { value: raw, enumerable: false },
|
49
|
+
});
|
50
|
+
return new Proxy(this, CoListProxyHandler(this._schema._item));
|
51
|
+
}
|
52
|
+
toRawItems(items) {
|
53
|
+
const itemDescriptor = this._schema._item;
|
54
|
+
const rawItems = itemDescriptor === "json"
|
55
|
+
? items
|
56
|
+
: "encoded" in itemDescriptor
|
57
|
+
? items?.map((e) => Schema.encodeSync(itemDescriptor.encoded)(e))
|
58
|
+
: "ref" in itemDescriptor
|
59
|
+
? items?.map((v) => v.id)
|
60
|
+
: (() => {
|
61
|
+
throw new Error("Invalid element descriptor");
|
62
|
+
})();
|
63
|
+
return rawItems;
|
64
|
+
}
|
65
|
+
push(...items) {
|
66
|
+
for (const item of this.toRawItems(items)) {
|
67
|
+
this._raw.append(item);
|
68
|
+
}
|
69
|
+
return this._raw.entries().length;
|
70
|
+
}
|
71
|
+
unshift(...items) {
|
72
|
+
for (const item of this.toRawItems(items)) {
|
73
|
+
this._raw.prepend(item);
|
74
|
+
}
|
75
|
+
return this._raw.entries().length;
|
76
|
+
}
|
77
|
+
pop() {
|
78
|
+
const last = this[this.length - 1];
|
79
|
+
this._raw.delete(this.length - 1);
|
80
|
+
return last;
|
81
|
+
}
|
82
|
+
shift() {
|
83
|
+
const first = this[0];
|
84
|
+
this._raw.delete(0);
|
85
|
+
return first;
|
86
|
+
}
|
87
|
+
splice(start, deleteCount, ...items) {
|
88
|
+
const deleted = this.slice(start, start + deleteCount);
|
89
|
+
for (let idxToDelete = start + deleteCount; idxToDelete > start; idxToDelete--) {
|
90
|
+
this._raw.delete(idxToDelete);
|
91
|
+
}
|
92
|
+
let appendAfter = start;
|
93
|
+
for (const item of this.toRawItems(items)) {
|
94
|
+
this._raw.append(item, appendAfter);
|
95
|
+
appendAfter++;
|
96
|
+
}
|
97
|
+
return deleted;
|
98
|
+
}
|
99
|
+
toJSON() {
|
100
|
+
const itemDescriptor = this._schema._item;
|
101
|
+
if (itemDescriptor === "json") {
|
102
|
+
return this._raw.asArray();
|
103
|
+
}
|
104
|
+
else if ("encoded" in itemDescriptor) {
|
105
|
+
return this._raw
|
106
|
+
.asArray()
|
107
|
+
.map((e) => Schema.encodeSync(itemDescriptor.encoded)(e));
|
108
|
+
}
|
109
|
+
else if ("ref" in itemDescriptor) {
|
110
|
+
return this.map((item) => item?.toJSON());
|
111
|
+
}
|
112
|
+
else {
|
113
|
+
return [];
|
114
|
+
}
|
115
|
+
}
|
116
|
+
[inspect]() {
|
117
|
+
return this.toJSON();
|
118
|
+
}
|
119
|
+
static fromRaw(raw) {
|
120
|
+
return new this(undefined, { fromRaw: raw });
|
121
|
+
}
|
122
|
+
static encoding(def) {
|
123
|
+
this._schema || (this._schema = {});
|
124
|
+
Object.assign(this._schema, def);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
_a = CoList;
|
128
|
+
(() => {
|
129
|
+
_a.prototype._type = "CoList";
|
130
|
+
})();
|
131
|
+
(() => {
|
132
|
+
_a.prototype.subscribe = CoValueBase.prototype.subscribe;
|
133
|
+
})();
|
134
|
+
(() => {
|
135
|
+
_a.prototype.subscribeEf = CoValueBase.prototype.subscribeEf;
|
136
|
+
})();
|
137
|
+
CoList.loadEf = CoValueBase.loadEf;
|
138
|
+
CoList.load = CoValueBase.load;
|
139
|
+
CoList.subscribeEf = CoValueBase.subscribeEf;
|
140
|
+
CoList.subscribe = CoValueBase.subscribe;
|
141
|
+
function CoListProxyHandler(itemDescriptor) {
|
142
|
+
return {
|
143
|
+
get(target, key, receiver) {
|
144
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
145
|
+
const rawValue = target._raw.get(Number(key));
|
146
|
+
if (itemDescriptor === "json") {
|
147
|
+
return rawValue;
|
148
|
+
}
|
149
|
+
else if ("encoded" in itemDescriptor) {
|
150
|
+
return rawValue === undefined
|
151
|
+
? undefined
|
152
|
+
: Schema.decodeSync(itemDescriptor.encoded)(rawValue);
|
153
|
+
}
|
154
|
+
else if ("ref" in itemDescriptor) {
|
155
|
+
return rawValue === undefined
|
156
|
+
? undefined
|
157
|
+
: new ValueRef(rawValue, target._loadedAs, itemDescriptor.ref()).accessFrom(receiver);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
else if (key === "length") {
|
161
|
+
return target._raw.entries().length;
|
162
|
+
}
|
163
|
+
else {
|
164
|
+
return Reflect.get(target, key, receiver);
|
165
|
+
}
|
166
|
+
},
|
167
|
+
set(target, key, value, receiver) {
|
168
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
169
|
+
let rawValue;
|
170
|
+
if (itemDescriptor === "json") {
|
171
|
+
rawValue = value;
|
172
|
+
}
|
173
|
+
else if ("encoded" in itemDescriptor) {
|
174
|
+
rawValue = Schema.encodeSync(itemDescriptor.encoded)(value);
|
175
|
+
}
|
176
|
+
else if ("ref" in itemDescriptor) {
|
177
|
+
rawValue = value.id;
|
178
|
+
}
|
179
|
+
target._raw.replace(Number(key), rawValue);
|
180
|
+
return true;
|
181
|
+
}
|
182
|
+
else {
|
183
|
+
return Reflect.set(target, key, value, receiver);
|
184
|
+
}
|
185
|
+
},
|
186
|
+
has(target, key) {
|
187
|
+
if (typeof key === "string" && !isNaN(+key)) {
|
188
|
+
return Number(key) < target._raw.entries().length;
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
return Reflect.has(target, key);
|
192
|
+
}
|
193
|
+
},
|
194
|
+
};
|
195
|
+
}
|
196
|
+
//# sourceMappingURL=coList.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coList.js","sourceRoot":"","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Q,GAAG,KAAK,CAAC,EAAE,CAAC;gBACxB,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAC3C,OAAO,IAAI,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACJ,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACrD,CAAC;QACL,CAAC;QACD,GAAG,CAAC,MAAM,EAAE,GAAG;YACX,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACJ,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACpC,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|
@@ -0,0 +1,249 @@
|
|
1
|
+
var _a;
|
2
|
+
import { Schema } from "@effect/schema";
|
3
|
+
import { Account, CoValueBase, ValueRef, inspect, makeRefs, subscriptionsScopes, indexSignature, } from "../internal.js";
|
4
|
+
export class CoMap extends CoValueBase {
|
5
|
+
get _schema() {
|
6
|
+
return this.constructor._schema;
|
7
|
+
}
|
8
|
+
get _refs() {
|
9
|
+
return makeRefs((key) => this._raw.get(key), () => Object.keys(this._schema).filter((key) => {
|
10
|
+
const schema = this._schema[key];
|
11
|
+
schema !== "json" && "ref" in schema;
|
12
|
+
}), this._loadedAs, (key) => this._schema[key].ref());
|
13
|
+
}
|
14
|
+
get _edits() {
|
15
|
+
return new Proxy(this, {
|
16
|
+
get(target, key) {
|
17
|
+
const rawEdit = target._raw.lastEditAt(key);
|
18
|
+
if (!rawEdit)
|
19
|
+
return undefined;
|
20
|
+
const descriptor = target._schema[key];
|
21
|
+
return {
|
22
|
+
value: descriptor === "json"
|
23
|
+
? rawEdit.value
|
24
|
+
: "encoded" in descriptor
|
25
|
+
? Schema.decodeSync(descriptor.encoded)(rawEdit.value)
|
26
|
+
: new ValueRef(rawEdit.value, target._loadedAs, descriptor.ref()).accessFrom(target),
|
27
|
+
ref: descriptor !== "json" && "ref" in descriptor
|
28
|
+
? new ValueRef(rawEdit.value, target._loadedAs, descriptor.ref())
|
29
|
+
: undefined,
|
30
|
+
by: rawEdit.by &&
|
31
|
+
new ValueRef(rawEdit.by, target._loadedAs, Account).accessFrom(target),
|
32
|
+
madeAt: rawEdit.at,
|
33
|
+
};
|
34
|
+
},
|
35
|
+
});
|
36
|
+
}
|
37
|
+
get _loadedAs() {
|
38
|
+
return Account.fromNode(this._raw.core.node);
|
39
|
+
}
|
40
|
+
constructor(init, options) {
|
41
|
+
super();
|
42
|
+
if (!this._schema) {
|
43
|
+
throw new Error("No schema found in " +
|
44
|
+
this.constructor.name +
|
45
|
+
" - ensure that you have a `static { this.define({...}) }` block in the class definition.");
|
46
|
+
}
|
47
|
+
const raw = this.rawFromInit(options, init);
|
48
|
+
Object.defineProperties(this, {
|
49
|
+
id: {
|
50
|
+
value: raw.id,
|
51
|
+
enumerable: false,
|
52
|
+
},
|
53
|
+
_raw: { value: raw, enumerable: false },
|
54
|
+
});
|
55
|
+
this.definePropertiesFromSchema();
|
56
|
+
if (this._schema[indexSignature]) {
|
57
|
+
return new Proxy(this, CoMapProxyHandler());
|
58
|
+
}
|
59
|
+
}
|
60
|
+
toJSON() {
|
61
|
+
const jsonedFields = this._raw.keys().map((key) => {
|
62
|
+
const tKey = key;
|
63
|
+
const descriptor = this._schema[tKey];
|
64
|
+
if (descriptor == "json" || "encode" in descriptor) {
|
65
|
+
return [key, this._raw.get(key)];
|
66
|
+
}
|
67
|
+
else if ("ref" in descriptor) {
|
68
|
+
const jsonedRef = this[tKey]?.toJSON();
|
69
|
+
return [key, jsonedRef];
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
return [key, undefined];
|
73
|
+
}
|
74
|
+
});
|
75
|
+
return {
|
76
|
+
id: this.id,
|
77
|
+
_type: this._type,
|
78
|
+
...Object.fromEntries(jsonedFields),
|
79
|
+
};
|
80
|
+
}
|
81
|
+
[inspect]() {
|
82
|
+
return this.toJSON();
|
83
|
+
}
|
84
|
+
rawFromInit(options, init) {
|
85
|
+
let raw;
|
86
|
+
if ("fromRaw" in options) {
|
87
|
+
raw = options.fromRaw;
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
const rawOwner = options.owner._raw;
|
91
|
+
const rawInit = {};
|
92
|
+
if (init)
|
93
|
+
for (const key of Object.keys(init)) {
|
94
|
+
const initValue = init[key];
|
95
|
+
const descriptor = (this._schema[key] || this._schema[indexSignature]);
|
96
|
+
if (descriptor === "json") {
|
97
|
+
rawInit[key] = initValue;
|
98
|
+
}
|
99
|
+
else if ("ref" in descriptor) {
|
100
|
+
if (initValue) {
|
101
|
+
rawInit[key] = initValue.id;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
else if ("encoded" in descriptor) {
|
105
|
+
rawInit[key] = Schema.encodeSync(descriptor.encoded)(initValue);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
raw = rawOwner.createMap(rawInit);
|
109
|
+
}
|
110
|
+
return raw;
|
111
|
+
}
|
112
|
+
static encoding(fields) {
|
113
|
+
this._schema || (this._schema = {});
|
114
|
+
Object.assign(this._schema, fields);
|
115
|
+
}
|
116
|
+
definePropertiesFromSchema() {
|
117
|
+
for (const [key, fieldSchema] of Object.entries(this._schema)) {
|
118
|
+
if (key === "indexSignature")
|
119
|
+
continue;
|
120
|
+
const descriptor = fieldSchema;
|
121
|
+
if (descriptor === "json") {
|
122
|
+
Object.defineProperty(this, key, this.primitivePropDef(key));
|
123
|
+
}
|
124
|
+
else if ("encoded" in descriptor) {
|
125
|
+
Object.defineProperty(this, key, this.encodedPropDef(key, descriptor.encoded));
|
126
|
+
}
|
127
|
+
else if ("ref" in descriptor) {
|
128
|
+
Object.defineProperty(this, key, this.refPropDef(key, descriptor.ref));
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
primitivePropDef(key) {
|
133
|
+
return {
|
134
|
+
get: () => {
|
135
|
+
return this._raw.get(key);
|
136
|
+
},
|
137
|
+
set(value) {
|
138
|
+
this._raw.set(key, value);
|
139
|
+
},
|
140
|
+
enumerable: true,
|
141
|
+
configurable: true,
|
142
|
+
};
|
143
|
+
}
|
144
|
+
encodedPropDef(key, arg) {
|
145
|
+
return {
|
146
|
+
get: () => {
|
147
|
+
const raw = this._raw.get(key);
|
148
|
+
return raw === undefined
|
149
|
+
? undefined
|
150
|
+
: Schema.decodeSync(arg)(raw);
|
151
|
+
},
|
152
|
+
set(value) {
|
153
|
+
this._raw.set(key, Schema.encodeSync(arg)(value));
|
154
|
+
},
|
155
|
+
enumerable: true,
|
156
|
+
configurable: true,
|
157
|
+
};
|
158
|
+
}
|
159
|
+
refPropDef(key, ref) {
|
160
|
+
return {
|
161
|
+
get: () => {
|
162
|
+
const rawID = this._raw.get(key);
|
163
|
+
return rawID === undefined
|
164
|
+
? undefined
|
165
|
+
: new ValueRef(rawID, this._loadedAs, ref()).accessFrom(this);
|
166
|
+
},
|
167
|
+
set: (value) => {
|
168
|
+
this._raw.set(key, value.id);
|
169
|
+
subscriptionsScopes.get(this)?.onRefAccessedOrSet(value.id);
|
170
|
+
},
|
171
|
+
enumerable: true,
|
172
|
+
configurable: true,
|
173
|
+
};
|
174
|
+
}
|
175
|
+
}
|
176
|
+
_a = CoMap;
|
177
|
+
(() => {
|
178
|
+
_a.prototype._type = "CoMap";
|
179
|
+
})();
|
180
|
+
// TODO: cache handlers per descriptor for performance?
|
181
|
+
function CoMapProxyHandler() {
|
182
|
+
return {
|
183
|
+
get(target, key, receiver) {
|
184
|
+
const descriptor = target._schema[indexSignature];
|
185
|
+
if (key in target || typeof key === "symbol") {
|
186
|
+
return Reflect.get(target, key, receiver);
|
187
|
+
}
|
188
|
+
else {
|
189
|
+
const raw = target._raw.get(key);
|
190
|
+
if (descriptor === "json") {
|
191
|
+
return raw;
|
192
|
+
}
|
193
|
+
else if ("encoded" in descriptor) {
|
194
|
+
return raw === undefined
|
195
|
+
? undefined
|
196
|
+
: Schema.decodeSync(descriptor.encoded)(raw);
|
197
|
+
}
|
198
|
+
else if ("ref" in descriptor) {
|
199
|
+
return raw === undefined
|
200
|
+
? undefined
|
201
|
+
: new ValueRef(raw, target._loadedAs, descriptor.ref()).accessFrom(target);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
},
|
205
|
+
set(target, key, value, receiver) {
|
206
|
+
const descriptor = target._schema[indexSignature];
|
207
|
+
if (key in target || typeof key === "symbol") {
|
208
|
+
return Reflect.set(target, key, value, receiver);
|
209
|
+
}
|
210
|
+
else {
|
211
|
+
if (descriptor === "json") {
|
212
|
+
target._raw.set(key, value);
|
213
|
+
}
|
214
|
+
else if ("encoded" in descriptor) {
|
215
|
+
target._raw.set(key, Schema.encodeSync(descriptor.encoded)(value));
|
216
|
+
}
|
217
|
+
else if ("ref" in descriptor) {
|
218
|
+
target._raw.set(key, value.id);
|
219
|
+
subscriptionsScopes
|
220
|
+
.get(target)
|
221
|
+
?.onRefAccessedOrSet(value.id);
|
222
|
+
}
|
223
|
+
return true;
|
224
|
+
}
|
225
|
+
},
|
226
|
+
ownKeys(target) {
|
227
|
+
const keys = Reflect.ownKeys(target);
|
228
|
+
for (const key of target._raw.keys()) {
|
229
|
+
if (!keys.includes(key)) {
|
230
|
+
keys.push(key);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
return keys;
|
234
|
+
},
|
235
|
+
getOwnPropertyDescriptor(target, key) {
|
236
|
+
if (key in target) {
|
237
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
238
|
+
}
|
239
|
+
else if (key in target._raw.ops) {
|
240
|
+
return {
|
241
|
+
enumerable: true,
|
242
|
+
configurable: true,
|
243
|
+
writable: true,
|
244
|
+
};
|
245
|
+
}
|
246
|
+
},
|
247
|
+
};
|
248
|
+
}
|
249
|
+
//# sourceMappingURL=coMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coMap.js","sourceRoot":"","sources":["../../src/coValues/coMap.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAYxC,OAAO,EACH,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,cAAc,GACjB,MAAM,gBAAgB,CAAC;AAuCxB,MAAM,OAAO,KACT,SAAQ,WAAW;IAWnB,IAAI,OAAO;QAOP,OAAQ,IAAI,CAAC,WAA4B,CAAC,OAAO,CAAC;IACtD,CAAC;IAED,IAAI,KAAK;QAOL,OAAO,QAAQ,CACX,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAa,CAA2B,EAC/D,GAAG,EAAE,CACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CACvB,GAAgC,CAChB,CAAC;YACrB,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI,MAAM,CAAC;QACzC,CAAC,CAAsB,EAC3B,IAAI,CAAC,SAAS,EACd,CAAC,GAAG,EAAE,EAAE,CAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAuB,CAAC,GAAG,EAAE,CACnD,CAAC;IACb,CAAC;IAED,IAAI,MAAM;QAQN,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;YACnB,GAAG,CAAC,MAAM,EAAE,GAAG;gBACX,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAa,CAAC,CAAC;gBACtD,IAAI,CAAC,OAAO;oBAAE,OAAO,SAAS,CAAC;gBAE/B,MAAM,UAAU,GAAG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