@voidhash/mimic 0.0.2 → 0.0.4
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/.turbo/turbo-build.log +257 -42
- package/dist/Document.cjs +152 -0
- package/dist/Document.d.cts +67 -0
- package/dist/Document.d.cts.map +1 -0
- package/dist/Document.d.mts +68 -0
- package/dist/Document.d.mts.map +1 -0
- package/dist/Document.mjs +147 -0
- package/dist/Document.mjs.map +1 -0
- package/dist/EffectSchema.cjs +180 -0
- package/dist/EffectSchema.d.cts +84 -0
- package/dist/EffectSchema.d.cts.map +1 -0
- package/dist/EffectSchema.d.mts +84 -0
- package/dist/EffectSchema.d.mts.map +1 -0
- package/dist/EffectSchema.mjs +176 -0
- package/dist/EffectSchema.mjs.map +1 -0
- package/dist/FractionalIndex.cjs +365 -0
- package/dist/FractionalIndex.mjs +364 -0
- package/dist/FractionalIndex.mjs.map +1 -0
- package/dist/Operation.cjs +53 -0
- package/dist/Operation.d.cts +39 -0
- package/dist/Operation.d.cts.map +1 -0
- package/dist/Operation.d.mts +39 -0
- package/dist/Operation.d.mts.map +1 -0
- package/dist/Operation.mjs +46 -0
- package/dist/Operation.mjs.map +1 -0
- package/dist/OperationDefinition.cjs +13 -0
- package/dist/OperationDefinition.d.cts +12 -0
- package/dist/OperationDefinition.d.cts.map +1 -0
- package/dist/OperationDefinition.d.mts +12 -0
- package/dist/OperationDefinition.d.mts.map +1 -0
- package/dist/OperationDefinition.mjs +13 -0
- package/dist/OperationDefinition.mjs.map +1 -0
- package/dist/OperationPath.cjs +148 -0
- package/dist/OperationPath.d.cts +60 -0
- package/dist/OperationPath.d.cts.map +1 -0
- package/dist/OperationPath.d.mts +60 -0
- package/dist/OperationPath.d.mts.map +1 -0
- package/dist/OperationPath.mjs +138 -0
- package/dist/OperationPath.mjs.map +1 -0
- package/dist/{Presence-gWrmGBeu.cjs → Presence.cjs} +4 -39
- package/dist/{Presence-N8u7Eppr.d.mts → Presence.d.cts} +2 -2
- package/dist/Presence.d.cts.map +1 -0
- package/dist/{Presence-DKKP4v5X.d.cts → Presence.d.mts} +2 -2
- package/dist/Presence.d.mts.map +1 -0
- package/dist/{Presence-DdMVKcOv.mjs → Presence.mjs} +3 -28
- package/dist/Presence.mjs.map +1 -0
- package/dist/Primitive.cjs +52 -0
- package/dist/Primitive.d.cts +20 -0
- package/dist/Primitive.d.cts.map +1 -0
- package/dist/Primitive.d.mts +20 -0
- package/dist/Primitive.d.mts.map +1 -0
- package/dist/Primitive.mjs +48 -0
- package/dist/Primitive.mjs.map +1 -0
- package/dist/ProxyEnvironment.cjs +34 -0
- package/dist/ProxyEnvironment.d.cts +31 -0
- package/dist/ProxyEnvironment.d.cts.map +1 -0
- package/dist/ProxyEnvironment.d.mts +31 -0
- package/dist/ProxyEnvironment.d.mts.map +1 -0
- package/dist/ProxyEnvironment.mjs +29 -0
- package/dist/ProxyEnvironment.mjs.map +1 -0
- package/dist/Transaction.cjs +66 -0
- package/dist/Transaction.d.cts +56 -0
- package/dist/Transaction.d.cts.map +1 -0
- package/dist/Transaction.d.mts +56 -0
- package/dist/Transaction.d.mts.map +1 -0
- package/dist/Transaction.mjs +58 -0
- package/dist/Transaction.mjs.map +1 -0
- package/dist/Transform.cjs +11 -0
- package/dist/Transform.d.cts +21 -0
- package/dist/Transform.d.cts.map +1 -0
- package/dist/Transform.d.mts +21 -0
- package/dist/Transform.d.mts.map +1 -0
- package/dist/Transform.mjs +6 -0
- package/dist/Transform.mjs.map +1 -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 +43 -0
- package/dist/{chunk-CLMFDpHK.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/client/ClientDocument.cjs +590 -0
- package/dist/client/ClientDocument.d.cts +161 -0
- package/dist/client/ClientDocument.d.cts.map +1 -0
- package/dist/client/ClientDocument.d.mts +162 -0
- package/dist/client/ClientDocument.d.mts.map +1 -0
- package/dist/client/ClientDocument.mjs +586 -0
- package/dist/client/ClientDocument.mjs.map +1 -0
- package/dist/client/Rebase.cjs +204 -0
- package/dist/client/Rebase.d.cts +87 -0
- package/dist/client/Rebase.d.cts.map +1 -0
- package/dist/client/Rebase.d.mts +88 -0
- package/dist/client/Rebase.d.mts.map +1 -0
- package/dist/client/Rebase.mjs +198 -0
- package/dist/client/Rebase.mjs.map +1 -0
- package/dist/client/StateMonitor.cjs +133 -0
- package/dist/client/StateMonitor.d.cts +122 -0
- package/dist/client/StateMonitor.d.cts.map +1 -0
- package/dist/client/StateMonitor.d.mts +122 -0
- package/dist/client/StateMonitor.d.mts.map +1 -0
- package/dist/client/StateMonitor.mjs +129 -0
- package/dist/client/StateMonitor.mjs.map +1 -0
- package/dist/client/Transport.cjs +11 -0
- package/dist/client/Transport.d.cts +237 -0
- package/dist/client/Transport.d.cts.map +1 -0
- package/dist/client/Transport.d.mts +237 -0
- package/dist/client/Transport.d.mts.map +1 -0
- package/dist/client/Transport.mjs +6 -0
- package/dist/client/Transport.mjs.map +1 -0
- package/dist/client/WebSocketTransport.cjs +396 -0
- package/dist/client/WebSocketTransport.d.cts +29 -0
- package/dist/client/WebSocketTransport.d.cts.map +1 -0
- package/dist/client/WebSocketTransport.d.mts +29 -0
- package/dist/client/WebSocketTransport.d.mts.map +1 -0
- package/dist/client/WebSocketTransport.mjs +392 -0
- package/dist/client/WebSocketTransport.mjs.map +1 -0
- package/dist/client/errors.cjs +135 -0
- package/dist/client/errors.d.cts +87 -0
- package/dist/client/errors.d.cts.map +1 -0
- package/dist/client/errors.d.mts +87 -0
- package/dist/client/errors.d.mts.map +1 -0
- package/dist/client/errors.mjs +127 -0
- package/dist/client/errors.mjs.map +1 -0
- package/dist/client/index.cjs +22 -1424
- package/dist/client/index.d.cts +8 -692
- package/dist/client/index.d.mts +8 -692
- package/dist/client/index.mjs +9 -1413
- package/dist/index.cjs +20 -2973
- package/dist/index.d.cts +12 -419
- package/dist/index.d.mts +12 -419
- package/dist/index.mjs +13 -2968
- package/dist/primitives/Array.cjs +302 -0
- package/dist/primitives/Array.d.cts +95 -0
- package/dist/primitives/Array.d.cts.map +1 -0
- package/dist/primitives/Array.d.mts +95 -0
- package/dist/primitives/Array.d.mts.map +1 -0
- package/dist/primitives/Array.mjs +301 -0
- package/dist/primitives/Array.mjs.map +1 -0
- package/dist/primitives/Boolean.cjs +95 -0
- package/dist/primitives/Boolean.d.cts +44 -0
- package/dist/primitives/Boolean.d.cts.map +1 -0
- package/dist/primitives/Boolean.d.mts +44 -0
- package/dist/primitives/Boolean.d.mts.map +1 -0
- package/dist/primitives/Boolean.mjs +94 -0
- package/dist/primitives/Boolean.mjs.map +1 -0
- package/dist/primitives/Either.cjs +200 -0
- package/dist/primitives/Either.d.cts +113 -0
- package/dist/primitives/Either.d.cts.map +1 -0
- package/dist/primitives/Either.d.mts +113 -0
- package/dist/primitives/Either.d.mts.map +1 -0
- package/dist/primitives/Either.mjs +199 -0
- package/dist/primitives/Either.mjs.map +1 -0
- package/dist/primitives/Lazy.cjs +46 -0
- package/dist/primitives/Lazy.d.cts +46 -0
- package/dist/primitives/Lazy.d.cts.map +1 -0
- package/dist/primitives/Lazy.d.mts +46 -0
- package/dist/primitives/Lazy.d.mts.map +1 -0
- package/dist/primitives/Lazy.mjs +46 -0
- package/dist/primitives/Lazy.mjs.map +1 -0
- package/dist/primitives/Literal.cjs +91 -0
- package/dist/primitives/Literal.d.cts +46 -0
- package/dist/primitives/Literal.d.cts.map +1 -0
- package/dist/primitives/Literal.d.mts +46 -0
- package/dist/primitives/Literal.d.mts.map +1 -0
- package/dist/primitives/Literal.mjs +90 -0
- package/dist/primitives/Literal.mjs.map +1 -0
- package/dist/primitives/Number.cjs +115 -0
- package/dist/primitives/Number.d.cts +54 -0
- package/dist/primitives/Number.d.cts.map +1 -0
- package/dist/primitives/Number.d.mts +54 -0
- package/dist/primitives/Number.d.mts.map +1 -0
- package/dist/primitives/Number.mjs +114 -0
- package/dist/primitives/Number.mjs.map +1 -0
- package/dist/primitives/String.cjs +127 -0
- package/dist/primitives/String.d.cts +56 -0
- package/dist/primitives/String.d.cts.map +1 -0
- package/dist/primitives/String.d.mts +56 -0
- package/dist/primitives/String.d.mts.map +1 -0
- package/dist/primitives/String.mjs +126 -0
- package/dist/primitives/String.mjs.map +1 -0
- package/dist/primitives/Struct.cjs +207 -0
- package/dist/primitives/Struct.d.cts +96 -0
- package/dist/primitives/Struct.d.cts.map +1 -0
- package/dist/primitives/Struct.d.mts +97 -0
- package/dist/primitives/Struct.d.mts.map +1 -0
- package/dist/primitives/Struct.mjs +206 -0
- package/dist/primitives/Struct.mjs.map +1 -0
- package/dist/primitives/Tree.cjs +575 -0
- package/dist/primitives/Tree.d.cts +185 -0
- package/dist/primitives/Tree.d.cts.map +1 -0
- package/dist/primitives/Tree.d.mts +185 -0
- package/dist/primitives/Tree.d.mts.map +1 -0
- package/dist/primitives/Tree.mjs +574 -0
- package/dist/primitives/Tree.mjs.map +1 -0
- package/dist/primitives/TreeNode.cjs +73 -0
- package/dist/primitives/TreeNode.d.cts +92 -0
- package/dist/primitives/TreeNode.d.cts.map +1 -0
- package/dist/primitives/TreeNode.d.mts +93 -0
- package/dist/primitives/TreeNode.d.mts.map +1 -0
- package/dist/primitives/TreeNode.mjs +72 -0
- package/dist/primitives/TreeNode.mjs.map +1 -0
- package/dist/primitives/Union.cjs +170 -0
- package/dist/primitives/Union.d.cts +81 -0
- package/dist/primitives/Union.d.cts.map +1 -0
- package/dist/primitives/Union.d.mts +81 -0
- package/dist/primitives/Union.d.mts.map +1 -0
- package/dist/primitives/Union.mjs +169 -0
- package/dist/primitives/Union.mjs.map +1 -0
- package/dist/primitives/shared.cjs +60 -0
- package/dist/primitives/shared.d.cts +147 -0
- package/dist/primitives/shared.d.cts.map +1 -0
- package/dist/primitives/shared.d.mts +147 -0
- package/dist/primitives/shared.d.mts.map +1 -0
- package/dist/primitives/shared.mjs +58 -0
- package/dist/primitives/shared.mjs.map +1 -0
- package/dist/server/ServerDocument.cjs +110 -0
- package/dist/server/ServerDocument.d.cts +98 -0
- package/dist/server/ServerDocument.d.cts.map +1 -0
- package/dist/server/ServerDocument.d.mts +99 -0
- package/dist/server/ServerDocument.d.mts.map +1 -0
- package/dist/server/ServerDocument.mjs +106 -0
- package/dist/server/ServerDocument.mjs.map +1 -0
- package/dist/server/errors.cjs +85 -0
- package/dist/server/errors.d.cts +53 -0
- package/dist/server/errors.d.cts.map +1 -0
- package/dist/server/errors.d.mts +53 -0
- package/dist/server/errors.d.mts.map +1 -0
- package/dist/server/errors.mjs +81 -0
- package/dist/server/errors.mjs.map +1 -0
- package/dist/server/index.cjs +9 -185
- package/dist/server/index.d.cts +3 -148
- package/dist/server/index.d.mts +3 -148
- package/dist/server/index.mjs +3 -181
- package/dist/types/index.cjs +16 -0
- package/dist/types/index.d.cts +16 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.mts +16 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +12 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/tree-helpers.cjs +443 -0
- package/dist/utils/tree-helpers.d.cts +280 -0
- package/dist/utils/tree-helpers.d.cts.map +1 -0
- package/dist/utils/tree-helpers.d.mts +280 -0
- package/dist/utils/tree-helpers.d.mts.map +1 -0
- package/dist/utils/tree-helpers.mjs +439 -0
- package/dist/utils/tree-helpers.mjs.map +1 -0
- package/package.json +2 -2
- package/tsdown.config.ts +1 -1
- package/dist/Document-ChuFrTk1.cjs +0 -571
- package/dist/Document-CwiAFTIq.mjs +0 -438
- package/dist/Document-CwiAFTIq.mjs.map +0 -1
- package/dist/Presence-DKKP4v5X.d.cts.map +0 -1
- package/dist/Presence-DdMVKcOv.mjs.map +0 -1
- package/dist/Presence-N8u7Eppr.d.mts.map +0 -1
- package/dist/Primitive-DqQFc3Gu.d.mts +0 -1180
- package/dist/Primitive-DqQFc3Gu.d.mts.map +0 -1
- package/dist/Primitive-awpEjnKL.d.cts +0 -1180
- package/dist/Primitive-awpEjnKL.d.cts.map +0 -1
- package/dist/client/index.d.cts.map +0 -1
- package/dist/client/index.d.mts.map +0 -1
- package/dist/client/index.mjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/server/index.d.cts.map +0 -1
- package/dist/server/index.d.mts.map +0 -1
- package/dist/server/index.mjs.map +0 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { __export } from "./_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/EffectSchema.ts
|
|
5
|
+
/**
|
|
6
|
+
* Effect.Schema utilities for converting Mimic primitives to Effect.Schema schemas.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.0.1
|
|
9
|
+
*/
|
|
10
|
+
var EffectSchema_exports = /* @__PURE__ */ __export({
|
|
11
|
+
TreeNodeStateSchema: () => TreeNodeStateSchema,
|
|
12
|
+
toSetSchema: () => toSetSchema,
|
|
13
|
+
toUpdateSchema: () => toUpdateSchema
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Schema for a tree node state (flat storage format).
|
|
17
|
+
*/
|
|
18
|
+
const TreeNodeStateSchema = Schema.Struct({
|
|
19
|
+
id: Schema.String,
|
|
20
|
+
type: Schema.String,
|
|
21
|
+
parentId: Schema.NullOr(Schema.String),
|
|
22
|
+
pos: Schema.String,
|
|
23
|
+
data: Schema.Unknown
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Check if a field is required for set operations.
|
|
27
|
+
* A field is required if: TRequired is true AND THasDefault is false.
|
|
28
|
+
*
|
|
29
|
+
* We determine this by checking the primitive's schema properties.
|
|
30
|
+
*/
|
|
31
|
+
function isRequiredForSet(primitive) {
|
|
32
|
+
const schema = primitive._schema;
|
|
33
|
+
if (!schema) return false;
|
|
34
|
+
return schema.required === true && schema.defaultValue === void 0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the base Effect.Schema for a primitive type (without optional wrapper).
|
|
38
|
+
*/
|
|
39
|
+
function getBaseSchema(primitive) {
|
|
40
|
+
switch (primitive._tag) {
|
|
41
|
+
case "StringPrimitive": return Schema.String;
|
|
42
|
+
case "NumberPrimitive": return Schema.Number;
|
|
43
|
+
case "BooleanPrimitive": return Schema.Boolean;
|
|
44
|
+
case "LiteralPrimitive": {
|
|
45
|
+
var _schema$literal, _schema;
|
|
46
|
+
const literalPrimitive = primitive;
|
|
47
|
+
const literalValue = (_schema$literal = (_schema = literalPrimitive._schema) === null || _schema === void 0 ? void 0 : _schema.literal) !== null && _schema$literal !== void 0 ? _schema$literal : literalPrimitive.literal;
|
|
48
|
+
return Schema.Literal(literalValue);
|
|
49
|
+
}
|
|
50
|
+
case "StructPrimitive": return buildStructSetSchema(primitive);
|
|
51
|
+
case "ArrayPrimitive": {
|
|
52
|
+
const elementSchema = buildElementSetSchema(primitive.element);
|
|
53
|
+
return Schema.Array(elementSchema);
|
|
54
|
+
}
|
|
55
|
+
case "UnionPrimitive": return buildUnionSetSchema(primitive);
|
|
56
|
+
case "EitherPrimitive": return buildEitherSchema(primitive);
|
|
57
|
+
case "LazyPrimitive": {
|
|
58
|
+
var _resolve, _resolve2;
|
|
59
|
+
const lazyPrimitive = primitive;
|
|
60
|
+
return getBaseSchema((_resolve = (_resolve2 = lazyPrimitive._resolve) === null || _resolve2 === void 0 ? void 0 : _resolve2.call(lazyPrimitive)) !== null && _resolve !== void 0 ? _resolve : lazyPrimitive._thunk());
|
|
61
|
+
}
|
|
62
|
+
case "TreeNodePrimitive": return buildStructSetSchema(primitive.data);
|
|
63
|
+
case "TreePrimitive": return Schema.Array(TreeNodeStateSchema);
|
|
64
|
+
default: return Schema.Unknown;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build the set schema for a struct primitive.
|
|
69
|
+
* Required fields (required=true, no default) are non-optional.
|
|
70
|
+
* Other fields are wrapped with Schema.optional.
|
|
71
|
+
*/
|
|
72
|
+
function buildStructSetSchema(structPrimitive) {
|
|
73
|
+
const fields = structPrimitive.fields;
|
|
74
|
+
const schemaFields = {};
|
|
75
|
+
for (const key in fields) {
|
|
76
|
+
const fieldPrimitive = fields[key];
|
|
77
|
+
const baseSchema = getBaseSchema(fieldPrimitive);
|
|
78
|
+
if (isRequiredForSet(fieldPrimitive)) schemaFields[key] = baseSchema;
|
|
79
|
+
else schemaFields[key] = Schema.optional(baseSchema);
|
|
80
|
+
}
|
|
81
|
+
return Schema.Struct(schemaFields);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Build the update schema for a struct primitive.
|
|
85
|
+
* All fields are optional for partial updates.
|
|
86
|
+
*/
|
|
87
|
+
function buildStructUpdateSchema(structPrimitive) {
|
|
88
|
+
const fields = structPrimitive.fields;
|
|
89
|
+
const schemaFields = {};
|
|
90
|
+
for (const key in fields) {
|
|
91
|
+
const fieldPrimitive = fields[key];
|
|
92
|
+
let fieldSchema;
|
|
93
|
+
if (fieldPrimitive._tag === "StructPrimitive") fieldSchema = buildStructUpdateSchema(fieldPrimitive);
|
|
94
|
+
else fieldSchema = getBaseSchema(fieldPrimitive);
|
|
95
|
+
schemaFields[key] = Schema.optional(fieldSchema);
|
|
96
|
+
}
|
|
97
|
+
return Schema.Struct(schemaFields);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Build the set schema for an array element.
|
|
101
|
+
* For struct elements, uses the struct's set input schema.
|
|
102
|
+
*/
|
|
103
|
+
function buildElementSetSchema(elementPrimitive) {
|
|
104
|
+
if (elementPrimitive._tag === "StructPrimitive") return buildStructSetSchema(elementPrimitive);
|
|
105
|
+
return getBaseSchema(elementPrimitive);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Build the set schema for a union primitive.
|
|
109
|
+
* Creates a Schema.Union of all variant schemas.
|
|
110
|
+
*/
|
|
111
|
+
function buildUnionSetSchema(unionPrimitive) {
|
|
112
|
+
const variants = unionPrimitive.variants;
|
|
113
|
+
const variantSchemas = [];
|
|
114
|
+
for (const key in variants) {
|
|
115
|
+
const variantPrimitive = variants[key];
|
|
116
|
+
variantSchemas.push(buildStructSetSchema(variantPrimitive));
|
|
117
|
+
}
|
|
118
|
+
if (variantSchemas.length === 0) return Schema.Unknown;
|
|
119
|
+
if (variantSchemas.length === 1) return variantSchemas[0];
|
|
120
|
+
return Schema.Union(...variantSchemas);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Build the schema for an either primitive.
|
|
124
|
+
* Creates a Schema.Union of all scalar variant types.
|
|
125
|
+
*/
|
|
126
|
+
function buildEitherSchema(eitherPrimitive) {
|
|
127
|
+
const variants = eitherPrimitive.variants;
|
|
128
|
+
const variantSchemas = [];
|
|
129
|
+
for (const variant of variants) variantSchemas.push(getBaseSchema(variant));
|
|
130
|
+
if (variantSchemas.length === 0) return Schema.Unknown;
|
|
131
|
+
if (variantSchemas.length === 1) return variantSchemas[0];
|
|
132
|
+
return Schema.Union(...variantSchemas);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Build the update schema for a union primitive.
|
|
136
|
+
* Creates a Schema.Union of all variant update schemas.
|
|
137
|
+
*/
|
|
138
|
+
function buildUnionUpdateSchema(unionPrimitive) {
|
|
139
|
+
const variants = unionPrimitive.variants;
|
|
140
|
+
const variantSchemas = [];
|
|
141
|
+
for (const key in variants) {
|
|
142
|
+
const variantPrimitive = variants[key];
|
|
143
|
+
variantSchemas.push(buildStructUpdateSchema(variantPrimitive));
|
|
144
|
+
}
|
|
145
|
+
if (variantSchemas.length === 0) return Schema.Unknown;
|
|
146
|
+
if (variantSchemas.length === 1) return variantSchemas[0];
|
|
147
|
+
return Schema.Union(...variantSchemas);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the update schema for a primitive.
|
|
151
|
+
* For structs, all fields are optional (partial updates).
|
|
152
|
+
* For simple primitives, same as set schema.
|
|
153
|
+
*/
|
|
154
|
+
function getUpdateSchema(primitive) {
|
|
155
|
+
switch (primitive._tag) {
|
|
156
|
+
case "StructPrimitive": return buildStructUpdateSchema(primitive);
|
|
157
|
+
case "UnionPrimitive": return buildUnionUpdateSchema(primitive);
|
|
158
|
+
case "TreeNodePrimitive": return buildStructUpdateSchema(primitive.data);
|
|
159
|
+
case "LazyPrimitive": {
|
|
160
|
+
var _resolve3, _resolve4;
|
|
161
|
+
const lazyPrimitive = primitive;
|
|
162
|
+
return getUpdateSchema((_resolve3 = (_resolve4 = lazyPrimitive._resolve) === null || _resolve4 === void 0 ? void 0 : _resolve4.call(lazyPrimitive)) !== null && _resolve3 !== void 0 ? _resolve3 : lazyPrimitive._thunk());
|
|
163
|
+
}
|
|
164
|
+
default: return getBaseSchema(primitive);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function toSetSchema(primitive) {
|
|
168
|
+
return getBaseSchema(primitive);
|
|
169
|
+
}
|
|
170
|
+
function toUpdateSchema(primitive) {
|
|
171
|
+
return getUpdateSchema(primitive);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
export { EffectSchema_exports };
|
|
176
|
+
//# sourceMappingURL=EffectSchema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EffectSchema.mjs","names":["schemaFields: Record<string, any>","fieldSchema: Schema.Schema<any>","variantSchemas: Schema.Schema<any>[]"],"sources":["../src/EffectSchema.ts"],"sourcesContent":["/**\n * Effect.Schema utilities for converting Mimic primitives to Effect.Schema schemas.\n * \n * @since 0.0.1\n */\nimport { Schema } from \"effect\";\nimport type { AnyPrimitive, InferSetInput, InferUpdateInput } from \"./primitives/shared\";\nimport type { LiteralPrimitive, LiteralValue } from \"./primitives/Literal\";\nimport type { StructPrimitive } from \"./primitives/Struct\";\nimport type { ArrayPrimitive } from \"./primitives/Array\";\nimport type { UnionPrimitive, UnionVariants } from \"./primitives/Union\";\nimport type { EitherPrimitive, ScalarPrimitive } from \"./primitives/Either\";\nimport type { LazyPrimitive } from \"./primitives/Lazy\";\nimport type { TreeNodePrimitive, AnyTreeNodePrimitive } from \"./primitives/TreeNode\";\n\n// =============================================================================\n// Type-level Schema Inference\n// =============================================================================\n\n/**\n * Infer the Effect.Schema type for a primitive's set input.\n */\nexport type ToSetSchema<T extends AnyPrimitive> = Schema.Schema<InferSetInput<T>>;\n\n/**\n * Infer the Effect.Schema type for a primitive's update input.\n */\nexport type ToUpdateSchema<T extends AnyPrimitive> = Schema.Schema<InferUpdateInput<T>>;\n\n/**\n * Type for TreeNode set schema - uses the node's data set input type\n */\nexport type ToTreeNodeSetSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferSetInput<T[\"data\"]>>;\n\n/**\n * Type for TreeNode update schema - uses the node's data update input type\n */\nexport type ToTreeNodeUpdateSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferUpdateInput<T[\"data\"]>>;\n\n// =============================================================================\n// Schema for TreeNodeState\n// =============================================================================\n\n/**\n * Schema for a tree node state (flat storage format).\n */\nexport const TreeNodeStateSchema = Schema.Struct({\n id: Schema.String,\n type: Schema.String,\n parentId: Schema.NullOr(Schema.String),\n pos: Schema.String,\n data: Schema.Unknown,\n});\n\n// =============================================================================\n// Internal type for primitives (including those that don't implement full Primitive interface)\n// =============================================================================\n\n/**\n * Internal type for anything that can be converted to a schema.\n * This includes both AnyPrimitive and AnyTreeNodePrimitive.\n */\ntype ConvertiblePrimitive = { _tag: string };\n\n// =============================================================================\n// Runtime Conversion Functions\n// =============================================================================\n\n/**\n * Check if a field is required for set operations.\n * A field is required if: TRequired is true AND THasDefault is false.\n * \n * We determine this by checking the primitive's schema properties.\n */\nfunction isRequiredForSet(primitive: ConvertiblePrimitive): boolean {\n // Access the private schema to check required and default status\n const schema = (primitive as any)._schema;\n if (!schema) return false;\n \n return schema.required === true && schema.defaultValue === undefined;\n}\n\n/**\n * Get the base Effect.Schema for a primitive type (without optional wrapper).\n */\nfunction getBaseSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {\n switch (primitive._tag) {\n case \"StringPrimitive\":\n return Schema.String;\n \n case \"NumberPrimitive\":\n return Schema.Number;\n \n case \"BooleanPrimitive\":\n return Schema.Boolean;\n \n case \"LiteralPrimitive\": {\n const literalPrimitive = primitive as unknown as LiteralPrimitive<LiteralValue, any, any>;\n const literalValue = (literalPrimitive as any)._schema?.literal ?? (literalPrimitive as any).literal;\n return Schema.Literal(literalValue);\n }\n \n case \"StructPrimitive\": {\n const structPrimitive = primitive as unknown as StructPrimitive<Record<string, AnyPrimitive>, any, any>;\n return buildStructSetSchema(structPrimitive);\n }\n \n case \"ArrayPrimitive\": {\n const arrayPrimitive = primitive as unknown as ArrayPrimitive<AnyPrimitive, any, any>;\n const elementSchema = buildElementSetSchema(arrayPrimitive.element);\n return Schema.Array(elementSchema);\n }\n \n case \"UnionPrimitive\": {\n const unionPrimitive = primitive as unknown as UnionPrimitive<UnionVariants, any, any, any>;\n return buildUnionSetSchema(unionPrimitive);\n }\n \n case \"EitherPrimitive\": {\n const eitherPrimitive = primitive as unknown as EitherPrimitive<readonly ScalarPrimitive[], any, any>;\n return buildEitherSchema(eitherPrimitive);\n }\n \n case \"LazyPrimitive\": {\n const lazyPrimitive = primitive as unknown as LazyPrimitive<() => AnyPrimitive>;\n // Resolve the lazy primitive and get its schema\n const resolved = (lazyPrimitive as any)._resolve?.() ?? (lazyPrimitive as any)._thunk();\n return getBaseSchema(resolved);\n }\n \n case \"TreeNodePrimitive\": {\n const treeNodePrimitive = primitive as unknown as TreeNodePrimitive<string, StructPrimitive<any>, any>;\n // TreeNode delegates to its data struct\n return buildStructSetSchema(treeNodePrimitive.data);\n }\n \n case \"TreePrimitive\": {\n // Tree returns an array of TreeNodeState\n return Schema.Array(TreeNodeStateSchema);\n }\n \n default:\n return Schema.Unknown;\n }\n}\n\n/**\n * Build the set schema for a struct primitive.\n * Required fields (required=true, no default) are non-optional.\n * Other fields are wrapped with Schema.optional.\n */\nfunction buildStructSetSchema(structPrimitive: StructPrimitive<Record<string, AnyPrimitive>, any, any>): Schema.Schema<any> {\n const fields = structPrimitive.fields;\n // Use any to avoid complex Schema type constraints\n const schemaFields: Record<string, any> = {};\n \n for (const key in fields) {\n const fieldPrimitive = fields[key]!;\n const baseSchema = getBaseSchema(fieldPrimitive);\n \n if (isRequiredForSet(fieldPrimitive)) {\n // Required field - use base schema directly\n schemaFields[key] = baseSchema;\n } else {\n // Optional field - wrap with Schema.optional\n schemaFields[key] = Schema.optional(baseSchema);\n }\n }\n \n return Schema.Struct(schemaFields) as any;\n}\n\n/**\n * Build the update schema for a struct primitive.\n * All fields are optional for partial updates.\n */\nfunction buildStructUpdateSchema(structPrimitive: StructPrimitive<Record<string, AnyPrimitive>, any, any>): Schema.Schema<any> {\n const fields = structPrimitive.fields;\n // Use any to avoid complex Schema type constraints\n const schemaFields: Record<string, any> = {};\n \n for (const key in fields) {\n const fieldPrimitive = fields[key]!;\n // For update, use the update schema for nested structs, otherwise base schema\n let fieldSchema: Schema.Schema<any>;\n \n if (fieldPrimitive._tag === \"StructPrimitive\") {\n fieldSchema = buildStructUpdateSchema(fieldPrimitive as StructPrimitive<Record<string, AnyPrimitive>, any, any>);\n } else {\n fieldSchema = getBaseSchema(fieldPrimitive);\n }\n \n // All fields are optional in update\n schemaFields[key] = Schema.optional(fieldSchema);\n }\n \n return Schema.Struct(schemaFields) as any;\n}\n\n/**\n * Build the set schema for an array element.\n * For struct elements, uses the struct's set input schema.\n */\nfunction buildElementSetSchema(elementPrimitive: AnyPrimitive): Schema.Schema<any> {\n if (elementPrimitive._tag === \"StructPrimitive\") {\n return buildStructSetSchema(elementPrimitive as StructPrimitive<Record<string, AnyPrimitive>, any, any>);\n }\n return getBaseSchema(elementPrimitive);\n}\n\n/**\n * Build the set schema for a union primitive.\n * Creates a Schema.Union of all variant schemas.\n */\nfunction buildUnionSetSchema(unionPrimitive: UnionPrimitive<UnionVariants, any, any, any>): Schema.Schema<any> {\n const variants = unionPrimitive.variants;\n const variantSchemas: Schema.Schema<any>[] = [];\n \n for (const key in variants) {\n const variantPrimitive = variants[key]!;\n variantSchemas.push(buildStructSetSchema(variantPrimitive));\n }\n \n if (variantSchemas.length === 0) {\n return Schema.Unknown;\n }\n \n if (variantSchemas.length === 1) {\n return variantSchemas[0]!;\n }\n \n return Schema.Union(...variantSchemas as [Schema.Schema<any>, Schema.Schema<any>, ...Schema.Schema<any>[]]);\n}\n\n/**\n * Build the schema for an either primitive.\n * Creates a Schema.Union of all scalar variant types.\n */\nfunction buildEitherSchema(eitherPrimitive: EitherPrimitive<readonly ScalarPrimitive[], any, any>): Schema.Schema<any> {\n const variants = eitherPrimitive.variants;\n const variantSchemas: Schema.Schema<any>[] = [];\n \n for (const variant of variants) {\n variantSchemas.push(getBaseSchema(variant as unknown as ConvertiblePrimitive));\n }\n \n if (variantSchemas.length === 0) {\n return Schema.Unknown;\n }\n \n if (variantSchemas.length === 1) {\n return variantSchemas[0]!;\n }\n \n return Schema.Union(...variantSchemas as [Schema.Schema<any>, Schema.Schema<any>, ...Schema.Schema<any>[]]);\n}\n\n/**\n * Build the update schema for a union primitive.\n * Creates a Schema.Union of all variant update schemas.\n */\nfunction buildUnionUpdateSchema(unionPrimitive: UnionPrimitive<UnionVariants, any, any, any>): Schema.Schema<any> {\n const variants = unionPrimitive.variants;\n const variantSchemas: Schema.Schema<any>[] = [];\n \n for (const key in variants) {\n const variantPrimitive = variants[key]!;\n variantSchemas.push(buildStructUpdateSchema(variantPrimitive));\n }\n \n if (variantSchemas.length === 0) {\n return Schema.Unknown;\n }\n \n if (variantSchemas.length === 1) {\n return variantSchemas[0]!;\n }\n \n return Schema.Union(...variantSchemas as [Schema.Schema<any>, Schema.Schema<any>, ...Schema.Schema<any>[]]);\n}\n\n/**\n * Get the update schema for a primitive.\n * For structs, all fields are optional (partial updates).\n * For simple primitives, same as set schema.\n */\nfunction getUpdateSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {\n switch (primitive._tag) {\n case \"StructPrimitive\": {\n const structPrimitive = primitive as unknown as StructPrimitive<Record<string, AnyPrimitive>, any, any>;\n return buildStructUpdateSchema(structPrimitive);\n }\n \n case \"UnionPrimitive\": {\n const unionPrimitive = primitive as unknown as UnionPrimitive<UnionVariants, any, any, any>;\n return buildUnionUpdateSchema(unionPrimitive);\n }\n \n case \"TreeNodePrimitive\": {\n const treeNodePrimitive = primitive as unknown as TreeNodePrimitive<string, StructPrimitive<any>, any>;\n // TreeNode update delegates to data struct's update schema (all fields optional)\n return buildStructUpdateSchema(treeNodePrimitive.data);\n }\n \n case \"LazyPrimitive\": {\n const lazyPrimitive = primitive as unknown as LazyPrimitive<() => AnyPrimitive>;\n const resolved = (lazyPrimitive as any)._resolve?.() ?? (lazyPrimitive as any)._thunk();\n return getUpdateSchema(resolved);\n }\n \n default:\n // For simple primitives, update schema is same as set schema\n return getBaseSchema(primitive);\n }\n}\n\n// =============================================================================\n// Public API\n// =============================================================================\n\n/**\n * Convert a Mimic primitive to an Effect.Schema for set operations.\n * \n * The resulting schema:\n * - For structs: required fields (required=true, no default) are non-optional, others are optional\n * - For arrays: uses the element's set schema\n * - For unions: creates a Schema.Union of variant schemas\n * - For TreeNode: delegates to the node's data struct schema\n * - For Tree: returns Schema.Array of TreeNodeState\n * \n * @example\n * ```typescript\n * const UserSchema = Primitive.Struct({\n * name: Primitive.String().required(),\n * age: Primitive.Number().default(0),\n * email: Primitive.String(),\n * });\n * \n * const SetSchema = toSetSchema(UserSchema);\n * // { name: string, age?: number, email?: string }\n * ```\n */\nexport function toSetSchema<T extends AnyPrimitive>(primitive: T): ToSetSchema<T>;\nexport function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeSetSchema<T>;\nexport function toSetSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {\n return getBaseSchema(primitive);\n}\n\n/**\n * Convert a Mimic primitive to an Effect.Schema for update operations.\n * \n * The resulting schema:\n * - For structs: all fields are optional (partial updates)\n * - For unions: all variant fields are optional\n * - For TreeNode: delegates to the node's data struct update schema\n * - For simple primitives: same as set schema\n * \n * @example\n * ```typescript\n * const UserSchema = Primitive.Struct({\n * name: Primitive.String().required(),\n * age: Primitive.Number().default(0),\n * email: Primitive.String(),\n * });\n * \n * const UpdateSchema = toUpdateSchema(UserSchema);\n * // { name?: string, age?: string, email?: string }\n * ```\n */\nexport function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;\nexport function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;\nexport function toUpdateSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {\n return getUpdateSchema(primitive);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let effect = require("effect");
|
|
3
|
+
|
|
4
|
+
//#region src/FractionalIndex.ts
|
|
5
|
+
function createCharSetDicts(charSet) {
|
|
6
|
+
const byCode = {};
|
|
7
|
+
const byChar = {};
|
|
8
|
+
const length = charSet.length;
|
|
9
|
+
for (let i = 0; i < length; i++) {
|
|
10
|
+
const char = charSet[i];
|
|
11
|
+
if (char === void 0) throw new Error("invalid charSet: missing character at index " + i);
|
|
12
|
+
byCode[i] = char;
|
|
13
|
+
byChar[char] = i;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
byCode,
|
|
17
|
+
byChar,
|
|
18
|
+
length
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function integerLimits(dicts, firstPositive, mostPositive, mostNegative) {
|
|
22
|
+
return effect.Effect.gen(function* () {
|
|
23
|
+
const firstPositiveIndex = firstPositive ? dicts.byChar[firstPositive] : Math.ceil(dicts.length / 2);
|
|
24
|
+
const mostPositiveIndex = mostPositive ? dicts.byChar[mostPositive] : dicts.length - 1;
|
|
25
|
+
const mostNegativeIndex = mostNegative ? dicts.byChar[mostNegative] : 0;
|
|
26
|
+
if (firstPositiveIndex === void 0 || mostPositiveIndex === void 0 || mostNegativeIndex === void 0) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet"));
|
|
27
|
+
if (mostPositiveIndex - firstPositiveIndex < 3) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("mostPositive must be at least 3 characters away from neutral"));
|
|
28
|
+
if (firstPositiveIndex - mostNegativeIndex < 3) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("mostNegative must be at least 3 characters away from neutral"));
|
|
29
|
+
const firstPositiveChar = dicts.byCode[firstPositiveIndex];
|
|
30
|
+
const mostPositiveChar = dicts.byCode[mostPositiveIndex];
|
|
31
|
+
const firstNegativeChar = dicts.byCode[firstPositiveIndex - 1];
|
|
32
|
+
const mostNegativeChar = dicts.byCode[mostNegativeIndex];
|
|
33
|
+
if (firstPositiveChar === void 0 || mostPositiveChar === void 0 || firstNegativeChar === void 0 || mostNegativeChar === void 0) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet"));
|
|
34
|
+
return {
|
|
35
|
+
firstPositive: firstPositiveChar,
|
|
36
|
+
mostPositive: mostPositiveChar,
|
|
37
|
+
firstNegative: firstNegativeChar,
|
|
38
|
+
mostNegative: mostNegativeChar
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function paddingDict(jitterRange, charSetLength) {
|
|
43
|
+
const paddingDict$1 = {};
|
|
44
|
+
for (let i = 0; i < 100; i++) {
|
|
45
|
+
const value = Math.pow(charSetLength, i);
|
|
46
|
+
paddingDict$1[i] = value;
|
|
47
|
+
if (value > jitterRange) break;
|
|
48
|
+
}
|
|
49
|
+
return paddingDict$1;
|
|
50
|
+
}
|
|
51
|
+
function validateChars(characters) {
|
|
52
|
+
if (characters.length < 7) return effect.Effect.fail(/* @__PURE__ */ new Error("charSet must be at least 7 characters long"));
|
|
53
|
+
if (!(characters.split("").sort().join("") === characters)) return effect.Effect.fail(/* @__PURE__ */ new Error("charSet must be sorted"));
|
|
54
|
+
return effect.Effect.void;
|
|
55
|
+
}
|
|
56
|
+
function indexCharacterSet(options) {
|
|
57
|
+
return effect.Effect.gen(function* () {
|
|
58
|
+
var _options$jitterRange;
|
|
59
|
+
yield* validateChars(options.chars);
|
|
60
|
+
const dicts = createCharSetDicts(options.chars);
|
|
61
|
+
const limits = yield* integerLimits(dicts, options.firstPositive, options.mostPositive, options.mostNegative);
|
|
62
|
+
const jitterRange = (_options$jitterRange = options.jitterRange) !== null && _options$jitterRange !== void 0 ? _options$jitterRange : Math.floor(Math.pow(dicts.length, 3) / 5);
|
|
63
|
+
const paddingRange = paddingDict(jitterRange, dicts.length);
|
|
64
|
+
const first = dicts.byCode[0];
|
|
65
|
+
const last = dicts.byCode[dicts.length - 1];
|
|
66
|
+
if (first === void 0 || last === void 0) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet"));
|
|
67
|
+
return {
|
|
68
|
+
chars: options.chars,
|
|
69
|
+
byChar: dicts.byChar,
|
|
70
|
+
byCode: dicts.byCode,
|
|
71
|
+
length: dicts.length,
|
|
72
|
+
first,
|
|
73
|
+
last,
|
|
74
|
+
firstPositive: limits.firstPositive,
|
|
75
|
+
mostPositive: limits.mostPositive,
|
|
76
|
+
firstNegative: limits.firstNegative,
|
|
77
|
+
mostNegative: limits.mostNegative,
|
|
78
|
+
jitterRange,
|
|
79
|
+
paddingDict: paddingRange
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
let _base62CharSet = null;
|
|
84
|
+
function base62CharSet() {
|
|
85
|
+
if (_base62CharSet) return _base62CharSet;
|
|
86
|
+
_base62CharSet = effect.Effect.runSync(indexCharacterSet({
|
|
87
|
+
chars: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
88
|
+
firstPositive: "a",
|
|
89
|
+
mostPositive: "z",
|
|
90
|
+
mostNegative: "A"
|
|
91
|
+
}));
|
|
92
|
+
return _base62CharSet;
|
|
93
|
+
}
|
|
94
|
+
function makeSameLength(a, b, pad, fillChar, forceLength) {
|
|
95
|
+
const max = forceLength !== null && forceLength !== void 0 ? forceLength : Math.max(a.length, b.length);
|
|
96
|
+
if (pad === "start") return [a.padStart(max, fillChar), b.padStart(max, fillChar)];
|
|
97
|
+
return [a.padEnd(max, fillChar), b.padEnd(max, fillChar)];
|
|
98
|
+
}
|
|
99
|
+
function distanceBetween(a, b, charSet) {
|
|
100
|
+
const indexA = charSet.byChar[a];
|
|
101
|
+
const indexB = charSet.byChar[b];
|
|
102
|
+
if (indexA === void 0 || indexB === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character in distance calculation"));
|
|
103
|
+
return effect.Effect.succeed(Math.abs(indexA - indexB));
|
|
104
|
+
}
|
|
105
|
+
function integerLengthFromSecondLevel(key, direction, charSet) {
|
|
106
|
+
if (key.length === 0) return effect.Effect.succeed(0);
|
|
107
|
+
const firstChar = key[0];
|
|
108
|
+
if (!firstChar || firstChar > charSet.mostPositive || firstChar < charSet.mostNegative) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid firstChar on key"));
|
|
109
|
+
if (firstChar === charSet.mostPositive && direction === "positive") return effect.Effect.gen(function* () {
|
|
110
|
+
const totalPositiveRoom = yield* distanceBetween(firstChar, charSet.mostNegative, charSet);
|
|
111
|
+
const rest = yield* integerLengthFromSecondLevel(key.slice(1), direction, charSet);
|
|
112
|
+
return totalPositiveRoom + 1 + rest;
|
|
113
|
+
});
|
|
114
|
+
if (firstChar === charSet.mostNegative && direction === "negative") return effect.Effect.gen(function* () {
|
|
115
|
+
const totalNegativeRoom = yield* distanceBetween(firstChar, charSet.mostPositive, charSet);
|
|
116
|
+
const rest = yield* integerLengthFromSecondLevel(key.slice(1), direction, charSet);
|
|
117
|
+
return totalNegativeRoom + 1 + rest;
|
|
118
|
+
});
|
|
119
|
+
if (direction === "positive") return effect.Effect.gen(function* () {
|
|
120
|
+
return (yield* distanceBetween(firstChar, charSet.mostNegative, charSet)) + 2;
|
|
121
|
+
});
|
|
122
|
+
else return effect.Effect.gen(function* () {
|
|
123
|
+
return (yield* distanceBetween(firstChar, charSet.mostPositive, charSet)) + 2;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function integerLength(head, charSet) {
|
|
127
|
+
if (head.length === 0) return effect.Effect.fail(/* @__PURE__ */ new Error("head cannot be empty"));
|
|
128
|
+
const firstChar = head[0];
|
|
129
|
+
if (!firstChar || firstChar > charSet.mostPositive || firstChar < charSet.mostNegative) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid firstChar on key"));
|
|
130
|
+
if (firstChar === charSet.mostPositive) return effect.Effect.gen(function* () {
|
|
131
|
+
const firstLevel = yield* distanceBetween(firstChar, charSet.firstPositive, charSet);
|
|
132
|
+
const rest = yield* integerLengthFromSecondLevel(head.slice(1), "positive", charSet);
|
|
133
|
+
return firstLevel + 1 + rest;
|
|
134
|
+
});
|
|
135
|
+
if (firstChar === charSet.mostNegative) return effect.Effect.gen(function* () {
|
|
136
|
+
const firstLevel = yield* distanceBetween(firstChar, charSet.firstNegative, charSet);
|
|
137
|
+
const rest = yield* integerLengthFromSecondLevel(head.slice(1), "negative", charSet);
|
|
138
|
+
return firstLevel + 1 + rest;
|
|
139
|
+
});
|
|
140
|
+
if (firstChar >= charSet.firstPositive) return effect.Effect.gen(function* () {
|
|
141
|
+
return (yield* distanceBetween(firstChar, charSet.firstPositive, charSet)) + 2;
|
|
142
|
+
});
|
|
143
|
+
else return effect.Effect.gen(function* () {
|
|
144
|
+
return (yield* distanceBetween(firstChar, charSet.firstNegative, charSet)) + 2;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function encodeToCharSet(int, charSet) {
|
|
148
|
+
if (int === 0) {
|
|
149
|
+
const zero = charSet.byCode[0];
|
|
150
|
+
if (zero === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet: missing code 0"));
|
|
151
|
+
return effect.Effect.succeed(zero);
|
|
152
|
+
}
|
|
153
|
+
let res = "";
|
|
154
|
+
const max = charSet.length;
|
|
155
|
+
while (int > 0) {
|
|
156
|
+
const code = charSet.byCode[int % max];
|
|
157
|
+
if (code === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character code in encodeToCharSet"));
|
|
158
|
+
res = code + res;
|
|
159
|
+
int = Math.floor(int / max);
|
|
160
|
+
}
|
|
161
|
+
return effect.Effect.succeed(res);
|
|
162
|
+
}
|
|
163
|
+
function decodeCharSetToNumber(key, charSet) {
|
|
164
|
+
let res = 0;
|
|
165
|
+
const length = key.length;
|
|
166
|
+
const max = charSet.length;
|
|
167
|
+
for (let i = 0; i < length; i++) {
|
|
168
|
+
const char = key[i];
|
|
169
|
+
if (char === void 0) continue;
|
|
170
|
+
const charIndex = charSet.byChar[char];
|
|
171
|
+
if (charIndex === void 0) continue;
|
|
172
|
+
res += charIndex * Math.pow(max, length - i - 1);
|
|
173
|
+
}
|
|
174
|
+
return res;
|
|
175
|
+
}
|
|
176
|
+
function addCharSetKeys(a, b, charSet) {
|
|
177
|
+
const base = charSet.length;
|
|
178
|
+
const [paddedA, paddedB] = makeSameLength(a, b, "start", charSet.first);
|
|
179
|
+
const result = [];
|
|
180
|
+
let carry = 0;
|
|
181
|
+
for (let i = paddedA.length - 1; i >= 0; i--) {
|
|
182
|
+
const charA = paddedA[i];
|
|
183
|
+
const charB = paddedB[i];
|
|
184
|
+
if (!charA || !charB) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character in addCharSetKeys"));
|
|
185
|
+
const digitA = charSet.byChar[charA];
|
|
186
|
+
const digitB = charSet.byChar[charB];
|
|
187
|
+
if (digitA === void 0 || digitB === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character in addCharSetKeys"));
|
|
188
|
+
const sum = digitA + digitB + carry;
|
|
189
|
+
carry = Math.floor(sum / base);
|
|
190
|
+
const remainder = sum % base;
|
|
191
|
+
const codeChar = charSet.byCode[remainder];
|
|
192
|
+
if (codeChar === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character code in addCharSetKeys"));
|
|
193
|
+
result.unshift(codeChar);
|
|
194
|
+
}
|
|
195
|
+
if (carry > 0) {
|
|
196
|
+
const carryChar = charSet.byCode[carry];
|
|
197
|
+
if (carryChar === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid carry character code"));
|
|
198
|
+
result.unshift(carryChar);
|
|
199
|
+
}
|
|
200
|
+
return effect.Effect.succeed(result.join(""));
|
|
201
|
+
}
|
|
202
|
+
function subtractCharSetKeys(a, b, charSet, stripLeadingZeros = true) {
|
|
203
|
+
const base = charSet.length;
|
|
204
|
+
const [paddedA, paddedB] = makeSameLength(a, b, "start", charSet.first);
|
|
205
|
+
const result = [];
|
|
206
|
+
let borrow = 0;
|
|
207
|
+
for (let i = paddedA.length - 1; i >= 0; i--) {
|
|
208
|
+
const charA = paddedA[i];
|
|
209
|
+
const charB = paddedB[i];
|
|
210
|
+
if (!charA || !charB) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character in subtractCharSetKeys"));
|
|
211
|
+
let digitA = charSet.byChar[charA];
|
|
212
|
+
const digitBValue = charSet.byChar[charB];
|
|
213
|
+
if (digitA === void 0 || digitBValue === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character in subtractCharSetKeys"));
|
|
214
|
+
const digitB = digitBValue + borrow;
|
|
215
|
+
if (digitA < digitB) {
|
|
216
|
+
borrow = 1;
|
|
217
|
+
digitA += base;
|
|
218
|
+
} else borrow = 0;
|
|
219
|
+
const difference = digitA - digitB;
|
|
220
|
+
const codeChar = charSet.byCode[difference];
|
|
221
|
+
if (codeChar === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid character code in subtractCharSetKeys"));
|
|
222
|
+
result.unshift(codeChar);
|
|
223
|
+
}
|
|
224
|
+
if (borrow > 0) return effect.Effect.fail(/* @__PURE__ */ new Error("Subtraction result is negative. Ensure a is greater than or equal to b."));
|
|
225
|
+
while (stripLeadingZeros && result.length > 1 && result[0] === charSet.first) result.shift();
|
|
226
|
+
return effect.Effect.succeed(result.join(""));
|
|
227
|
+
}
|
|
228
|
+
function incrementKey(key, charSet) {
|
|
229
|
+
const one = charSet.byCode[1];
|
|
230
|
+
if (one === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet: missing code 1"));
|
|
231
|
+
return addCharSetKeys(key, one, charSet);
|
|
232
|
+
}
|
|
233
|
+
function decrementKey(key, charSet) {
|
|
234
|
+
const one = charSet.byCode[1];
|
|
235
|
+
if (one === void 0) return effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet: missing code 1"));
|
|
236
|
+
return subtractCharSetKeys(key, one, charSet, false);
|
|
237
|
+
}
|
|
238
|
+
function lexicalDistance(a, b, charSet) {
|
|
239
|
+
const [lower, upper] = makeSameLength(a, b, "end", charSet.first).sort();
|
|
240
|
+
return effect.Effect.gen(function* () {
|
|
241
|
+
return decodeCharSetToNumber(yield* subtractCharSetKeys(upper, lower, charSet), charSet);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
function midPoint(lower, upper, charSet) {
|
|
245
|
+
return effect.Effect.gen(function* () {
|
|
246
|
+
let [paddedLower, paddedUpper] = makeSameLength(lower, upper, "end", charSet.first);
|
|
247
|
+
let distance = yield* lexicalDistance(paddedLower, paddedUpper, charSet);
|
|
248
|
+
if (distance === 1) {
|
|
249
|
+
paddedLower = paddedLower.padEnd(paddedLower.length + 1, charSet.first);
|
|
250
|
+
distance = charSet.length;
|
|
251
|
+
}
|
|
252
|
+
const mid = yield* encodeToCharSet(Math.floor(distance / 2), charSet);
|
|
253
|
+
return yield* addCharSetKeys(paddedLower, mid, charSet);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function startKey(charSet) {
|
|
257
|
+
return charSet.firstPositive + charSet.byCode[0];
|
|
258
|
+
}
|
|
259
|
+
function validInteger(integer, charSet) {
|
|
260
|
+
return effect.Effect.gen(function* () {
|
|
261
|
+
return (yield* integerLength(integer, charSet)) === integer.length;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function validateOrderKey(orderKey, charSet) {
|
|
265
|
+
return effect.Effect.gen(function* () {
|
|
266
|
+
yield* getIntegerPart(orderKey, charSet);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function getIntegerPart(orderKey, charSet) {
|
|
270
|
+
return effect.Effect.gen(function* () {
|
|
271
|
+
const integerPartLength = yield* integerLength(integerHead(orderKey, charSet), charSet);
|
|
272
|
+
if (integerPartLength > orderKey.length) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid order key length: " + orderKey));
|
|
273
|
+
return orderKey.slice(0, integerPartLength);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function validateInteger(integer, charSet) {
|
|
277
|
+
return effect.Effect.gen(function* () {
|
|
278
|
+
if (!(yield* validInteger(integer, charSet))) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid integer length: " + integer));
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function integerHead(integer, charSet) {
|
|
282
|
+
let i = 0;
|
|
283
|
+
if (integer[0] === charSet.mostPositive) while (integer[i] === charSet.mostPositive) i = i + 1;
|
|
284
|
+
if (integer[0] === charSet.mostNegative) while (integer[i] === charSet.mostNegative) i = i + 1;
|
|
285
|
+
return integer.slice(0, i + 1);
|
|
286
|
+
}
|
|
287
|
+
function splitInteger(integer, charSet) {
|
|
288
|
+
return effect.Effect.gen(function* () {
|
|
289
|
+
const head = integerHead(integer, {
|
|
290
|
+
firstPositive: charSet.firstPositive,
|
|
291
|
+
mostPositive: charSet.mostPositive,
|
|
292
|
+
firstNegative: charSet.firstNegative,
|
|
293
|
+
mostNegative: charSet.mostNegative
|
|
294
|
+
});
|
|
295
|
+
return [head, integer.slice(head.length)];
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function incrementIntegerHead(head, charSet) {
|
|
299
|
+
return effect.Effect.gen(function* () {
|
|
300
|
+
const inPositiveRange = head >= charSet.firstPositive;
|
|
301
|
+
const nextHead = yield* incrementKey(head, charSet);
|
|
302
|
+
const headIsLimitMax = head[head.length - 1] === charSet.mostPositive;
|
|
303
|
+
const nextHeadIsLimitMax = nextHead[nextHead.length - 1] === charSet.mostPositive;
|
|
304
|
+
if (inPositiveRange && nextHeadIsLimitMax) return nextHead + charSet.mostNegative;
|
|
305
|
+
if (!inPositiveRange && headIsLimitMax) return head.slice(0, head.length - 1);
|
|
306
|
+
return nextHead;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
function decrementIntegerHead(head, charSet) {
|
|
310
|
+
return effect.Effect.gen(function* () {
|
|
311
|
+
const inPositiveRange = head >= charSet.firstPositive;
|
|
312
|
+
const headIsLimitMin = head[head.length - 1] === charSet.mostNegative;
|
|
313
|
+
if (inPositiveRange && headIsLimitMin) return yield* decrementKey(head.slice(0, head.length - 1), charSet);
|
|
314
|
+
if (!inPositiveRange && headIsLimitMin) return head + charSet.mostPositive;
|
|
315
|
+
return yield* decrementKey(head, charSet);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function startOnNewHead(head, limit, charSet) {
|
|
319
|
+
return effect.Effect.gen(function* () {
|
|
320
|
+
const newLength = yield* integerLength(head, charSet);
|
|
321
|
+
const fillCharCode = limit === "upper" ? charSet.length - 1 : 0;
|
|
322
|
+
const fillChar = charSet.byCode[fillCharCode];
|
|
323
|
+
if (fillChar === void 0) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid fill character code"));
|
|
324
|
+
return head + fillChar.repeat(newLength - head.length);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function incrementInteger(integer, charSet) {
|
|
328
|
+
return effect.Effect.gen(function* () {
|
|
329
|
+
yield* validateInteger(integer, charSet);
|
|
330
|
+
const [head, digs] = yield* splitInteger(integer, charSet);
|
|
331
|
+
const maxChar = charSet.byCode[charSet.length - 1];
|
|
332
|
+
if (maxChar === void 0) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet: missing max character"));
|
|
333
|
+
if (digs.split("").some((d) => d !== maxChar)) return head + (yield* incrementKey(digs, charSet));
|
|
334
|
+
return yield* startOnNewHead(yield* incrementIntegerHead(head, charSet), "lower", charSet);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function decrementInteger(integer, charSet) {
|
|
338
|
+
return effect.Effect.gen(function* () {
|
|
339
|
+
yield* validateInteger(integer, charSet);
|
|
340
|
+
const [head, digs] = yield* splitInteger(integer, charSet);
|
|
341
|
+
const minChar = charSet.byCode[0];
|
|
342
|
+
if (minChar === void 0) return yield* effect.Effect.fail(/* @__PURE__ */ new Error("invalid charSet: missing min character"));
|
|
343
|
+
if (digs.split("").some((d) => d !== minChar)) return head + (yield* decrementKey(digs, charSet));
|
|
344
|
+
return yield* startOnNewHead(yield* decrementIntegerHead(head, charSet), "upper", charSet);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Generate a key between two other keys.
|
|
349
|
+
* If either lower or upper is null, the key will be generated at the start or end of the list.
|
|
350
|
+
*/
|
|
351
|
+
function generateKeyBetween(lower, upper, charSet = base62CharSet()) {
|
|
352
|
+
return effect.Effect.gen(function* () {
|
|
353
|
+
if (lower !== null) yield* validateOrderKey(lower, charSet);
|
|
354
|
+
if (upper !== null) yield* validateOrderKey(upper, charSet);
|
|
355
|
+
if (lower === null && upper === null) return startKey(charSet);
|
|
356
|
+
if (lower === null) return yield* decrementInteger(yield* getIntegerPart(upper, charSet), charSet);
|
|
357
|
+
if (upper === null) return yield* incrementInteger(yield* getIntegerPart(lower, charSet), charSet);
|
|
358
|
+
if (lower >= upper) return yield* effect.Effect.fail(/* @__PURE__ */ new Error(lower + " >= " + upper));
|
|
359
|
+
return yield* midPoint(lower, upper, charSet);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
//#endregion
|
|
364
|
+
exports.base62CharSet = base62CharSet;
|
|
365
|
+
exports.generateKeyBetween = generateKeyBetween;
|