trellis 3.1.35 → 3.2.2
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/CHANGELOG.md +23 -5
- package/README.md +63 -156
- package/bin/trellis.mjs +2 -75
- package/dist/{better-sqlite-backend-ahx5p0br.js → better-sqlite-backend-2P4F6AOJ.js} +91 -29
- package/dist/boot-middleware-MHLHFCUC.js +9 -0
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +95 -0
- package/dist/{index-53f3b8p8.js → chunk-2W3MHTMG.js} +552 -213
- package/dist/chunk-44FFQKQX.js +142 -0
- package/dist/chunk-4HYPLFJD.js +150 -0
- package/dist/chunk-4XIVMVHC.js +361 -0
- package/dist/{index-yp88he8n.js → chunk-6CTA6MCE.js} +88 -64
- package/dist/chunk-6GEZ6DN5.js +394 -0
- package/dist/chunk-7ZFRVCUE.js +211 -0
- package/dist/chunk-CAG4FULI.js +121 -0
- package/dist/chunk-FF36CQHZ.js +61 -0
- package/dist/{index-h32txmxe.js → chunk-FKQO5A3H.js} +6 -13
- package/dist/{index-nq520y6k.js → chunk-FWRS4CSC.js} +46 -32
- package/dist/chunk-GFZCJ4EH.js +108 -0
- package/dist/chunk-GLM4HGN4.js +55 -0
- package/dist/{index-4cdr7x2x.js → chunk-GU374KWZ.js} +182 -111
- package/dist/chunk-H6JB3PZ3.js +45 -0
- package/dist/chunk-IZX2PLIB.js +1240 -0
- package/dist/chunk-J2TXUFCZ.js +289 -0
- package/dist/chunk-J3WYZO3Q.js +211 -0
- package/dist/{index-xzym9w0m.js → chunk-JA7AIHRK.js} +12 -7
- package/dist/chunk-JHHEXEDM.js +162 -0
- package/dist/chunk-JUEMDWLU.js +233 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/chunk-KIJITUZB.js +419 -0
- package/dist/{index-4wxa8xz4.js → chunk-KQ4A2D2P.js} +162 -23
- package/dist/chunk-KSU2GW22.js +958 -0
- package/dist/{index-rv1p47gp.js → chunk-L5N5PR2S.js} +3015 -2480
- package/dist/{index-h9e2efx4.js → chunk-LNUIGRDZ.js} +71 -55
- package/dist/{index-skhn0agf.js → chunk-MLC5BUYO.js} +19 -20
- package/dist/chunk-MPXUVGT3.js +104 -0
- package/dist/chunk-N6MYZT4O.js +68 -0
- package/dist/chunk-O2AV5WMN.js +48 -0
- package/dist/chunk-PZ4XYZ4J.js +143 -0
- package/dist/chunk-QB5ISE47.js +419 -0
- package/dist/chunk-RSWUFTO2.js +857 -0
- package/dist/chunk-S3XLFZ27.js +1095 -0
- package/dist/{index-w5wccer3.js → chunk-S6GBJ2ZB.js} +28 -12
- package/dist/{index-7pjz3tsy.js → chunk-SGMDTWJJ.js} +57 -15
- package/dist/chunk-SPSPV5BC.js +390 -0
- package/dist/chunk-TCKXSOBP.js +123 -0
- package/dist/chunk-UBGUDMUV.js +59 -0
- package/dist/{index-wt8rz4gn.js → chunk-UQISRW6T.js} +97 -26
- package/dist/chunk-USEINYUL.js +12 -0
- package/dist/{index-bmyt7k8n.js → chunk-UZRUP7QW.js} +12 -4
- package/dist/{index-xhcp6xrn.js → chunk-VBYUTRXX.js} +695 -514
- package/dist/{index-vkpkfwhq.js → chunk-VDAKEOML.js} +234 -194
- package/dist/chunk-WXSWA3MV.js +0 -0
- package/dist/{index-n9f2qyh5.js → chunk-X5FLTRUB.js} +55 -33
- package/dist/{index-h7zxhhhh.js → chunk-XMQ7G77X.js} +46 -38
- package/dist/{index-w7ng765c.js → chunk-YCM7ZYEZ.js} +102 -49
- package/dist/cli/deploy-cli.d.ts +18 -0
- package/dist/cli/deploy-cli.d.ts.map +1 -0
- package/dist/cli/errors.d.ts +6 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/examples.d.ts +23 -0
- package/dist/cli/examples.d.ts.map +1 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2426 -6225
- package/dist/client/index.browser.d.ts +29 -0
- package/dist/client/index.browser.d.ts.map +1 -0
- package/dist/client/index.browser.js +64 -0
- package/dist/client/index.d.ts +6 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +41 -21
- package/dist/client/live.d.ts +67 -0
- package/dist/client/live.d.ts.map +1 -0
- package/dist/client/reactive.d.ts +31 -0
- package/dist/client/reactive.d.ts.map +1 -0
- package/dist/client/sdk.browser.d.ts +104 -0
- package/dist/client/sdk.browser.d.ts.map +1 -0
- package/dist/client/sdk.browser.js +9 -0
- package/dist/client/sdk.d.ts +26 -2
- package/dist/client/sdk.d.ts.map +1 -1
- package/dist/client/sdk.js +9 -0
- package/dist/client/vcs-client.d.ts +129 -0
- package/dist/client/vcs-client.d.ts.map +1 -0
- package/dist/cms/index.js +171 -163
- package/dist/{config-8hczw0rs.js → config-PFTP67TR.js} +8 -9
- package/dist/core/computation/index.d.ts +5 -0
- package/dist/core/computation/index.d.ts.map +1 -0
- package/dist/core/computation/rollup.d.ts +18 -0
- package/dist/core/computation/rollup.d.ts.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +171 -104
- package/dist/core/kernel/boot-middleware.d.ts +10 -0
- package/dist/core/kernel/boot-middleware.d.ts.map +1 -0
- package/dist/core/kernel/logic-middleware.d.ts +7 -1
- package/dist/core/kernel/logic-middleware.d.ts.map +1 -1
- package/dist/core/kernel/trellis-kernel.d.ts.map +1 -1
- package/dist/core/ontology/types.d.ts +5 -0
- package/dist/core/ontology/types.d.ts.map +1 -1
- package/dist/core/persist/better-sqlite-backend.d.ts +9 -2
- package/dist/core/persist/better-sqlite-backend.d.ts.map +1 -1
- package/dist/core/persist/factory.d.ts +6 -7
- package/dist/core/persist/factory.d.ts.map +1 -1
- package/dist/core/persist/factory.js +2 -3
- package/dist/core/persist/sqljs-backend.js +2 -3
- package/dist/db/index.d.ts +4 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +67 -54
- package/dist/db/inspector.js +11 -19
- package/dist/db/trellis.css +1 -1
- package/dist/decisions/index.js +9 -10
- package/dist/deploy-LQ7GUGJ5.js +9 -0
- package/dist/deploy-YNVG5E4E.js +9 -0
- package/dist/deploy-cli-24BCHAXY.js +67 -0
- package/dist/deploy-cli-C35HTITO.js +67 -0
- package/dist/embeddings/auto-embed.d.ts +2 -2
- package/dist/embeddings/auto-embed.d.ts.map +1 -1
- package/dist/embeddings/index.js +20 -22
- package/dist/embeddings/search.d.ts +2 -1
- package/dist/embeddings/search.d.ts.map +1 -1
- package/dist/embeddings/store.d.ts +25 -4
- package/dist/embeddings/store.d.ts.map +1 -1
- package/dist/engine.d.ts +59 -19
- package/dist/engine.d.ts.map +1 -1
- package/dist/import-UZEKXU3B.js +10 -0
- package/dist/index.js +102 -93
- package/dist/launch-explorer-HZ4ZJA4X.js +95 -0
- package/dist/links/index.js +24 -26
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/plugins/agent-memory/index.js +316 -0
- package/dist/plugins/idea-garden/index.js +165 -0
- package/dist/plugins/plan-approval/index.js +579 -0
- package/dist/plugins/proactive-watcher/index.js +194 -0
- package/dist/{index-2r4jxwnb.js → query-XYLTJYSA.js} +14 -15
- package/dist/react/index.js +39 -70
- package/dist/react/realtime.js +11 -0
- package/dist/react/schema-hooks.js +87 -0
- package/dist/realtime/broadcast-channel-transport.d.ts +43 -0
- package/dist/realtime/broadcast-channel-transport.d.ts.map +1 -0
- package/dist/realtime/durable-object-relay-transport.d.ts +96 -0
- package/dist/realtime/durable-object-relay-transport.d.ts.map +1 -0
- package/dist/realtime/index.d.ts +44 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +40 -0
- package/dist/realtime/memory-hub.d.ts +32 -0
- package/dist/realtime/memory-hub.d.ts.map +1 -0
- package/dist/realtime/persistent-channel.d.ts +105 -0
- package/dist/realtime/persistent-channel.d.ts.map +1 -0
- package/dist/realtime/presence.d.ts +73 -0
- package/dist/realtime/presence.d.ts.map +1 -0
- package/dist/realtime/relay-persistence.d.ts +37 -0
- package/dist/realtime/relay-persistence.d.ts.map +1 -0
- package/dist/realtime/relay-persistence.js +107 -0
- package/dist/realtime/relay-server.d.ts +103 -0
- package/dist/realtime/relay-server.d.ts.map +1 -0
- package/dist/realtime/room.d.ts +98 -0
- package/dist/realtime/room.d.ts.map +1 -0
- package/dist/realtime/text.d.ts +73 -0
- package/dist/realtime/text.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +89 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/dist/realtime/websocket-relay-transport.d.ts +28 -0
- package/dist/realtime/websocket-relay-transport.d.ts.map +1 -0
- package/dist/realtime.bundle.js +1100 -0
- package/dist/{remote-manager-xvbg4230.js → remote-manager-ODE3T2KR.js} +25 -15
- package/dist/scaffold/seed.d.ts.map +1 -1
- package/dist/scaffold/write.d.ts +1 -1
- package/dist/scaffold/write.d.ts.map +1 -1
- package/dist/schema/define.d.ts +137 -0
- package/dist/schema/define.d.ts.map +1 -0
- package/dist/schema/entity-projection.d.ts +34 -0
- package/dist/schema/entity-projection.d.ts.map +1 -0
- package/dist/schema/eql.d.ts +46 -0
- package/dist/schema/eql.d.ts.map +1 -0
- package/dist/schema/index.d.ts +21 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +46 -0
- package/dist/schema/kernel-resolve.d.ts +21 -0
- package/dist/schema/kernel-resolve.d.ts.map +1 -0
- package/dist/schema/mutations.d.ts +20 -0
- package/dist/schema/mutations.d.ts.map +1 -0
- package/dist/schema/resolve.d.ts +21 -0
- package/dist/schema/resolve.d.ts.map +1 -0
- package/dist/server/deploy-meta.d.ts +25 -0
- package/dist/server/deploy-meta.d.ts.map +1 -0
- package/dist/server/deploy.d.ts +7 -2
- package/dist/server/deploy.d.ts.map +1 -1
- package/dist/server/index.d.ts +7 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +100 -58
- package/dist/server/node-adapter.js +5 -104
- package/dist/server/realtime.d.ts +14 -3
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/server.d.ts +8 -16
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/sprites.d.ts +18 -1
- package/dist/server/sprites.d.ts.map +1 -1
- package/dist/server/tenancy.d.ts +4 -0
- package/dist/server/tenancy.d.ts.map +1 -1
- package/dist/server/usage-meter.d.ts +53 -0
- package/dist/server/usage-meter.d.ts.map +1 -0
- package/dist/server-MB3OPSPI.js +18 -0
- package/dist/server-ZVWGLLRF.js +18 -0
- package/dist/sprites-KQGTGM6W.js +27 -0
- package/dist/{sprites-vc4qbrp1.js → sprites-RU3E4XQN.js} +6 -7
- package/dist/svelte/index.d.ts +17 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +51 -0
- package/dist/svelte/schema-hooks.d.ts +45 -0
- package/dist/svelte/schema-hooks.d.ts.map +1 -0
- package/dist/svelte/schema-hooks.js +71 -0
- package/dist/svelte/stores.d.ts +78 -0
- package/dist/svelte/stores.d.ts.map +1 -0
- package/dist/sync/http-transport.d.ts +3 -3
- package/dist/sync/http-transport.d.ts.map +1 -1
- package/dist/sync/index.d.ts +15 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +617 -0
- package/dist/sync/memory-room.d.ts +37 -0
- package/dist/sync/memory-room.d.ts.map +1 -0
- package/dist/sync/memory-transport.d.ts +3 -3
- package/dist/sync/memory-transport.d.ts.map +1 -1
- package/dist/sync/partykit-room.d.ts +40 -0
- package/dist/sync/partykit-room.d.ts.map +1 -0
- package/dist/sync/partykit-transport.d.ts +84 -0
- package/dist/sync/partykit-transport.d.ts.map +1 -0
- package/dist/sync/room-core.d.ts +53 -0
- package/dist/sync/room-core.d.ts.map +1 -0
- package/dist/sync/sync-engine.d.ts +40 -2
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-room-server.d.ts +39 -0
- package/dist/sync/sync-room-server.d.ts.map +1 -0
- package/dist/sync/types.d.ts +70 -3
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/vcs-sync-peer.d.ts +63 -0
- package/dist/sync/vcs-sync-peer.d.ts.map +1 -0
- package/dist/sync/ws-transport.d.ts +2 -2
- package/dist/sync/ws-transport.d.ts.map +1 -1
- package/dist/tenancy-NBLLGCNJ.js +14 -0
- package/dist/tenancy-POMWQP6M.js +16 -0
- package/dist/ui/client.html +355 -67
- package/dist/ui/launch-explorer.d.ts +22 -0
- package/dist/ui/launch-explorer.d.ts.map +1 -0
- package/dist/ui/server.d.ts +1 -1
- package/dist/ui/server.d.ts.map +1 -1
- package/dist/vcs/blob-store.d.ts.map +1 -1
- package/dist/vcs/idb-op-log.d.ts +67 -0
- package/dist/vcs/idb-op-log.d.ts.map +1 -0
- package/dist/vcs/index.d.ts +1 -0
- package/dist/vcs/index.d.ts.map +1 -1
- package/dist/vcs/index.js +81 -72
- package/dist/vcs/issue.d.ts +22 -5
- package/dist/vcs/issue.d.ts.map +1 -1
- package/dist/vcs/lane-materialize.d.ts +5 -0
- package/dist/vcs/lane-materialize.d.ts.map +1 -1
- package/dist/vcs/op-log.d.ts +28 -2
- package/dist/vcs/op-log.d.ts.map +1 -1
- package/dist/vcs/ops.d.ts +10 -0
- package/dist/vcs/ops.d.ts.map +1 -1
- package/dist/vcs/types.d.ts +2 -0
- package/dist/vcs/types.d.ts.map +1 -1
- package/dist/{vm-config-6xhsj6b3.js → vm-config-JI4OXKDQ.js} +9 -10
- package/dist/vue/hooks.d.ts +64 -0
- package/dist/vue/hooks.d.ts.map +1 -0
- package/dist/vue/index.d.ts +19 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +59 -0
- package/dist/vue/schema-hooks.d.ts +41 -0
- package/dist/vue/schema-hooks.d.ts.map +1 -0
- package/dist/vue/schema-hooks.js +64 -0
- package/package.json +130 -17
- package/dist/deploy-999q207z.js +0 -10
- package/dist/engine-y0724kjq.js +0 -8
- package/dist/import-s2b8e0ft.js +0 -11
- package/dist/index-a76rekgs.js +0 -67
- package/dist/index-c9h37r6h.js +0 -1
- package/dist/index-hr9qvv77.js +0 -860
- package/dist/index-k5b0xskw.js +0 -1
- package/dist/index-nzb3am4f.js +0 -80
- package/dist/index-wncptktd.js +0 -292
- package/dist/index-y6a4kj0p.js +0 -43
- package/dist/index-yhwjgfvj.js +0 -342
- package/dist/sdk-bepky0xs.js +0 -16
- package/dist/server-szdjx0nt.js +0 -13
- package/dist/sqlite-backend-0vsmc6qj.js +0 -8
- package/dist/tenancy-pjm32b4v.js +0 -14
package/dist/index-k5b0xskw.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// @bun
|
package/dist/index-nzb3am4f.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
__esm
|
|
4
|
-
} from "./index-a76rekgs.js";
|
|
5
|
-
|
|
6
|
-
// src/vcs/ops.ts
|
|
7
|
-
async function createVcsOp(kind, params) {
|
|
8
|
-
const opBase = {
|
|
9
|
-
kind,
|
|
10
|
-
timestamp: new Date().toISOString(),
|
|
11
|
-
agentId: params.agentId,
|
|
12
|
-
previousHash: params.previousHash,
|
|
13
|
-
vcs: params.vcs
|
|
14
|
-
};
|
|
15
|
-
const content = JSON.stringify(opBase);
|
|
16
|
-
const msgUint8 = new TextEncoder().encode(content);
|
|
17
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8);
|
|
18
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
19
|
-
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
20
|
-
return {
|
|
21
|
-
...opBase,
|
|
22
|
-
hash: `trellis:op:${hashHex}`
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function isVcsOp(op) {
|
|
26
|
-
return op.vcs !== undefined || typeof op.kind === "string" && op.kind.startsWith("vcs:");
|
|
27
|
-
}
|
|
28
|
-
function isVcsOpKind(kind) {
|
|
29
|
-
return kind.startsWith("vcs:");
|
|
30
|
-
}
|
|
31
|
-
var init_ops = () => {};
|
|
32
|
-
|
|
33
|
-
// src/vcs/types.ts
|
|
34
|
-
function fileEntityId(path) {
|
|
35
|
-
return `file:${path}`;
|
|
36
|
-
}
|
|
37
|
-
function dirEntityId(path) {
|
|
38
|
-
return `dir:${path}`;
|
|
39
|
-
}
|
|
40
|
-
function branchEntityId(name) {
|
|
41
|
-
return `branch:${name}`;
|
|
42
|
-
}
|
|
43
|
-
function milestoneEntityId(hash) {
|
|
44
|
-
return `milestone:${hash}`;
|
|
45
|
-
}
|
|
46
|
-
function checkpointEntityId(hash) {
|
|
47
|
-
return `checkpoint:${hash}`;
|
|
48
|
-
}
|
|
49
|
-
function issueEntityId(id) {
|
|
50
|
-
return id.startsWith("issue:") ? id : `issue:${id}`;
|
|
51
|
-
}
|
|
52
|
-
function criterionEntityId(issueId, index) {
|
|
53
|
-
const bare = issueId.replace(/^issue:/, "");
|
|
54
|
-
return `criterion:${bare}:ac-${index}`;
|
|
55
|
-
}
|
|
56
|
-
function decisionEntityId(id) {
|
|
57
|
-
return id.startsWith("decision:") ? id : `decision:${id}`;
|
|
58
|
-
}
|
|
59
|
-
function laneEntityId(id) {
|
|
60
|
-
return id.startsWith("lane:") ? id : `lane:${id}`;
|
|
61
|
-
}
|
|
62
|
-
var DEFAULT_CONFIG;
|
|
63
|
-
var init_types = __esm(() => {
|
|
64
|
-
DEFAULT_CONFIG = {
|
|
65
|
-
ignorePatterns: [
|
|
66
|
-
"node_modules",
|
|
67
|
-
".git",
|
|
68
|
-
".trellis",
|
|
69
|
-
"dist",
|
|
70
|
-
"build",
|
|
71
|
-
".DS_Store",
|
|
72
|
-
"*.log"
|
|
73
|
-
],
|
|
74
|
-
debounceMs: 300,
|
|
75
|
-
defaultBranch: "main",
|
|
76
|
-
dbPath: ".trellis/trellis.db"
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export { createVcsOp, isVcsOp, isVcsOpKind, init_ops, fileEntityId, dirEntityId, branchEntityId, milestoneEntityId, checkpointEntityId, issueEntityId, criterionEntityId, decisionEntityId, laneEntityId, DEFAULT_CONFIG, init_types };
|
package/dist/index-wncptktd.js
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
readConfig
|
|
4
|
-
} from "./index-xzym9w0m.js";
|
|
5
|
-
import {
|
|
6
|
-
TenantPool
|
|
7
|
-
} from "./index-7pjz3tsy.js";
|
|
8
|
-
import {
|
|
9
|
-
__require
|
|
10
|
-
} from "./index-a76rekgs.js";
|
|
11
|
-
|
|
12
|
-
// src/client/sdk.ts
|
|
13
|
-
function isRemote(opts) {
|
|
14
|
-
return "url" in opts;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class TrellisDb {
|
|
18
|
-
opts;
|
|
19
|
-
_pool = null;
|
|
20
|
-
_ws = null;
|
|
21
|
-
_subCallbacks = new Map;
|
|
22
|
-
constructor(opts) {
|
|
23
|
-
this.opts = opts;
|
|
24
|
-
}
|
|
25
|
-
static fromConfig(dir = ".") {
|
|
26
|
-
const config = readConfig(dir);
|
|
27
|
-
if (!config)
|
|
28
|
-
throw new Error("No .trellis-db.json found. Run `trellis db init` first.");
|
|
29
|
-
if (config.mode === "remote" && config.url) {
|
|
30
|
-
return new TrellisDb({ url: config.url, apiKey: config.apiKey });
|
|
31
|
-
}
|
|
32
|
-
if (config.dbPath) {
|
|
33
|
-
return new TrellisDb({ path: config.dbPath });
|
|
34
|
-
}
|
|
35
|
-
throw new Error("Invalid .trellis-db.json: missing url or dbPath.");
|
|
36
|
-
}
|
|
37
|
-
async create(type, attributes = {}, links) {
|
|
38
|
-
if (isRemote(this.opts)) {
|
|
39
|
-
const res = await this._fetch("POST", "/entities", {
|
|
40
|
-
type,
|
|
41
|
-
attributes,
|
|
42
|
-
links
|
|
43
|
-
});
|
|
44
|
-
return res.id;
|
|
45
|
-
}
|
|
46
|
-
const pool = this._getPool();
|
|
47
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
48
|
-
const kernel = pool.get(tenantId);
|
|
49
|
-
const entityId = `${type.toLowerCase()}:${crypto.randomUUID()}`;
|
|
50
|
-
await kernel.createEntity(entityId, type, attributes, links);
|
|
51
|
-
return entityId;
|
|
52
|
-
}
|
|
53
|
-
async read(id) {
|
|
54
|
-
if (isRemote(this.opts)) {
|
|
55
|
-
try {
|
|
56
|
-
return await this._fetch("GET", `/entities/${encodeURIComponent(id)}`);
|
|
57
|
-
} catch (err) {
|
|
58
|
-
if (err?.status === 404)
|
|
59
|
-
return null;
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const pool = this._getPool();
|
|
64
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
65
|
-
const kernel = pool.get(tenantId);
|
|
66
|
-
const entity = kernel.getEntity(id);
|
|
67
|
-
if (!entity)
|
|
68
|
-
return null;
|
|
69
|
-
return entityToPlain(entity);
|
|
70
|
-
}
|
|
71
|
-
async update(id, attributes) {
|
|
72
|
-
if (isRemote(this.opts)) {
|
|
73
|
-
await this._fetch("PUT", `/entities/${encodeURIComponent(id)}`, attributes);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const pool = this._getPool();
|
|
77
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
78
|
-
const kernel = pool.get(tenantId);
|
|
79
|
-
await kernel.updateEntity(id, attributes);
|
|
80
|
-
}
|
|
81
|
-
async delete(id) {
|
|
82
|
-
if (isRemote(this.opts)) {
|
|
83
|
-
await this._fetch("DELETE", `/entities/${encodeURIComponent(id)}`);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const pool = this._getPool();
|
|
87
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
88
|
-
const kernel = pool.get(tenantId);
|
|
89
|
-
await kernel.deleteEntity(id);
|
|
90
|
-
}
|
|
91
|
-
async list(type, opts = {}) {
|
|
92
|
-
if (isRemote(this.opts)) {
|
|
93
|
-
const params = new URLSearchParams;
|
|
94
|
-
if (type)
|
|
95
|
-
params.set("type", type);
|
|
96
|
-
if (opts.limit)
|
|
97
|
-
params.set("limit", String(opts.limit));
|
|
98
|
-
if (opts.offset)
|
|
99
|
-
params.set("offset", String(opts.offset));
|
|
100
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
101
|
-
return await this._fetch("GET", `/entities${qs}`);
|
|
102
|
-
}
|
|
103
|
-
const pool = this._getPool();
|
|
104
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
105
|
-
const kernel = pool.get(tenantId);
|
|
106
|
-
const entities = kernel.listEntities(type, opts.filters);
|
|
107
|
-
const limit = opts.limit ?? 100;
|
|
108
|
-
const offset = opts.offset ?? 0;
|
|
109
|
-
const page = entities.slice(offset, offset + limit);
|
|
110
|
-
return {
|
|
111
|
-
data: page.map(entityToPlain),
|
|
112
|
-
total: entities.length,
|
|
113
|
-
limit,
|
|
114
|
-
offset
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
async query(eql) {
|
|
118
|
-
if (isRemote(this.opts)) {
|
|
119
|
-
return await this._fetch("POST", "/query", {
|
|
120
|
-
query: eql
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
const { parseSimple } = await import("./index-2r4jxwnb.js");
|
|
124
|
-
const { QueryEngine } = await import("./engine-y0724kjq.js");
|
|
125
|
-
const pool = this._getPool();
|
|
126
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
127
|
-
const kernel = pool.get(tenantId);
|
|
128
|
-
const parsed = parseSimple(eql);
|
|
129
|
-
const engine = new QueryEngine(kernel.getStore());
|
|
130
|
-
return engine.execute(parsed);
|
|
131
|
-
}
|
|
132
|
-
async upload(data, contentType = "application/octet-stream") {
|
|
133
|
-
const raw = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
|
|
134
|
-
const cleanBuf = raw.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength);
|
|
135
|
-
const buffer = new Uint8Array(cleanBuf);
|
|
136
|
-
if (isRemote(this.opts)) {
|
|
137
|
-
const res = await fetch(`${this.opts.url}/upload`, {
|
|
138
|
-
method: "POST",
|
|
139
|
-
headers: {
|
|
140
|
-
"Content-Type": contentType,
|
|
141
|
-
...this.opts.apiKey ? { Authorization: `Bearer ${this.opts.apiKey}` } : {}
|
|
142
|
-
},
|
|
143
|
-
body: cleanBuf
|
|
144
|
-
});
|
|
145
|
-
if (!res.ok)
|
|
146
|
-
throw new FetchError(res.status, await res.text());
|
|
147
|
-
return await res.json();
|
|
148
|
-
}
|
|
149
|
-
const hashBuf = await crypto.subtle.digest("SHA-256", buffer);
|
|
150
|
-
const hash = `blob:${Array.from(new Uint8Array(hashBuf)).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
151
|
-
const pool = this._getPool();
|
|
152
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
153
|
-
const kernel = pool.get(tenantId);
|
|
154
|
-
const backend = kernel.getBackend();
|
|
155
|
-
if (!backend.hasBlob(hash))
|
|
156
|
-
backend.putBlob(hash, buffer);
|
|
157
|
-
return { hash, size: buffer.length, contentType };
|
|
158
|
-
}
|
|
159
|
-
async getFile(hash) {
|
|
160
|
-
if (isRemote(this.opts)) {
|
|
161
|
-
const res = await fetch(`${this.opts.url}/files/${encodeURIComponent(hash)}`, {
|
|
162
|
-
headers: this.opts.apiKey ? { Authorization: `Bearer ${this.opts.apiKey}` } : {}
|
|
163
|
-
});
|
|
164
|
-
if (res.status === 404)
|
|
165
|
-
return null;
|
|
166
|
-
if (!res.ok)
|
|
167
|
-
throw new FetchError(res.status, await res.text());
|
|
168
|
-
return new Uint8Array(await res.arrayBuffer());
|
|
169
|
-
}
|
|
170
|
-
const pool = this._getPool();
|
|
171
|
-
const tenantId = this.opts.tenantId ?? null;
|
|
172
|
-
const kernel = pool.get(tenantId);
|
|
173
|
-
const backend = kernel.getBackend();
|
|
174
|
-
return backend.getBlob(hash) ?? null;
|
|
175
|
-
}
|
|
176
|
-
async register(email, password, name) {
|
|
177
|
-
if (!isRemote(this.opts))
|
|
178
|
-
throw new Error("register() requires remote mode");
|
|
179
|
-
return await this._fetch("POST", "/auth/register", {
|
|
180
|
-
email,
|
|
181
|
-
password,
|
|
182
|
-
name
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
async login(email, password) {
|
|
186
|
-
if (!isRemote(this.opts))
|
|
187
|
-
throw new Error("login() requires remote mode");
|
|
188
|
-
return await this._fetch("POST", "/auth/login", {
|
|
189
|
-
email,
|
|
190
|
-
password
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
setToken(token) {
|
|
194
|
-
if (!isRemote(this.opts))
|
|
195
|
-
return;
|
|
196
|
-
this.opts.apiKey = token;
|
|
197
|
-
}
|
|
198
|
-
subscribe(eql, callback) {
|
|
199
|
-
if (!isRemote(this.opts)) {
|
|
200
|
-
throw new Error("subscribe() requires remote mode (connect to a running server)");
|
|
201
|
-
}
|
|
202
|
-
const subId = `sub_${crypto.randomUUID()}`;
|
|
203
|
-
this._subCallbacks.set(subId, callback);
|
|
204
|
-
this._ensureWs().then((ws) => {
|
|
205
|
-
ws.send(JSON.stringify({ type: "subscribe", id: subId, query: eql }));
|
|
206
|
-
});
|
|
207
|
-
return {
|
|
208
|
-
unsubscribe: () => {
|
|
209
|
-
this._subCallbacks.delete(subId);
|
|
210
|
-
this._ws?.send(JSON.stringify({ type: "unsubscribe", id: subId }));
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
disconnect() {
|
|
215
|
-
this._ws?.close();
|
|
216
|
-
this._ws = null;
|
|
217
|
-
}
|
|
218
|
-
close() {
|
|
219
|
-
this._pool?.closeAll();
|
|
220
|
-
this._pool = null;
|
|
221
|
-
this.disconnect();
|
|
222
|
-
}
|
|
223
|
-
_getPool() {
|
|
224
|
-
if (!this._pool) {
|
|
225
|
-
const path = this.opts.path;
|
|
226
|
-
this._pool = new TenantPool(path);
|
|
227
|
-
}
|
|
228
|
-
return this._pool;
|
|
229
|
-
}
|
|
230
|
-
async _fetch(method, path, body) {
|
|
231
|
-
const opts = this.opts;
|
|
232
|
-
const url = `${opts.url}${path}`;
|
|
233
|
-
const res = await fetch(url, {
|
|
234
|
-
method,
|
|
235
|
-
headers: {
|
|
236
|
-
"Content-Type": "application/json",
|
|
237
|
-
...opts.apiKey ? { Authorization: `Bearer ${opts.apiKey}` } : {}
|
|
238
|
-
},
|
|
239
|
-
body: body !== undefined ? JSON.stringify(body) : undefined
|
|
240
|
-
});
|
|
241
|
-
const data = await res.json();
|
|
242
|
-
if (!res.ok)
|
|
243
|
-
throw new FetchError(res.status, data?.message ?? res.statusText, data);
|
|
244
|
-
return data;
|
|
245
|
-
}
|
|
246
|
-
async _ensureWs() {
|
|
247
|
-
if (this._ws && this._ws.readyState === WebSocket.OPEN)
|
|
248
|
-
return this._ws;
|
|
249
|
-
const opts = this.opts;
|
|
250
|
-
const wsUrl = opts.url.replace(/^https?/, opts.url.startsWith("https") ? "wss" : "ws") + "/realtime";
|
|
251
|
-
return new Promise((resolve, reject) => {
|
|
252
|
-
const ws = new WebSocket(wsUrl);
|
|
253
|
-
ws.onopen = () => {
|
|
254
|
-
this._ws = ws;
|
|
255
|
-
resolve(ws);
|
|
256
|
-
};
|
|
257
|
-
ws.onerror = (e) => reject(e);
|
|
258
|
-
ws.onmessage = (e) => {
|
|
259
|
-
try {
|
|
260
|
-
const msg = JSON.parse(e.data);
|
|
261
|
-
if (msg.type === "data" && this._subCallbacks.has(msg.id)) {
|
|
262
|
-
this._subCallbacks.get(msg.id)(msg.result, msg.diff);
|
|
263
|
-
}
|
|
264
|
-
} catch {}
|
|
265
|
-
};
|
|
266
|
-
ws.onclose = () => {
|
|
267
|
-
this._ws = null;
|
|
268
|
-
};
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function entityToPlain(entity) {
|
|
273
|
-
const obj = { id: entity.id, type: entity.type };
|
|
274
|
-
for (const f of entity.facts) {
|
|
275
|
-
if (f.a !== "type")
|
|
276
|
-
obj[f.a] = f.v;
|
|
277
|
-
}
|
|
278
|
-
return obj;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
class FetchError extends Error {
|
|
282
|
-
status;
|
|
283
|
-
body;
|
|
284
|
-
constructor(status, message, body) {
|
|
285
|
-
super(`HTTP ${status}: ${message}`);
|
|
286
|
-
this.status = status;
|
|
287
|
-
this.body = body;
|
|
288
|
-
this.name = "FetchError";
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export { TrellisDb, FetchError };
|
package/dist/index-y6a4kj0p.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// src/server/sprites.ts
|
|
3
|
-
async function runSpriteCmd(args) {
|
|
4
|
-
const proc = Bun.spawn(["sprite", ...args], {
|
|
5
|
-
stdout: "pipe",
|
|
6
|
-
stderr: "pipe"
|
|
7
|
-
});
|
|
8
|
-
const exitCode = await proc.exited;
|
|
9
|
-
const stdout = await new Response(proc.stdout).text();
|
|
10
|
-
if (exitCode !== 0) {
|
|
11
|
-
const err = await new Response(proc.stderr).text();
|
|
12
|
-
throw new Error(`sprite ${args[0]} failed (exit ${exitCode}): ${err}`);
|
|
13
|
-
}
|
|
14
|
-
return stdout.trim();
|
|
15
|
-
}
|
|
16
|
-
async function runSpriteCopy(localPath, spriteName, remotePath) {
|
|
17
|
-
const proc = Bun.spawn(["sprite", "cp", localPath, `${spriteName}:${remotePath}`], { stdout: "pipe", stderr: "pipe" });
|
|
18
|
-
const exitCode = await proc.exited;
|
|
19
|
-
if (exitCode !== 0) {
|
|
20
|
-
const err = await new Response(proc.stderr).text();
|
|
21
|
-
throw new Error(`sprite cp failed (exit ${exitCode}): ${err}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function runSpriteInteractive(args) {
|
|
25
|
-
const proc = Bun.spawn(["sprite", ...args], { stdio: "inherit" });
|
|
26
|
-
const exitCode = await proc.exited;
|
|
27
|
-
if (exitCode !== 0) {
|
|
28
|
-
throw new Error(`sprite ${args[0]} failed (exit ${exitCode})`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function assertSpriteCli() {
|
|
32
|
-
await runSpriteCmd(["--version"]).catch(() => {
|
|
33
|
-
throw new Error("`sprite` CLI not found. Install it from https://docs.sprites.dev and authenticate.");
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function resolveSprite(explicitName) {
|
|
37
|
-
if (explicitName) {
|
|
38
|
-
return explicitName;
|
|
39
|
-
}
|
|
40
|
-
throw new Error("No sprite specified. Use --sprite <name> or set an active sprite with `trellis vm use <name>`");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { runSpriteCmd, runSpriteCopy, runSpriteInteractive, assertSpriteCli, resolveSprite };
|