@based/db 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/darwin_aarch64/include/selva/db.h +89 -6
- package/dist/lib/darwin_aarch64/include/selva/fields.h +28 -39
- package/dist/lib/darwin_aarch64/include/selva/types.h +0 -10
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +89 -6
- package/dist/lib/linux_aarch64/include/selva/fields.h +28 -39
- package/dist/lib/linux_aarch64/include/selva/types.h +0 -10
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +89 -6
- package/dist/lib/linux_x86_64/include/selva/fields.h +28 -39
- package/dist/lib/linux_x86_64/include/selva/types.h +0 -10
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.js +8 -3
- package/dist/src/client/modify/ModifyRes.d.ts +1 -1
- package/dist/src/client/modify/ModifyRes.js +1 -1
- package/dist/src/client/modify/alias.d.ts +1 -1
- package/dist/src/client/modify/binary.d.ts +1 -1
- package/dist/src/client/modify/cardinality.d.ts +1 -1
- package/dist/src/client/modify/cardinality.js +1 -1
- package/dist/src/client/modify/create.js +2 -2
- package/dist/src/client/modify/delete.js +1 -1
- package/dist/src/client/modify/expire.js +1 -1
- package/dist/src/client/modify/fixed.d.ts +1 -1
- package/dist/src/client/modify/fixed.js +1 -1
- package/dist/src/client/modify/json.d.ts +1 -1
- package/dist/src/client/modify/modify.d.ts +1 -1
- package/dist/src/client/modify/modify.js +1 -1
- package/dist/src/client/modify/references/edge.d.ts +1 -1
- package/dist/src/client/modify/references/edge.js +1 -1
- package/dist/src/client/modify/references/reference.d.ts +1 -1
- package/dist/src/client/modify/references/references.d.ts +1 -1
- package/dist/src/client/modify/references/references.js +1 -1
- package/dist/src/client/modify/setCursor.d.ts +1 -1
- package/dist/src/client/modify/string.d.ts +1 -1
- package/dist/src/client/modify/text.d.ts +1 -1
- package/dist/src/client/modify/text.js +6 -0
- package/dist/src/client/modify/update.js +1 -1
- package/dist/src/client/modify/upsert.js +1 -1
- package/dist/src/client/modify/vector.d.ts +1 -1
- package/dist/src/client/operations.d.ts +2 -1
- package/dist/src/client/operations.js +1 -0
- package/dist/src/client/query/BasedDbQuery.js +1 -1
- package/dist/src/client/query/debug.js +1 -1
- package/dist/src/client/query/display.d.ts +1 -1
- package/dist/src/client/query/display.js +1 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.d.ts +1 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +1 -2
- package/dist/src/client/query/filter/createReferenceFilter.d.ts +1 -1
- package/dist/src/client/query/filter/createVariableFilterBuffer.d.ts +1 -1
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +1 -1
- package/dist/src/client/query/filter/filter.d.ts +1 -1
- package/dist/src/client/query/filter/filter.js +1 -1
- package/dist/src/client/query/filter/parseFilterValue.d.ts +1 -1
- package/dist/src/client/query/filter/parseFilterValue.js +1 -1
- package/dist/src/client/query/filter/primitiveFilter.d.ts +1 -1
- package/dist/src/client/query/filter/primitiveFilter.js +4 -1
- package/dist/src/client/query/include/props.d.ts +1 -1
- package/dist/src/client/query/include/props.js +1 -1
- package/dist/src/client/query/include/utils.d.ts +1 -1
- package/dist/src/client/query/include/utils.js +1 -1
- package/dist/src/client/query/include/walk.js +1 -1
- package/dist/src/client/query/read/read.js +1 -1
- package/dist/src/client/query/search/index.js +1 -1
- package/dist/src/client/query/subscription/markers.d.ts +1 -1
- package/dist/src/client/query/types.d.ts +1 -1
- package/dist/src/client/query/validation.d.ts +1 -1
- package/dist/src/client/query/validation.js +9 -8
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/server/index.d.ts +3 -5
- package/dist/src/server/index.js +11 -5
- package/dist/src/server/migrate/worker.js +1 -1
- package/dist/src/server/start.d.ts +0 -1
- package/dist/src/server/start.js +1 -1
- package/dist/src/server/tree.d.ts +1 -1
- package/package.json +2 -2
- package/dist/lib/darwin_aarch64/libxxhash.0.8.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.0.dylib +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0.8.2 +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0.8.2 +0 -0
- package/dist/src/server/schema/schema.d.ts +0 -3
- package/dist/src/server/schema/schema.js +0 -4
- package/dist/src/server/schema/selvaBuffer.d.ts +0 -4
- package/dist/src/server/schema/selvaBuffer.js +0 -112
- package/dist/src/server/schema/typeDef.d.ts +0 -6
- package/dist/src/server/schema/typeDef.js +0 -337
- package/dist/src/server/schema/types.d.ts +0 -140
- package/dist/src/server/schema/types.js +0 -121
- package/dist/src/server/schema/utils.d.ts +0 -7
- package/dist/src/server/schema/utils.js +0 -34
|
@@ -75,28 +75,92 @@ struct SelvaTypeEntry *selva_get_type_by_node(const struct SelvaDb *db, struct S
|
|
|
75
75
|
* Get the node schema for type.
|
|
76
76
|
*/
|
|
77
77
|
SELVA_EXPORT
|
|
78
|
-
|
|
78
|
+
__attribute__((nonnull, pure))
|
|
79
|
+
inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te)
|
|
80
|
+
#if !__zig
|
|
81
|
+
{
|
|
82
|
+
return &te->ns;
|
|
83
|
+
}
|
|
84
|
+
#else
|
|
85
|
+
;
|
|
86
|
+
#endif
|
|
79
87
|
|
|
80
88
|
SELVA_EXPORT
|
|
81
|
-
|
|
89
|
+
__attribute__((nonnull, pure))
|
|
90
|
+
inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field)
|
|
91
|
+
#if !__zig
|
|
92
|
+
{
|
|
93
|
+
if (field >= fields_schema->nr_fields) {
|
|
94
|
+
return nullptr;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return &fields_schema->field_schemas[field];
|
|
98
|
+
}
|
|
99
|
+
#else
|
|
100
|
+
;
|
|
101
|
+
#endif
|
|
82
102
|
|
|
83
103
|
/**
|
|
84
104
|
* Get the field schema for field.
|
|
85
105
|
*/
|
|
86
106
|
SELVA_EXPORT
|
|
87
|
-
|
|
107
|
+
__attribute__((nonnull, pure))
|
|
108
|
+
inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct SelvaTypeEntry *te, field_t field)
|
|
109
|
+
#if !__zig
|
|
110
|
+
{
|
|
111
|
+
return get_fs_by_fields_schema_field(&te->ns.fields_schema, field);
|
|
112
|
+
}
|
|
113
|
+
#else
|
|
114
|
+
;
|
|
115
|
+
#endif
|
|
88
116
|
|
|
89
117
|
/**
|
|
90
118
|
* Get the field schema for field.
|
|
91
119
|
*/
|
|
92
120
|
SELVA_EXPORT
|
|
93
|
-
|
|
121
|
+
__attribute__((nonnull, pure))
|
|
122
|
+
inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field)
|
|
123
|
+
#if !__zig
|
|
124
|
+
{
|
|
125
|
+
return get_fs_by_fields_schema_field(&ns->fields_schema, field);
|
|
126
|
+
}
|
|
127
|
+
#else
|
|
128
|
+
;
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Get the field schema for field.
|
|
133
|
+
*/
|
|
134
|
+
SELVA_EXPORT
|
|
135
|
+
__attribute__((nonnull, pure))
|
|
136
|
+
inline const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field)
|
|
137
|
+
#if !__zig
|
|
138
|
+
{
|
|
139
|
+
struct SelvaTypeEntry *type;
|
|
140
|
+
|
|
141
|
+
type = selva_get_type_by_node(db, node);
|
|
142
|
+
if (!type) {
|
|
143
|
+
return nullptr;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return selva_get_fs_by_ns_field(&type->ns, field);
|
|
147
|
+
}
|
|
148
|
+
#else
|
|
149
|
+
;
|
|
150
|
+
#endif
|
|
94
151
|
|
|
95
152
|
SELVA_EXPORT
|
|
96
153
|
#if __has_c_attribute(reproducible)
|
|
97
154
|
[[reproducible]]
|
|
98
155
|
#endif
|
|
99
|
-
enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
|
|
156
|
+
inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
|
|
157
|
+
#if !__zig
|
|
158
|
+
{
|
|
159
|
+
return fs->type;
|
|
160
|
+
}
|
|
161
|
+
#else
|
|
162
|
+
;
|
|
163
|
+
#endif
|
|
100
164
|
|
|
101
165
|
/**
|
|
102
166
|
* Get the EdgeFieldConstraint from a ref field schema.
|
|
@@ -105,7 +169,17 @@ enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs);
|
|
|
105
169
|
* struct SelvaFieldSchema *dst_fs = selva_get_fs_by_node(db, dst, efc->inverse_field);
|
|
106
170
|
*/
|
|
107
171
|
SELVA_EXPORT
|
|
108
|
-
|
|
172
|
+
__attribute__((nonnull))
|
|
173
|
+
inline const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs)
|
|
174
|
+
#if !__zig
|
|
175
|
+
{
|
|
176
|
+
return (fs->type == SELVA_FIELD_TYPE_REFERENCE || fs->type == SELVA_FIELD_TYPE_REFERENCES)
|
|
177
|
+
? &fs->edge_constraint
|
|
178
|
+
: nullptr;
|
|
179
|
+
}
|
|
180
|
+
#else
|
|
181
|
+
;
|
|
182
|
+
#endif
|
|
109
183
|
|
|
110
184
|
SELVA_EXPORT
|
|
111
185
|
const struct SelvaFieldsSchema *selva_get_edge_field_fields_schema(struct SelvaDb *db, const struct EdgeFieldConstraint *efc);
|
|
@@ -173,6 +247,11 @@ struct SelvaNode *selva_prev_node(struct SelvaTypeEntry *type, struct SelvaNode
|
|
|
173
247
|
SELVA_EXPORT
|
|
174
248
|
struct SelvaNode *selva_next_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
|
|
175
249
|
|
|
250
|
+
/**
|
|
251
|
+
* \addtogroup db_cursor
|
|
252
|
+
* @{
|
|
253
|
+
*/
|
|
254
|
+
|
|
176
255
|
/**
|
|
177
256
|
* Create a new cursor pointing to node.
|
|
178
257
|
* If the node is deleted later then the cursor is updated to point to the next
|
|
@@ -205,6 +284,10 @@ void selva_cursor_del(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__
|
|
|
205
284
|
SELVA_EXPORT
|
|
206
285
|
size_t selva_cursor_count(const struct SelvaTypeEntry *type) __attribute__((nonnull));
|
|
207
286
|
|
|
287
|
+
/**
|
|
288
|
+
* @}
|
|
289
|
+
*/
|
|
290
|
+
|
|
208
291
|
/**
|
|
209
292
|
* Total count of nodes of type.
|
|
210
293
|
*/
|
|
@@ -58,37 +58,21 @@ struct SelvaNodeWeakReferences {
|
|
|
58
58
|
struct SelvaNodeWeakReference *refs __pcounted_by(nr_refs);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
|
|
77
|
-
int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
|
|
78
|
-
uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
|
|
79
|
-
int64_t int64; /* SELVA_FIELD_TYPE_INT64 */
|
|
80
|
-
uint64_t uint64; /*!< SELVA_FIELD_TYPE_UINT64 */
|
|
81
|
-
uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
|
|
82
|
-
#if 0
|
|
83
|
-
struct SelvaTextField *text; /*!< SELVA_FIELD_TYPE_TEXT */
|
|
84
|
-
struct SelvaNodeReference *reference; /*!< SELVA_FIELD_TYPE_REFERENCE */
|
|
85
|
-
struct SelvaNodeReferences *references; /*!< SELVA_FIELD_TYPE_REFERENCES */
|
|
86
|
-
struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
|
|
87
|
-
struct SelvaNodeWeakReferences weak_references; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCES */
|
|
88
|
-
struct SelvaMicroBuffer *smb; /*!< SELVA_FIELD_TYPE_MICRO_BUFFER */
|
|
89
|
-
#endif
|
|
90
|
-
// HyperLogLogPlusPlus cardinality; /*!< SELVA_FIELD_TYPE_HLL */
|
|
91
|
-
};
|
|
61
|
+
/**
|
|
62
|
+
* Type helper to determine the size of statically (constant/fixed) sized fields.
|
|
63
|
+
*/
|
|
64
|
+
union SelvaStaticFields {
|
|
65
|
+
bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
|
|
66
|
+
double number; /*!< SELVA_FIELD_TYPE_NUMBER */
|
|
67
|
+
struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
|
|
68
|
+
int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
|
|
69
|
+
uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
|
|
70
|
+
int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
|
|
71
|
+
uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
|
|
72
|
+
int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
|
|
73
|
+
uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
|
|
74
|
+
uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
|
|
75
|
+
struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
|
|
92
76
|
};
|
|
93
77
|
|
|
94
78
|
struct SelvaFieldsPointer {
|
|
@@ -128,7 +112,6 @@ int selva_fields_get_mutable_string(
|
|
|
128
112
|
__attribute__((access(write_only, 4)));
|
|
129
113
|
|
|
130
114
|
/*
|
|
131
|
-
* TODO prefix with selva_
|
|
132
115
|
* TODO Document diff to get_mutable_string
|
|
133
116
|
*/
|
|
134
117
|
SELVA_EXPORT
|
|
@@ -137,6 +120,15 @@ struct selva_string *selva_fields_ensure_string(
|
|
|
137
120
|
const struct SelvaFieldSchema *fs,
|
|
138
121
|
size_t initial_len);
|
|
139
122
|
|
|
123
|
+
SELVA_EXPORT
|
|
124
|
+
struct selva_string *selva_fields_ensure_string2(
|
|
125
|
+
struct SelvaDb *db,
|
|
126
|
+
struct SelvaNode *node,
|
|
127
|
+
const struct EdgeFieldConstraint *efc,
|
|
128
|
+
struct SelvaNodeReference *ref,
|
|
129
|
+
const struct SelvaFieldSchema *fs,
|
|
130
|
+
size_t initial_len);
|
|
131
|
+
|
|
140
132
|
SELVA_EXPORT
|
|
141
133
|
int selva_fields_reference_set(
|
|
142
134
|
struct SelvaDb *db,
|
|
@@ -274,16 +266,16 @@ int selva_fields_get_text(
|
|
|
274
266
|
size_t *len);
|
|
275
267
|
|
|
276
268
|
SELVA_EXPORT
|
|
277
|
-
struct SelvaNodeReference *selva_fields_get_reference(struct SelvaNode *node, field_t field);
|
|
269
|
+
struct SelvaNodeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, field_t field);
|
|
278
270
|
|
|
279
271
|
SELVA_EXPORT
|
|
280
|
-
struct SelvaNodeReferences *selva_fields_get_references(struct SelvaNode *node, field_t field);
|
|
272
|
+
struct SelvaNodeReferences *selva_fields_get_references(struct SelvaDb *db, struct SelvaNode *node, field_t field);
|
|
281
273
|
|
|
282
274
|
SELVA_EXPORT
|
|
283
|
-
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaFields *fields, field_t field);
|
|
275
|
+
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaDb *db, struct SelvaFields *fields, field_t field);
|
|
284
276
|
|
|
285
277
|
SELVA_EXPORT
|
|
286
|
-
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaFields *fields, field_t field);
|
|
278
|
+
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaDb *db, struct SelvaFields *fields, field_t field);
|
|
287
279
|
|
|
288
280
|
SELVA_EXPORT
|
|
289
281
|
struct SelvaNode *selva_fields_resolve_weak_reference(
|
|
@@ -333,9 +325,6 @@ void selva_fields_init(const struct SelvaFieldsSchema *schema, struct SelvaField
|
|
|
333
325
|
SELVA_EXPORT
|
|
334
326
|
void selva_fields_destroy(struct SelvaDb *db, struct SelvaNode *node);
|
|
335
327
|
|
|
336
|
-
SELVA_EXPORT
|
|
337
|
-
int selva_fields_get_text_crc(const struct SelvaNode *node, const struct SelvaFieldSchema *fs, enum selva_lang_code lang, uint32_t *crc);
|
|
338
|
-
|
|
339
328
|
SELVA_EXPORT
|
|
340
329
|
void selva_fields_hash_update(struct XXH3_state_s *hash_state, struct SelvaDb *db, const struct SelvaFieldsSchema *schema, const struct SelvaFields *fields);
|
|
341
330
|
|
|
@@ -23,23 +23,13 @@ struct SelvaFieldsSchema;
|
|
|
23
23
|
|
|
24
24
|
enum SelvaFieldType {
|
|
25
25
|
SELVA_FIELD_TYPE_NULL = 0,
|
|
26
|
-
SELVA_FIELD_TYPE_TIMESTAMP = 1,
|
|
27
|
-
#if 0
|
|
28
|
-
SELVA_FIELD_TYPE_SPARE1 = 2,
|
|
29
|
-
SELVA_FIELD_TYPE_SPARE2 = 3,
|
|
30
|
-
#endif
|
|
31
26
|
SELVA_FIELD_TYPE_NUMBER = 4,
|
|
32
|
-
#if 0
|
|
33
|
-
SELVA_FIELD_TYPE_SPARE3 = 5,
|
|
34
|
-
#endif
|
|
35
27
|
SELVA_FIELD_TYPE_INT8 = 20,
|
|
36
28
|
SELVA_FIELD_TYPE_UINT8 = 6,
|
|
37
29
|
SELVA_FIELD_TYPE_INT16 = 21,
|
|
38
30
|
SELVA_FIELD_TYPE_UINT16 = 22,
|
|
39
31
|
SELVA_FIELD_TYPE_INT32 = 23,
|
|
40
32
|
SELVA_FIELD_TYPE_UINT32 = 7,
|
|
41
|
-
SELVA_FIELD_TYPE_INT64 = 24,
|
|
42
|
-
SELVA_FIELD_TYPE_UINT64 = 8,
|
|
43
33
|
SELVA_FIELD_TYPE_BOOLEAN = 9,
|
|
44
34
|
SELVA_FIELD_TYPE_ENUM = 10,
|
|
45
35
|
SELVA_FIELD_TYPE_STRING = 11,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema, StrictSchema } from '@based/schema';
|
|
2
2
|
import { CreateObj } from './modify/create.js';
|
|
3
|
-
import { SchemaTypeDef } from '
|
|
3
|
+
import { SchemaTypeDef } from '@based/schema/def';
|
|
4
4
|
import { ModifyCtx } from './operations.js';
|
|
5
5
|
import { SubscriptionMarkerMap, SubscriptionsMap, SubscriptionsToRun } from './query/subscription/index.js';
|
|
6
6
|
import { BasedDbQuery, QueryByAliasObj } from './query/BasedDbQuery.js';
|
package/dist/src/client/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { parse } from '@based/schema';
|
|
2
2
|
import { create } from './modify/create.js';
|
|
3
|
+
import { updateTypeDefs, schemaToSelvaBuffer, } from '@based/schema/def';
|
|
3
4
|
import { flushBuffer, ModifyCtx } from './operations.js';
|
|
4
5
|
import { BasedDbQuery } from './query/BasedDbQuery.js';
|
|
5
6
|
import { ModifyState } from './modify/ModifyRes.js';
|
|
6
7
|
import { upsert } from './modify/upsert.js';
|
|
7
8
|
import { update } from './modify/update.js';
|
|
8
9
|
import { deleteFn } from './modify/delete.js';
|
|
9
|
-
import { updateTypeDefs } from '../server/schema/typeDef.js';
|
|
10
|
-
import { schemaToSelvaBuffer } from '../server/schema/selvaBuffer.js';
|
|
11
10
|
import { deepEqual } from '@saulx/utils';
|
|
12
11
|
import { hash } from '@saulx/hash';
|
|
13
12
|
import { expire } from './modify/expire.js';
|
|
@@ -53,7 +52,13 @@ export class DbClient {
|
|
|
53
52
|
return this.schema;
|
|
54
53
|
}
|
|
55
54
|
this.schema = schema;
|
|
56
|
-
|
|
55
|
+
for (const field in this.schema.types) {
|
|
56
|
+
if (!('id' in this.schema.types[field])) {
|
|
57
|
+
this.schema.lastId++;
|
|
58
|
+
this.schema.types[field].id = this.schema.lastId;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
updateTypeDefs(this.schema, this.schemaTypesParsed, this.schemaTypesParsedById);
|
|
57
62
|
// TODO should not need this, but it modifies the schema
|
|
58
63
|
schemaToSelvaBuffer(this.schemaTypesParsed);
|
|
59
64
|
return this.schema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropDef, PropDefEdge, SchemaPropTree } from '
|
|
1
|
+
import { PropDef, PropDefEdge, SchemaPropTree } from '@based/schema/def';
|
|
2
2
|
import { inspect } from 'node:util';
|
|
3
3
|
import { SubscriptionMarkersCheck } from '../query/subscription/index.js';
|
|
4
4
|
import { DbClient } from '../index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPropDef, REVERSE_TYPE_INDEX_MAP, } from '
|
|
1
|
+
import { isPropDef, REVERSE_TYPE_INDEX_MAP, } from '@based/schema/def';
|
|
2
2
|
import { inspect } from 'node:util';
|
|
3
3
|
import { langCodesMap } from '@based/schema';
|
|
4
4
|
const MAGIC_KEY = Math.random().toString(36).substring(2);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { SchemaTypeDef, PropDef } from '
|
|
2
|
+
import { SchemaTypeDef, PropDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
4
4
|
export declare function writeAlias(value: string | null | Buffer, ctx: ModifyCtx, def: SchemaTypeDef, t: PropDef, parentId: number, modifyOp: ModifyOp): ModifyErr;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { PropDef, SchemaTypeDef } from '
|
|
2
|
+
import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
4
4
|
export declare function getBuffer(value: any): Buffer;
|
|
5
5
|
export declare function writeBinaryRaw(value: Buffer, ctx: ModifyCtx): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { SchemaTypeDef, PropDef } from '
|
|
2
|
+
import { SchemaTypeDef, PropDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
4
4
|
export declare function writeHll(value: string | null | Buffer | Array<string | Buffer>, ctx: ModifyCtx, def: SchemaTypeDef, t: PropDef, parentId: number, modifyOp: ModifyOp): ModifyErr;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MICRO_BUFFER } from '
|
|
1
|
+
import { MICRO_BUFFER } from '@based/schema/def';
|
|
2
2
|
import { startDrain, flushBuffer } from '../operations.js';
|
|
3
3
|
import { setCursor } from './setCursor.js';
|
|
4
4
|
import { modify } from './modify.js';
|
|
@@ -59,7 +59,7 @@ const appendCreate = (ctx, def, obj, res, unsafe) => {
|
|
|
59
59
|
ctx.buf[sizepos] = size >>>= 8;
|
|
60
60
|
}
|
|
61
61
|
if (ctx.hasSortField !== -1) {
|
|
62
|
-
def.seperateSort.buffer.
|
|
62
|
+
def.seperateSort.buffer.set(def.seperateSort.bufferTmp);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { flushBuffer, startDrain } from '../operations.js';
|
|
2
2
|
import { setCursor } from './setCursor.js';
|
|
3
3
|
import { UPDATE } from './types.js';
|
|
4
|
-
import { MICRO_BUFFER } from '
|
|
4
|
+
import { MICRO_BUFFER } from '@based/schema/def';
|
|
5
5
|
export const deleteFn = (db, type, id) => {
|
|
6
6
|
const ctx = db.modifyCtx;
|
|
7
7
|
const schema = db.schemaTypesParsed[type];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { PropDef, PropDefEdge } from '
|
|
2
|
+
import { PropDef, PropDefEdge } from '@based/schema/def';
|
|
3
3
|
import { ModifyErr } from './types.js';
|
|
4
4
|
export declare const writeFixedValue: (ctx: ModifyCtx, val: any, def: PropDef | PropDefEdge, pos: number) => ModifyErr;
|
|
5
5
|
export declare const appendFixedValue: (ctx: ModifyCtx, val: any, def: PropDef | PropDefEdge) => ModifyErr;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BINARY, BOOLEAN, ENUM, INT16, INT32, INT8, NUMBER, STRING, TIMESTAMP, UINT16, UINT32, UINT8, } from '
|
|
1
|
+
import { BINARY, BOOLEAN, ENUM, INT16, INT32, INT8, NUMBER, STRING, TIMESTAMP, UINT16, UINT32, UINT8, } from '@based/schema/def';
|
|
2
2
|
import { convertToTimestamp } from '../timestamp.js';
|
|
3
3
|
import { getBuffer } from './binary.js';
|
|
4
4
|
import { ModifyError } from './ModifyRes.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { PropDef, SchemaTypeDef } from '
|
|
2
|
+
import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
4
4
|
export declare function writeJson(value: any, ctx: ModifyCtx, schema: SchemaTypeDef, t: PropDef, parentId: number, modifyOp: ModifyOp): ModifyErr;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { SchemaTypeDef } from '
|
|
2
|
+
import { SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyState } from './ModifyRes.js';
|
|
4
4
|
import { ModifyErr, ModifyOp } from './types.js';
|
|
5
5
|
export declare function modify(ctx: ModifyCtx, res: ModifyState, obj: Record<string, any>, schema: SchemaTypeDef, mod: ModifyOp, tree: SchemaTypeDef['tree'], overwrite: boolean, unsafe?: boolean): ModifyErr;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPropDef, REFERENCE, REFERENCES, STRING, TEXT, ALIAS, BINARY, CARDINALITY, VECTOR, MICRO_BUFFER, JSON, } from '
|
|
1
|
+
import { isPropDef, REFERENCE, REFERENCES, STRING, TEXT, ALIAS, BINARY, CARDINALITY, VECTOR, MICRO_BUFFER, JSON, } from '@based/schema/def';
|
|
2
2
|
import { ModifyError } from './ModifyRes.js';
|
|
3
3
|
import { writeReference } from './references/reference.js';
|
|
4
4
|
import { writeReferences } from './references/references.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../../index.js';
|
|
2
|
-
import { PropDef } from '
|
|
2
|
+
import { PropDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyErr } from '../types.js';
|
|
4
4
|
import { RefModifyOpts } from './references.js';
|
|
5
5
|
export declare function getEdgeSize(t: PropDef, ref: RefModifyOpts): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BINARY, REFERENCE, REFERENCES, STRING, } from '
|
|
1
|
+
import { BINARY, REFERENCE, REFERENCES, STRING, } from '@based/schema/def';
|
|
2
2
|
import { write } from '../../string.js';
|
|
3
3
|
import { getBuffer, writeBinaryRaw } from '../binary.js';
|
|
4
4
|
import { ModifyError, ModifyState } from '../ModifyRes.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../../index.js';
|
|
2
|
-
import { PropDef, SchemaTypeDef } from '
|
|
2
|
+
import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyState } from '../ModifyRes.js';
|
|
4
4
|
import { ModifyErr, ModifyOp } from '../types.js';
|
|
5
5
|
export declare function writeReference(value: number | ModifyState | {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../../index.js';
|
|
2
|
-
import { PropDef, SchemaTypeDef } from '
|
|
2
|
+
import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyState } from '../ModifyRes.js';
|
|
4
4
|
import { ModifyErr, ModifyOp } from '../types.js';
|
|
5
5
|
export type RefModifyOpts = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { REFERENCES
|
|
1
|
+
import { REFERENCES } from '@based/schema/def';
|
|
2
2
|
import { ModifyError, ModifyState } from '../ModifyRes.js';
|
|
3
3
|
import { setCursor } from '../setCursor.js';
|
|
4
4
|
import { DELETE, RANGE_ERR } from '../types.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { SchemaTypeDef } from '
|
|
2
|
+
import { SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyOp } from './types.js';
|
|
4
4
|
export declare const setCursor: (ctx: ModifyCtx, schema: SchemaTypeDef, field: number, typeIndex: number, id: number, modifyOp: ModifyOp, ignoreField?: boolean) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LangCode } from '@based/schema';
|
|
2
2
|
import { ModifyCtx } from '../../index.js';
|
|
3
|
-
import { SchemaTypeDef, PropDef } from '
|
|
3
|
+
import { SchemaTypeDef, PropDef } from '@based/schema/def';
|
|
4
4
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
5
5
|
export declare function writeString(lang: LangCode, value: string | null | Buffer, ctx: ModifyCtx, def: SchemaTypeDef, t: PropDef, parentId: number, modifyOp: ModifyOp): ModifyErr;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
2
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
3
|
-
import { SchemaTypeDef, PropDef } from '
|
|
3
|
+
import { SchemaTypeDef, PropDef } from '@based/schema/def';
|
|
4
4
|
import { writeString } from './string.js';
|
|
5
5
|
import { ModifyState } from './ModifyRes.js';
|
|
6
6
|
export declare function writeText(value: {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { langCodesMap } from '@based/schema';
|
|
2
|
+
import { CREATE } from './types.js';
|
|
2
3
|
import { writeString } from './string.js';
|
|
3
4
|
export function writeText(value, ctx, def, t, res, modifyOp) {
|
|
4
5
|
// todo proper fallback as well
|
|
5
6
|
if (value && typeof value !== 'object') {
|
|
6
7
|
const err = writeString(res.locale ?? langCodesMap.get('en'), value, ctx, def, t, res.tmpId, modifyOp);
|
|
8
|
+
if (modifyOp === CREATE) {
|
|
9
|
+
def.seperateTextSort.bufferTmp[t.prop * def.localeSize] = 2;
|
|
10
|
+
ctx.hasSortText++;
|
|
11
|
+
}
|
|
12
|
+
return err;
|
|
7
13
|
}
|
|
8
14
|
else {
|
|
9
15
|
for (const lang in value) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ModifyCtx } from '../../index.js';
|
|
2
|
-
import { PropDef, SchemaTypeDef } from '
|
|
2
|
+
import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
3
3
|
import { ModifyOp, ModifyErr } from './types.js';
|
|
4
4
|
export declare function writeVector(value: any, ctx: ModifyCtx, schema: SchemaTypeDef, t: PropDef, parentId: number, modifyOp: ModifyOp): ModifyErr;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropDef, SchemaTypeDef } from '
|
|
1
|
+
import { PropDef, SchemaTypeDef } from '@based/schema/def';
|
|
2
2
|
import { DbClient } from './index.js';
|
|
3
3
|
import { ModifyState } from './modify/ModifyRes.js';
|
|
4
4
|
export declare class ModifyCtx {
|
|
@@ -7,6 +7,7 @@ export declare class ModifyCtx {
|
|
|
7
7
|
id: number;
|
|
8
8
|
lastMain: number;
|
|
9
9
|
hasSortField: number;
|
|
10
|
+
hasSortText: number;
|
|
10
11
|
queue: Map<(payload: any) => void, ModifyState>;
|
|
11
12
|
ctx: {
|
|
12
13
|
offsets?: Record<number, number>;
|
|
@@ -4,7 +4,7 @@ import { createOrGetEdgeRefQueryDef, createOrGetRefQueryDef, } from './include/u
|
|
|
4
4
|
import { FilterBranch } from './filter/FilterBranch.js';
|
|
5
5
|
import { search, vectorSearch } from './search/index.js';
|
|
6
6
|
import native from '../../native.js';
|
|
7
|
-
import { REFERENCE, REFERENCES } from '
|
|
7
|
+
import { REFERENCE, REFERENCES } from '@based/schema/def';
|
|
8
8
|
import { subscribe } from './subscription/index.js';
|
|
9
9
|
import { registerQuery } from './registerQuery.js';
|
|
10
10
|
import { langCodesMap } from '@based/schema';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import picocolors from 'picocolors';
|
|
2
|
-
import { isPropDef, REVERSE_TYPE_INDEX_MAP } from '
|
|
2
|
+
import { isPropDef, REVERSE_TYPE_INDEX_MAP } from '@based/schema/def';
|
|
3
3
|
import { QueryDefType } from './types.js';
|
|
4
4
|
import { concatUint8Arr } from '../bitWise.js';
|
|
5
5
|
export const debugQueryDef = (q, returnIt) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryDef } from './types.js';
|
|
2
|
-
import { TypeIndex } from '
|
|
2
|
+
import { TypeIndex } from '@based/schema/def';
|
|
3
3
|
import { BasedQueryResponse } from './BasedIterable.js';
|
|
4
4
|
export declare const size: (size: number) => string;
|
|
5
5
|
export declare const time: (time: number) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import picocolors from 'picocolors';
|
|
2
|
-
import { BINARY, CARDINALITY, NUMBER, REFERENCE, REFERENCES, STRING, TEXT, TIMESTAMP, } from '
|
|
2
|
+
import { BINARY, CARDINALITY, NUMBER, REFERENCE, REFERENCES, STRING, TEXT, TIMESTAMP, } from '@based/schema/def';
|
|
3
3
|
const decimals = (v) => ~~(v * 100) / 100;
|
|
4
4
|
const sizeCalc = (size) => {
|
|
5
5
|
if (size > 1e6) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropDef, PropDefEdge } from '
|
|
1
|
+
import { PropDef, PropDefEdge } from '@based/schema/def';
|
|
2
2
|
import { FilterCtx } from './types.js';
|
|
3
3
|
export declare const writeFixed: (prop: PropDef | PropDefEdge, buf: Buffer, value: any, size: number, offset: number) => void;
|
|
4
4
|
export declare const createFixedFilterBuffer: (prop: PropDef | PropDefEdge, size: number, ctx: FilterCtx, value: any, sort: boolean) => Buffer;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { BINARY, STRING, REFERENCES, } from '
|
|
2
|
-
import { propIsSigned } from '../../../server/schema/utils.js';
|
|
1
|
+
import { BINARY, STRING, REFERENCES, propIsSigned, } from '@based/schema/def';
|
|
3
2
|
import { EQUAL, MODE_AND_FIXED, MODE_DEFAULT, MODE_OR_FIXED, } from './types.js';
|
|
4
3
|
import { parseFilterValue } from './parseFilterValue.js';
|
|
5
4
|
// -------------------------------------------
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PropDef, PropDefEdge } from '
|
|
1
|
+
import { PropDef, PropDefEdge } from '@based/schema/def';
|
|
2
2
|
import { FilterCtx } from './types.js';
|
|
3
3
|
export declare const createReferenceFilter: (prop: PropDef | PropDefEdge, ctx: FilterCtx, value: any) => Buffer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropDef, PropDefEdge } from '
|
|
1
|
+
import { PropDef, PropDefEdge } from '@based/schema/def';
|
|
2
2
|
import { FilterCtx } from './types.js';
|
|
3
3
|
import { LangCode } from '@based/schema';
|
|
4
4
|
export declare const createVariableFilterBuffer: (value: any, prop: PropDef | PropDefEdge, ctx: FilterCtx, lang: LangCode) => Buffer;
|