trellis 3.1.3 → 3.1.7
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/README.md +1 -0
- package/bin/trellis.mjs +68 -2
- package/dist/better-sqlite-backend-ahx5p0br.js +147 -0
- package/dist/cli/index.js +116 -45
- package/dist/client/index.js +5 -4
- package/dist/cms/client.d.ts +4 -3
- package/dist/cms/client.d.ts.map +1 -1
- package/dist/cms/formula.d.ts +10 -0
- package/dist/cms/formula.d.ts.map +1 -0
- package/dist/cms/index.d.ts +3 -2
- package/dist/cms/index.d.ts.map +1 -1
- package/dist/cms/index.js +156 -4
- package/dist/cms/types.d.ts +11 -0
- package/dist/cms/types.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +14 -4
- package/dist/core/persist/factory.d.ts +28 -0
- package/dist/core/persist/factory.d.ts.map +1 -0
- package/dist/core/persist/factory.js +8 -0
- package/dist/core/persist/sqlite-backend.d.ts.map +1 -1
- package/dist/core/persist/sqljs-backend.d.ts +60 -0
- package/dist/core/persist/sqljs-backend.d.ts.map +1 -0
- package/dist/core/persist/sqljs-backend.js +8 -0
- package/dist/db/index.js +11 -10
- package/dist/embeddings/index.js +1 -1
- package/dist/embeddings/store.d.ts.map +1 -1
- package/dist/{index-0zk3fx2s.js → index-4wxa8xz4.js} +4 -237
- package/dist/{index-6n5dcebj.js → index-53f3b8p8.js} +84 -30
- package/dist/{index-y3d71wzd.js → index-7pjz3tsy.js} +36 -6
- package/dist/{index-0q7wbasy.js → index-a2a394zz.js} +7 -3
- package/dist/index-h32txmxe.js +42 -0
- package/dist/index-h7zxhhhh.js +252 -0
- package/dist/index-h9e2efx4.js +251 -0
- package/dist/{index-2917tjd8.js → index-hr9qvv77.js} +15 -3
- package/dist/{index-hmdbnd4n.js → index-hy73j9z8.js} +1 -1
- package/dist/{index-q31hfjja.js → index-jgda3xyv.js} +1 -1
- package/dist/{index-7e27kvvj.js → index-wncptktd.js} +1 -1
- package/dist/index.js +8 -6
- package/dist/react/index.js +5 -4
- package/dist/{sdk-snn5gad3.js → sdk-bepky0xs.js} +5 -4
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +27 -24
- package/dist/server/node-adapter.d.ts +38 -0
- package/dist/server/node-adapter.d.ts.map +1 -0
- package/dist/server/node-adapter.js +108 -0
- package/dist/server/server-shared.d.ts +21 -0
- package/dist/server/server-shared.d.ts.map +1 -0
- package/dist/server/server.d.ts +19 -2
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/tenancy.d.ts +28 -2
- package/dist/server/tenancy.d.ts.map +1 -1
- package/dist/{server-mrctdwzr.js → server-szdjx0nt.js} +5 -3
- package/dist/sqlite-backend-0vsmc6qj.js +8 -0
- package/dist/{tenancy-7d1g4ayp.js → tenancy-pjm32b4v.js} +4 -3
- package/dist/vcs/blob-store.d.ts +2 -1
- package/dist/vcs/blob-store.d.ts.map +1 -1
- package/dist/vcs/index.js +2 -2
- package/package.json +16 -3
package/dist/cms/client.d.ts
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @module trellis/cms
|
|
25
25
|
*/
|
|
26
|
-
import type { CmsClientOptions, Collection, Entry, EntrySubscribeOptions, EntrySubscriber, GetOptions, ListOptions, ListSubscribeOptions, ListSubscriber, Unsubscribe } from './types.js';
|
|
27
|
-
import { type RawEntity } from './internal.js';
|
|
26
|
+
import type { CmsClientOptions, Collection, Entry, EntrySubscribeOptions, EntrySubscriber, GetOptions, ListOptions, ListSubscribeOptions, ListSubscriber, Unsubscribe, FieldDefinition } from './types.js';
|
|
27
|
+
import { type RawEntity, type RawFact } from './internal.js';
|
|
28
28
|
export declare class CmsClient {
|
|
29
29
|
private readonly url;
|
|
30
30
|
private readonly basePath;
|
|
@@ -55,7 +55,7 @@ export declare class CmsClient {
|
|
|
55
55
|
/** @internal */
|
|
56
56
|
_entities(): Promise<RawEntity[]>;
|
|
57
57
|
/** @internal */
|
|
58
|
-
_entryById(id: string): Promise<Entry | null>;
|
|
58
|
+
_entryById(id: string, schemaFacts?: RawFact[]): Promise<Entry | null>;
|
|
59
59
|
}
|
|
60
60
|
export declare class CollectionRef<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
61
61
|
private readonly client;
|
|
@@ -71,6 +71,7 @@ export declare class CollectionRef<T extends Record<string, unknown> = Record<st
|
|
|
71
71
|
* and one HTTP request per cycle.
|
|
72
72
|
*/
|
|
73
73
|
subscribe(callback: ListSubscriber<T>, opts?: ListSubscribeOptions): Unsubscribe;
|
|
74
|
+
schema(): Promise<FieldDefinition[]>;
|
|
74
75
|
}
|
|
75
76
|
export declare class EntryRef<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
76
77
|
private readonly client;
|
package/dist/cms/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cms/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cms/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAQL,KAAK,SAAS,EACd,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;AA4BvB,qBAAa,SAAS;IACpB,OAAO,CAAC,Q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f;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAEjE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Entry, FieldDefinition } from './types.js';
|
|
2
|
+
export declare function evaluateFormula(expr: string, fields: Record<string, unknown>): number | undefined;
|
|
3
|
+
export declare function parseFields(raw: unknown): FieldDefinition[];
|
|
4
|
+
export declare function schemaFields(facts: {
|
|
5
|
+
e: string;
|
|
6
|
+
a: string;
|
|
7
|
+
v: unknown;
|
|
8
|
+
}[], names: string[]): FieldDefinition[];
|
|
9
|
+
export declare function applyFormulas<T extends Record<string, unknown>>(entry: Entry<T>, defs: FieldDefinition[]): Entry<T>;
|
|
10
|
+
//# sourceMappingURL=formula.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formula.d.ts","sourceRoot":"","sources":["../../src/cms/formula.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA2FzD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,GAAG,SAAS,CASpB;AAcD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,EAAE,CAa3D;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,EAC7C,KAAK,EAAE,MAAM,EAAE,GACd,eAAe,EAAE,CASnB;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7D,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,EAAE,eAAe,EAAE,GACtB,KAAK,CAAC,CAAC,CAAC,CAcV"}
|
package/dist/cms/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module trellis/cms
|
|
5
5
|
*/
|
|
6
|
-
export { CmsClient, CollectionRef, EntryRef, createCmsClient } from './client.js';
|
|
7
|
-
export type { CmsClientOptions, Collection, Entry, EntryStatus, EntrySubscribeOptions, EntrySubscriber, Framework, GetOptions, ListOptions, ListSubscribeOptions, ListSubscriber, SubscribeExtras, Unsubscribe, } from './types.js';
|
|
6
|
+
export { CmsClient, CollectionRef, EntryRef, createCmsClient, } from './client.js';
|
|
7
|
+
export type { CmsClientOptions, Collection, Entry, EntryStatus, EntrySubscribeOptions, EntrySubscriber, FieldDefinition, FieldKind, Framework, GetOptions, ListOptions, ListSubscribeOptions, ListSubscriber, SubscribeExtras, Unsubscribe, } from './types.js';
|
|
8
|
+
export { applyFormulas, evaluateFormula, parseFields } from './formula.js';
|
|
8
9
|
export { scaffoldConsumer, scaffoldFilename } from './scaffold.js';
|
|
9
10
|
export type { ScaffoldOptions } from './scaffold.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cms/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cms/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cms/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/cms/index.js
CHANGED
|
@@ -115,6 +115,146 @@ function fingerprint(value) {
|
|
|
115
115
|
return JSON.stringify(value);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// src/cms/formula.ts
|
|
119
|
+
var OPS = new Set(["+", "-", "*", "/", "(", ")"]);
|
|
120
|
+
function num(value) {
|
|
121
|
+
if (typeof value === "number")
|
|
122
|
+
return Number.isFinite(value) ? value : undefined;
|
|
123
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
124
|
+
return;
|
|
125
|
+
const parsed = Number(value);
|
|
126
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
127
|
+
}
|
|
128
|
+
function tokenize(expr) {
|
|
129
|
+
const tokens = [];
|
|
130
|
+
let i = 0;
|
|
131
|
+
while (i < expr.length) {
|
|
132
|
+
const ch = expr[i];
|
|
133
|
+
if (/\s/.test(ch)) {
|
|
134
|
+
i++;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (OPS.has(ch)) {
|
|
138
|
+
tokens.push(ch);
|
|
139
|
+
i++;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (/\d|\./.test(ch)) {
|
|
143
|
+
let end = i + 1;
|
|
144
|
+
while (end < expr.length && /\d|\./.test(expr[end]))
|
|
145
|
+
end++;
|
|
146
|
+
const value = Number(expr.slice(i, end));
|
|
147
|
+
if (!Number.isFinite(value))
|
|
148
|
+
return;
|
|
149
|
+
tokens.push(value);
|
|
150
|
+
i = end;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
return tokens;
|
|
156
|
+
}
|
|
157
|
+
function parse(tokens) {
|
|
158
|
+
let i = 0;
|
|
159
|
+
const peek = () => tokens[i];
|
|
160
|
+
const take = () => tokens[i++];
|
|
161
|
+
const primary = () => {
|
|
162
|
+
const token = take();
|
|
163
|
+
if (typeof token === "number")
|
|
164
|
+
return token;
|
|
165
|
+
if (token === "+")
|
|
166
|
+
return primary();
|
|
167
|
+
if (token === "-") {
|
|
168
|
+
const value2 = primary();
|
|
169
|
+
return value2 === undefined ? undefined : -value2;
|
|
170
|
+
}
|
|
171
|
+
if (token === "(") {
|
|
172
|
+
const value2 = add();
|
|
173
|
+
if (take() !== ")")
|
|
174
|
+
return;
|
|
175
|
+
return value2;
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
};
|
|
179
|
+
const mul = () => {
|
|
180
|
+
let left = primary();
|
|
181
|
+
while (peek() === "*" || peek() === "/") {
|
|
182
|
+
const op = take();
|
|
183
|
+
const right = primary();
|
|
184
|
+
if (left === undefined || right === undefined)
|
|
185
|
+
return;
|
|
186
|
+
left = op === "*" ? left * right : left / right;
|
|
187
|
+
}
|
|
188
|
+
return left;
|
|
189
|
+
};
|
|
190
|
+
const add = () => {
|
|
191
|
+
let left = mul();
|
|
192
|
+
while (peek() === "+" || peek() === "-") {
|
|
193
|
+
const op = take();
|
|
194
|
+
const right = mul();
|
|
195
|
+
if (left === undefined || right === undefined)
|
|
196
|
+
return;
|
|
197
|
+
left = op === "+" ? left + right : left - right;
|
|
198
|
+
}
|
|
199
|
+
return left;
|
|
200
|
+
};
|
|
201
|
+
const value = add();
|
|
202
|
+
if (i !== tokens.length || value === undefined || !Number.isFinite(value))
|
|
203
|
+
return;
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
function evaluateFormula(expr, fields) {
|
|
207
|
+
const interpolated = expr.replace(/\{([^{}]+)\}/g, (match, key) => {
|
|
208
|
+
const value = num(fields[key.trim()]);
|
|
209
|
+
return value === undefined ? match : String(value);
|
|
210
|
+
});
|
|
211
|
+
if (interpolated.includes("{") || interpolated.includes("}"))
|
|
212
|
+
return;
|
|
213
|
+
const tokens = tokenize(interpolated);
|
|
214
|
+
return tokens ? parse(tokens) : undefined;
|
|
215
|
+
}
|
|
216
|
+
function keys(value) {
|
|
217
|
+
const raw = value.replace(/^schema:/, "").trim();
|
|
218
|
+
const camel = raw.replace(/([a-z0-9])([A-Z])/g, "$1_$2");
|
|
219
|
+
const lower = raw.toLowerCase().replace(/\s+/g, "_");
|
|
220
|
+
const snake = camel.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
221
|
+
const compact = lower.replace(/[^a-z0-9]+/g, "");
|
|
222
|
+
return [...new Set([lower, snake, compact].filter(Boolean))];
|
|
223
|
+
}
|
|
224
|
+
function parseFields(raw) {
|
|
225
|
+
if (typeof raw !== "string")
|
|
226
|
+
return [];
|
|
227
|
+
try {
|
|
228
|
+
const parsed = JSON.parse(raw);
|
|
229
|
+
if (!Array.isArray(parsed))
|
|
230
|
+
return [];
|
|
231
|
+
return parsed.filter((item) => {
|
|
232
|
+
if (!item || typeof item !== "object")
|
|
233
|
+
return false;
|
|
234
|
+
const def = item;
|
|
235
|
+
return typeof def.key === "string" && typeof def.type === "string";
|
|
236
|
+
});
|
|
237
|
+
} catch {
|
|
238
|
+
return [];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function schemaFields(facts, names) {
|
|
242
|
+
const wanted = new Set(names.flatMap(keys));
|
|
243
|
+
const fact = facts.find((item) => item.e.startsWith("schema:") && item.a === "props" && keys(item.e).some((key) => wanted.has(key)));
|
|
244
|
+
return parseFields(fact?.v);
|
|
245
|
+
}
|
|
246
|
+
function applyFormulas(entry, defs) {
|
|
247
|
+
const formulas = defs.filter((def) => def.type === "formula" && typeof def.formula === "string" && def.formula.trim());
|
|
248
|
+
if (formulas.length === 0)
|
|
249
|
+
return entry;
|
|
250
|
+
const fields = { ...entry.fields };
|
|
251
|
+
for (let pass = 0;pass < formulas.length; pass++) {
|
|
252
|
+
for (const def of formulas)
|
|
253
|
+
fields[def.key] = evaluateFormula(def.formula, fields);
|
|
254
|
+
}
|
|
255
|
+
return { ...entry, fields };
|
|
256
|
+
}
|
|
257
|
+
|
|
118
258
|
// src/cms/client.ts
|
|
119
259
|
var DEFAULT_BASE_PATH = "/trellis/store";
|
|
120
260
|
var DEFAULT_POLL_MS = 2000;
|
|
@@ -273,13 +413,14 @@ class CmsClient {
|
|
|
273
413
|
offset += MAX_ENTITIES_PER_FETCH;
|
|
274
414
|
}
|
|
275
415
|
}
|
|
276
|
-
async _entryById(id) {
|
|
416
|
+
async _entryById(id, schemaFacts) {
|
|
277
417
|
const detail = await this._get(`/entity/${encodeURIComponent(id)}`);
|
|
278
418
|
if (!detail)
|
|
279
419
|
return null;
|
|
280
420
|
const typeFact = detail.facts.find((f) => f.a === "type");
|
|
281
421
|
const type = typeof typeFact?.v === "string" ? typeFact.v : "unknown";
|
|
282
|
-
|
|
422
|
+
const facts = schemaFacts ?? await this._get(`/facts?limit=${MAX_FACTS_PER_FETCH}`) ?? [];
|
|
423
|
+
return applyFormulas(entryFromFacts({ id: detail.id, type }, detail.facts, detail.links), schemaFields(facts, [type]));
|
|
283
424
|
}
|
|
284
425
|
}
|
|
285
426
|
|
|
@@ -307,13 +448,17 @@ class CollectionRef {
|
|
|
307
448
|
return [];
|
|
308
449
|
const factsByEntity = groupFactsByEntity(facts ?? []);
|
|
309
450
|
const linksBySource = groupLinksBySource(links ?? []);
|
|
310
|
-
|
|
451
|
+
const defs = schemaFields(facts ?? [], [
|
|
452
|
+
this.key,
|
|
453
|
+
...matching.map((e) => e.type)
|
|
454
|
+
]);
|
|
455
|
+
let entries = matching.map((e) => applyFormulas(entryFromFacts(e, factsByEntity.get(e.id) ?? [], linksBySource.get(e.id) ?? []), defs));
|
|
311
456
|
if (status !== "all") {
|
|
312
457
|
entries = entries.filter((e) => e.status === status);
|
|
313
458
|
}
|
|
314
459
|
entries = entries.slice(0, limit);
|
|
315
460
|
if (wantsExpand) {
|
|
316
|
-
entries = await expandReferences(entries, opts.expand, (id) => this.client._entryById(id));
|
|
461
|
+
entries = await expandReferences(entries, opts.expand, (id) => this.client._entryById(id, facts ?? []));
|
|
317
462
|
}
|
|
318
463
|
return entries;
|
|
319
464
|
}
|
|
@@ -332,6 +477,10 @@ class CollectionRef {
|
|
|
332
477
|
const key = `coll:${typeKey(this.key)}:${JSON.stringify(listOpts)}`;
|
|
333
478
|
return this.client._share(key, () => this.list(listOpts), callback, { onError, equals });
|
|
334
479
|
}
|
|
480
|
+
async schema() {
|
|
481
|
+
const facts = await this.client._get(`/facts?limit=${MAX_FACTS_PER_FETCH}`);
|
|
482
|
+
return schemaFields(facts ?? [], [this.key]);
|
|
483
|
+
}
|
|
335
484
|
}
|
|
336
485
|
|
|
337
486
|
class EntryRef {
|
|
@@ -485,7 +634,10 @@ function scaffoldFilename(opts) {
|
|
|
485
634
|
export {
|
|
486
635
|
scaffoldFilename,
|
|
487
636
|
scaffoldConsumer,
|
|
637
|
+
parseFields,
|
|
638
|
+
evaluateFormula,
|
|
488
639
|
createCmsClient,
|
|
640
|
+
applyFormulas,
|
|
489
641
|
EntryRef,
|
|
490
642
|
CollectionRef,
|
|
491
643
|
CmsClient
|
package/dist/cms/types.d.ts
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
* @module trellis/cms
|
|
5
5
|
*/
|
|
6
6
|
export type EntryStatus = 'draft' | 'published';
|
|
7
|
+
export type FieldKind = 'text' | 'rich_text' | 'number' | 'boolean' | 'date' | 'email' | 'url' | 'color' | 'select' | 'multiselect' | 'file' | 'formula' | 'reference' | 'image' | 'video' | 'audio';
|
|
8
|
+
export type FieldDefinition = {
|
|
9
|
+
key: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
type: FieldKind;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
default?: string;
|
|
14
|
+
options?: string[];
|
|
15
|
+
formula?: string;
|
|
16
|
+
target?: string;
|
|
17
|
+
};
|
|
7
18
|
export type Entry<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
8
19
|
/** Stable entity id (e.g. "blog_post:abc123" or "BlogPost:abc"). */
|
|
9
20
|
id: string;
|
package/dist/cms/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cms/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAEhD,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cms/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAEhD,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,SAAS,GACT,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,QAAQ,GACR,aAAa,GACb,MAAM,GACN,SAAS,GACT,WAAW,GACX,OAAO,GACP,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC3E;I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,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG;IACvB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,QAAQ,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iGAAiG;IACjG,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export type { Atom, EntityRef, Fact, Link, CatalogEntry, QueryTraceEntry, QueryR
|
|
|
11
11
|
export type { KernelOp, KernelOpKind, KernelBackend, } from './persist/backend.js';
|
|
12
12
|
export type { KernelMiddleware, MiddlewareContext, OpMiddlewareNext, } from './kernel/middleware.js';
|
|
13
13
|
export { SqliteKernelBackend } from './persist/sqlite-backend.js';
|
|
14
|
+
export { SqlJsKernelBackend } from './persist/sqljs-backend.js';
|
|
15
|
+
export type { SqlJsKernelBackendOptions } from './persist/sqljs-backend.js';
|
|
16
|
+
export { createKernelBackend } from './persist/factory.js';
|
|
17
|
+
export type { CreateKernelBackendOptions } from './persist/factory.js';
|
|
14
18
|
export { QueryEngine, parseQuery, parseRule, parseSimple, DatalogRuntime, } from './query/index.js';
|
|
15
19
|
export type { Query, Pattern, FactPattern, LinkPattern, Term, Variable, Literal, Filter, FilterOp, Aggregate, OrderBy, Bindings, DatalogRule, } from './query/index.js';
|
|
16
20
|
export { OntologyRegistry, validateEntity, validateStore, createValidationMiddleware, } from './ontology/index.js';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE1E,YAAY,EACV,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,eAAe,EACf,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,KAAK,EACL,OAAO,EACP,WAAW,EACX,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,cAAc,EACd,eAAe,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sBAAsB,CAAC;AAGvE,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,KAAK,EACL,OAAO,EACP,WAAW,EACX,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EACV,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,EACR,aAAa,EACb,SAAS,EACT,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,4BAA4B,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -9,6 +9,12 @@ import {
|
|
|
9
9
|
validateEntity,
|
|
10
10
|
validateStore
|
|
11
11
|
} from "../index-w7ng765c.js";
|
|
12
|
+
import {
|
|
13
|
+
SqlJsKernelBackend
|
|
14
|
+
} from "../index-h9e2efx4.js";
|
|
15
|
+
import {
|
|
16
|
+
createKernelBackend
|
|
17
|
+
} from "../index-h32txmxe.js";
|
|
12
18
|
import {
|
|
13
19
|
DatalogRuntime,
|
|
14
20
|
parseQuery,
|
|
@@ -16,9 +22,11 @@ import {
|
|
|
16
22
|
parseSimple
|
|
17
23
|
} from "../index-n9f2qyh5.js";
|
|
18
24
|
import {
|
|
19
|
-
SqliteKernelBackend,
|
|
20
25
|
TrellisKernel
|
|
21
|
-
} from "../index-
|
|
26
|
+
} from "../index-4wxa8xz4.js";
|
|
27
|
+
import {
|
|
28
|
+
QueryEngine
|
|
29
|
+
} from "../index-yp88he8n.js";
|
|
22
30
|
import {
|
|
23
31
|
EAVStore,
|
|
24
32
|
flatten,
|
|
@@ -26,8 +34,8 @@ import {
|
|
|
26
34
|
jsonEntityFacts
|
|
27
35
|
} from "../index-yhwjgfvj.js";
|
|
28
36
|
import {
|
|
29
|
-
|
|
30
|
-
} from "../index-
|
|
37
|
+
SqliteKernelBackend
|
|
38
|
+
} from "../index-h7zxhhhh.js";
|
|
31
39
|
import"../index-a76rekgs.js";
|
|
32
40
|
|
|
33
41
|
// src/core/index.ts
|
|
@@ -565,10 +573,12 @@ export {
|
|
|
565
573
|
jsonEntityFacts,
|
|
566
574
|
flatten,
|
|
567
575
|
createValidationMiddleware,
|
|
576
|
+
createKernelBackend,
|
|
568
577
|
builtinOntologies,
|
|
569
578
|
agentOntology,
|
|
570
579
|
TrellisKernel,
|
|
571
580
|
SqliteKernelBackend,
|
|
581
|
+
SqlJsKernelBackend,
|
|
572
582
|
QueryEngine,
|
|
573
583
|
PluginRegistry,
|
|
574
584
|
OntologyRegistry,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel backend factory.
|
|
3
|
+
*
|
|
4
|
+
* Picks the right `KernelBackend` for the host runtime:
|
|
5
|
+
* - Bun → SqliteKernelBackend (bun:sqlite, native)
|
|
6
|
+
* - Node + better-sqlite3 installed → BetterSqliteKernelBackend
|
|
7
|
+
* - Otherwise → SqlJsKernelBackend (pure WASM, requires `sql.js`)
|
|
8
|
+
*
|
|
9
|
+
* This is an additive helper; existing callsites that construct a specific
|
|
10
|
+
* backend directly are unaffected. Use this when you want runtime portability
|
|
11
|
+
* (e.g. WebContainer demos, browser builds, restricted Node hosts).
|
|
12
|
+
*
|
|
13
|
+
* @module trellis/core/persist
|
|
14
|
+
*/
|
|
15
|
+
import type { KernelBackend } from './backend.js';
|
|
16
|
+
export interface CreateKernelBackendOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Override automatic detection. Useful for tests and for environments
|
|
19
|
+
* where the runtime check would pick the wrong backend.
|
|
20
|
+
*/
|
|
21
|
+
backend?: 'bun' | 'better-sqlite' | 'sqljs';
|
|
22
|
+
/** Forwarded to `SqlJsKernelBackend` when that backend is selected. */
|
|
23
|
+
sqljs?: {
|
|
24
|
+
autoFlushEvery?: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare function createKernelBackend(dbPath: string, opts?: CreateKernelBackendOptions): Promise<KernelBackend>;
|
|
28
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/core/persist/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,eAAe,GAAG,OAAO,CAAC;IAC5C,uEAAuE;IACvE,KAAK,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,0BAA+B,GACpC,OAAO,CAAC,aAAa,CAAC,CA0BxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-backend.d.ts","sourceRoot":"","sources":["../../../src/core/persist/sqlite-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"sqlite-backend.d.ts","sourceRoot":"","sources":["../../../src/core/persist/sqlite-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA6D5D,qBAAa,mBAAoB,YAAW,aAAa;IAiB3C,OAAO,CAAC,MAAM;IAhB1B,OAAO,CAAC,EAAE,CAAW;IACrB,OAAO,CAAC,MAAM,CAaE;gBAEI,MAAM,EAAE,MAAM;IAKlC,IAAI,IAAI,IAAI;IAQZ,OAAO,CAAC,kBAAkB;IAqD1B,MAAM,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI;IAoB1B,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI;IASlC,OAAO,IAAI,QAAQ,EAAE;IAKrB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE;IAKnC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE;IAKnC,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,EAAE;IAUpD,SAAS,IAAI,QAAQ,GAAG,SAAS;IAKjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAI7C,UAAU,IAAI,MAAM;IAIpB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAK/C,KAAK,IAAI,MAAM;IAKf;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IA2BtE,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI;IAOjD,kBAAkB,IAAI;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,GAAG,SAAS;IAanE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI;IAOhD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAM7C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQ9B,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sql.js-backed Kernel Backend
|
|
3
|
+
*
|
|
4
|
+
* Pure-WASM SQLite. Use this backend in environments that cannot load
|
|
5
|
+
* native binaries or `bun:sqlite` — Node-without-Bun, WebContainer, browser.
|
|
6
|
+
*
|
|
7
|
+
* sql.js holds the database image in memory. Persistence is implemented by
|
|
8
|
+
* snapshotting the full image to disk on close and at a configurable write
|
|
9
|
+
* interval. Appropriate for kernel op-log sized datasets; not appropriate
|
|
10
|
+
* for very large stores where incremental flushes matter.
|
|
11
|
+
*
|
|
12
|
+
* @module trellis/core/persist
|
|
13
|
+
*/
|
|
14
|
+
import type { KernelOp, KernelBackend } from './backend.js';
|
|
15
|
+
export interface SqlJsKernelBackendOptions {
|
|
16
|
+
/** Filesystem path to load/persist DB image. Pass `:memory:` to disable disk I/O. */
|
|
17
|
+
dbPath: string;
|
|
18
|
+
/** Auto-flush every N writes. Default 50. Set 0 to disable auto-flush. */
|
|
19
|
+
autoFlushEvery?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class SqlJsKernelBackend implements KernelBackend {
|
|
22
|
+
private opts;
|
|
23
|
+
private db;
|
|
24
|
+
private stmts;
|
|
25
|
+
private writes;
|
|
26
|
+
private flushEvery;
|
|
27
|
+
private initialized;
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Async factory — sql.js WASM init is async, but the resulting backend
|
|
31
|
+
* exposes the synchronous KernelBackend surface, so it slots into the
|
|
32
|
+
* existing kernel without interface changes.
|
|
33
|
+
*/
|
|
34
|
+
static create(opts: SqlJsKernelBackendOptions): Promise<SqlJsKernelBackend>;
|
|
35
|
+
private bootstrap;
|
|
36
|
+
private loadFromDisk;
|
|
37
|
+
private flushToDisk;
|
|
38
|
+
init(): void;
|
|
39
|
+
private prepareStatements;
|
|
40
|
+
append(op: KernelOp): void;
|
|
41
|
+
readAll(): KernelOp[];
|
|
42
|
+
readUntil(hash: string): KernelOp[];
|
|
43
|
+
readAfter(hash: string): KernelOp[];
|
|
44
|
+
readUntilTimestamp(iso: string): KernelOp[];
|
|
45
|
+
getByHash(hash: string): KernelOp | undefined;
|
|
46
|
+
getLastOp(): KernelOp | undefined;
|
|
47
|
+
getOpCount(): number;
|
|
48
|
+
saveSnapshot(lastOpHash: string, data: any): void;
|
|
49
|
+
loadLatestSnapshot(): {
|
|
50
|
+
lastOpHash: string;
|
|
51
|
+
data: any;
|
|
52
|
+
} | undefined;
|
|
53
|
+
close(): void;
|
|
54
|
+
/** Force a write of the in-memory DB image to disk. */
|
|
55
|
+
flush(): void;
|
|
56
|
+
private runAll;
|
|
57
|
+
private runOne;
|
|
58
|
+
private tickFlush;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=sqljs-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqljs-backend.d.ts","sourceRoot":"","sources":["../../../src/core/persist/sqljs-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAgC5D,MAAM,WAAW,yBAAyB;IACxC,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,kBAAmB,YAAW,aAAa;IAOlC,OAAO,CAAC,IAAI;IANhC,OAAO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6
|
+
import"../index-bmyt7k8n.js";
|
|
7
|
+
import"../index-y6a4kj0p.js";
|
|
3
8
|
import {
|
|
4
9
|
ADMIN_ONLY,
|
|
5
10
|
ANONYMOUS,
|
|
@@ -17,22 +22,17 @@ import {
|
|
|
17
22
|
signJwt,
|
|
18
23
|
startServer,
|
|
19
24
|
verifyJwt
|
|
20
|
-
} from "../index-
|
|
25
|
+
} from "../index-53f3b8p8.js";
|
|
21
26
|
import {
|
|
22
27
|
importFile,
|
|
23
28
|
importRecords
|
|
24
29
|
} from "../index-skhn0agf.js";
|
|
25
|
-
import {
|
|
26
|
-
deploy
|
|
27
|
-
} from "../index-wt8rz4gn.js";
|
|
28
|
-
import"../index-bmyt7k8n.js";
|
|
29
|
-
import"../index-y6a4kj0p.js";
|
|
30
30
|
import"../index-n9f2qyh5.js";
|
|
31
31
|
import"../index-k5b0xskw.js";
|
|
32
32
|
import {
|
|
33
33
|
FetchError,
|
|
34
34
|
TrellisDb
|
|
35
|
-
} from "../index-
|
|
35
|
+
} from "../index-wncptktd.js";
|
|
36
36
|
import {
|
|
37
37
|
CONFIG_FILE,
|
|
38
38
|
configPath,
|
|
@@ -45,10 +45,11 @@ import {
|
|
|
45
45
|
import {
|
|
46
46
|
DEFAULT_TENANT,
|
|
47
47
|
TenantPool
|
|
48
|
-
} from "../index-
|
|
49
|
-
import"../index-
|
|
50
|
-
import"../index-yhwjgfvj.js";
|
|
48
|
+
} from "../index-7pjz3tsy.js";
|
|
49
|
+
import"../index-4wxa8xz4.js";
|
|
51
50
|
import"../index-yp88he8n.js";
|
|
51
|
+
import"../index-yhwjgfvj.js";
|
|
52
|
+
import"../index-h7zxhhhh.js";
|
|
52
53
|
import"../index-a76rekgs.js";
|
|
53
54
|
export {
|
|
54
55
|
writeConfig,
|
package/dist/embeddings/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/embeddings/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/embeddings/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,SAAS,EAET,eAAe,EACf,aAAa,EACb,YAAY,EACb,MAAM,YAAY,CAAC;AAqDpB,qBAAa,WAAW;IACtB,OAAO,CAAC,EAAE,CAAW;gBAET,MAAM,EAAE,MAAM;IAQ1B;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IA4BrC;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;IA+B7C;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAetC;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAepC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAQtC;;;OAGG;IACH,MAAM,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,GAAE,aAAkB,GAAG,YAAY,EAAE;IAwD3E;;OAEG;IACH,KAAK,IAAI,MAAM;IAOf;;OAEG;IACH,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAarC;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAiBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,CAYzE"}
|