@feltdb/core 0.9.0 → 0.10.0

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.
Files changed (105) hide show
  1. package/dist/authority-scope.d.ts +2 -0
  2. package/dist/authority-scope.d.ts.map +1 -1
  3. package/dist/authority-scope.js +7 -2
  4. package/dist/cli/commands.js +19 -21
  5. package/dist/cli/development-session.js +16 -0
  6. package/dist/cli/studio-artifact.js +33 -0
  7. package/dist/create/package-versions.js +1 -1
  8. package/dist/create/server-source/crates/feltdb/src/acceptance_tests.rs +8 -1
  9. package/dist/create/server-source/crates/feltdb/src/application.rs +16 -0
  10. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +21 -22
  11. package/dist/create/server-source/crates/feltdb/src/lib.rs +451 -33
  12. package/dist/create/server-source/crates/feltdb/src/state_contract.rs +48 -3
  13. package/dist/create/server-source/crates/feltdb/src/state_model.rs +569 -4
  14. package/dist/create/server-source/crates/feltdb/src/state_trigger.rs +1 -0
  15. package/dist/create/server-source/crates/feltdb/src/versioned_object_substrate.rs +708 -0
  16. package/dist/create/server-source/crates/feltdb/src/worker_mesh.rs +1 -0
  17. package/dist/create/server-source/crates/feltdb/src/workload.rs +480 -44
  18. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_evidence.rs +123 -0
  19. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +281 -0
  20. package/dist/create/server-source/crates/feltdb/tests/production_readiness_contract.rs +15 -3
  21. package/dist/create/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +28 -18
  22. package/dist/create/server-source/crates/feltdb/tests/storage_independent_versioned_object_substrate.rs +328 -0
  23. package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +20 -3
  24. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +14 -4
  25. package/dist/create/server-source/crates/feltdb-server/src/backup.rs +0 -4
  26. package/dist/create/server-source/crates/feltdb-server/src/canonical_principals.rs +1093 -0
  27. package/dist/create/server-source/crates/feltdb-server/src/causal.rs +905 -144
  28. package/dist/create/server-source/crates/feltdb-server/src/connections.rs +9 -6
  29. package/dist/create/server-source/crates/feltdb-server/src/control_plane.rs +90 -0
  30. package/dist/create/server-source/crates/feltdb-server/src/lib.rs +1 -0
  31. package/dist/create/server-source/crates/feltdb-server/src/main.rs +443 -77
  32. package/dist/create/server-source/crates/feltdb-server/src/principals.rs +9 -501
  33. package/dist/create/server-source/crates/feltdb-server/src/tenancy.rs +22 -0
  34. package/dist/create/server-source/crates/feltdb-server/tests/principal_tenant_migration.rs +247 -0
  35. package/dist/db.d.ts +14 -7
  36. package/dist/db.d.ts.map +1 -1
  37. package/dist/db.js +50 -26
  38. package/dist/deployment.d.ts +2 -0
  39. package/dist/deployment.d.ts.map +1 -1
  40. package/dist/deployment.js +4 -2
  41. package/dist/embedded-transaction.d.ts.map +1 -1
  42. package/dist/embedded-transaction.js +4 -0
  43. package/dist/error-codes.d.ts +12 -0
  44. package/dist/error-codes.d.ts.map +1 -1
  45. package/dist/error-codes.js +20 -2
  46. package/dist/feltdb.d.ts +4 -0
  47. package/dist/feltdb.d.ts.map +1 -1
  48. package/dist/file-db.d.ts +10 -0
  49. package/dist/file-db.d.ts.map +1 -1
  50. package/dist/file-db.js +18 -0
  51. package/dist/http-db.d.ts +7 -0
  52. package/dist/http-db.d.ts.map +1 -1
  53. package/dist/http-db.js +83 -15
  54. package/dist/index-core.d.ts +1 -0
  55. package/dist/index-core.d.ts.map +1 -1
  56. package/dist/index-core.js +1 -0
  57. package/dist/operation-admission.d.ts +2 -0
  58. package/dist/operation-admission.d.ts.map +1 -1
  59. package/dist/public-contract.d.ts +112 -0
  60. package/dist/public-contract.d.ts.map +1 -0
  61. package/dist/public-contract.js +125 -0
  62. package/dist/studio/app.d.ts +23 -0
  63. package/dist/studio/app.d.ts.map +1 -1
  64. package/dist/studio/components/ContractInspector.d.ts +5 -0
  65. package/dist/studio/components/ContractInspector.d.ts.map +1 -1
  66. package/dist/studio/components/SettingsPanel.d.ts +4 -1
  67. package/dist/studio/components/SettingsPanel.d.ts.map +1 -1
  68. package/dist/studio/components/index.js +4 -4
  69. package/dist/studio/{components-CehkcX_k.js → components-CJFgdKG6.js} +322 -303
  70. package/dist/studio/control-plane/Data.d.ts.map +1 -1
  71. package/dist/studio/control-plane/Instance.d.ts +10 -0
  72. package/dist/studio/control-plane/Instance.d.ts.map +1 -1
  73. package/dist/studio/control-plane/Operations.d.ts +3 -0
  74. package/dist/studio/control-plane/Operations.d.ts.map +1 -1
  75. package/dist/studio/control-plane/State.d.ts.map +1 -1
  76. package/dist/studio/control-plane/index.d.ts +4 -2
  77. package/dist/studio/control-plane/index.d.ts.map +1 -1
  78. package/dist/studio/control-plane/index.js +2 -2
  79. package/dist/studio/control-plane-DP8ljTDO.js +3207 -0
  80. package/dist/studio/index.js +96 -75
  81. package/dist/studio/utils/api.d.ts +1 -1
  82. package/dist/studio/utils/api.d.ts.map +1 -1
  83. package/dist/studio/utils/control-plane-api.d.ts +12 -1
  84. package/dist/studio/utils/control-plane-api.d.ts.map +1 -1
  85. package/dist/studio/utils/control-plane-api.js +1 -1
  86. package/dist/studio/utils/index.js +16 -16
  87. package/dist/studio/utils/service-api.d.ts +8 -0
  88. package/dist/studio/utils/service-api.d.ts.map +1 -1
  89. package/dist/studio/utils/service-api.js +15 -12
  90. package/dist/studio-app/assets/{feltdb_wasm-DksXDnLa.js → feltdb_wasm-CfNb3IoF.js} +1 -1
  91. package/dist/studio-app/assets/feltdb_wasm_bg-D9d3gY-E.wasm +0 -0
  92. package/dist/studio-app/assets/index-SDXdROi1.js +30 -0
  93. package/dist/studio-app/feltdb-studio.json +6 -0
  94. package/dist/studio-app/index.html +1 -1
  95. package/dist/transaction.d.ts +9 -1
  96. package/dist/transaction.d.ts.map +1 -1
  97. package/dist/transaction.js +6 -2
  98. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  99. package/dist/workspace/local-development-authority.d.ts +8 -0
  100. package/dist/workspace/local-development-authority.d.ts.map +1 -1
  101. package/dist/workspace/local-development-authority.js +136 -1
  102. package/package.json +2 -2
  103. package/dist/studio/control-plane-D6TT2fCQ.js +0 -3064
  104. package/dist/studio-app/assets/feltdb_wasm_bg-Yy4QRHJT.wasm +0 -0
  105. package/dist/studio-app/assets/index-CjELc-ul.js +0 -30
@@ -0,0 +1,6 @@
1
+ {
2
+ "contract": "feltdb.studio.app.v1",
3
+ "source": "@feltdb/studio",
4
+ "version": "0.8.0",
5
+ "entrypoint": "src/main.tsx"
6
+ }
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#17211b"/><title>FeltDB Studio</title> <script type="module" crossorigin src="/assets/index-CjELc-ul.js"></script>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#17211b"/><title>FeltDB Studio</title> <script type="module" crossorigin src="/assets/index-SDXdROi1.js"></script>
2
2
  <link rel="stylesheet" crossorigin href="/assets/index-BrsF-kWL.css">
3
3
  </head><body><div id="root"></div></body></html>
@@ -123,6 +123,12 @@ export interface AtomicTransactionResult {
123
123
  operations: number;
124
124
  stateBefore: number;
125
125
  stateAfter: number;
126
+ /** Authority revision before and after this atomic commit. */
127
+ baseRevision: number;
128
+ commitRevision: number;
129
+ /** Stable revision and operation identities; never aliases of transactionId. */
130
+ revisionId: string;
131
+ operationIds: string[];
126
132
  }
127
133
  /** Staging surface for one collection inside a transaction. */
128
134
  export interface AtomicTransactionCollection<T = unknown> {
@@ -167,7 +173,9 @@ export interface AtomicTransactionOptions {
167
173
  /** Thrown when a transaction cannot be committed. Nothing was applied. */
168
174
  export declare class AtomicTransactionError extends Error {
169
175
  readonly transactionId: string;
170
- constructor(message: string, transactionId: string);
176
+ readonly code?: string;
177
+ readonly status?: number;
178
+ constructor(message: string, transactionId: string, code?: string, status?: number, cause?: unknown);
171
179
  }
172
180
  /** Which predicate failed, and what the authority actually holds. */
173
181
  export interface ConditionalConflictDetail {
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,yDAAyD;AACzD,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,0DAA0D;AAC1D,MAAM,WAAW,iCAAiC;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,iFAAiF;IACjF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;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M;IAIlC,IAAI,UAAU,IAAI,SAAS,iCAAiC,EAAE,CAE7D;IAED,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,2BAA2B,CAAC,CAAC,CAAC;IAgErE,IAAI,aAAa,IAAI,SAAS,6BAA6B,EAAE,CAE5D;IAED,OAAO,CAAC,SAAS,EAAE,6BAA6B,GAAG,sBAAsB;IAuBzE,0DAA0D;IAC1D,IAAI,IAAI,wBAAwB;CAQjC"}
@@ -25,10 +25,14 @@
25
25
  /** Thrown when a transaction cannot be committed. Nothing was applied. */
26
26
  export class AtomicTransactionError extends Error {
27
27
  transactionId;
28
- constructor(message, transactionId) {
29
- super(message);
28
+ code;
29
+ status;
30
+ constructor(message, transactionId, code, status, cause) {
31
+ super(message, { cause });
30
32
  this.name = 'AtomicTransactionError';
31
33
  this.transactionId = transactionId;
34
+ this.code = code;
35
+ this.status = status;
32
36
  }
33
37
  }
34
38
  /**
Binary file
@@ -11,6 +11,14 @@ export interface LocalDevelopmentAuthorityOptions {
11
11
  port?: number;
12
12
  proposalContext?: () => Promise<ProposalContext>;
13
13
  intentObservations?: () => ObservedEvidenceInput[] | Promise<ObservedEvidenceInput[]>;
14
+ runtimeContext?: {
15
+ namespace: string;
16
+ runtime: string;
17
+ storage: string;
18
+ distributed: boolean;
19
+ applicationLifecycle: string;
20
+ applicationUrl?: string;
21
+ };
14
22
  }
15
23
  /** Start the durable, unauthenticated loopback authority used by `feltdb dev`. */
16
24
  export declare function startLocalDevelopmentAuthority(options: LocalDevelopmentAuthorityOptions): Promise<LocalDevelopmentAuthority>;
@@ -1 +1 @@
1
- {"version":3,"file":"local-development-authority.d.ts","sourceRoot":"","sources":["../../src/workspace/local-development-authority.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwD,KAAK,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AAEhI,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACjD,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,EAAE,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;CACvF;AAED,kFAAkF;AAClF,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,yBAAyB,CAAC,CA6JpC"}
1
+ {"version":3,"file":"local-development-authority.d.ts","sourceRoot":"","sources":["../../src/workspace/local-development-authority.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwD,KAAK,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AAEhI,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IACjD,kBAAkB,CAAC,EAAE,MAAM,qBAAqB,EAAE,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;IACtF,cAAc,CAAC,EAAE;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAeD,kFAAkF;AAClF,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,yBAAyB,CAAC,CA6QpC"}
@@ -3,6 +3,18 @@ import path from 'node:path';
3
3
  import { FileJsDb } from '../file-db.js';
4
4
  import { FELTDB_CONVERGENCE_COLLECTION, FeltDBProposalService } from '../proposal.js';
5
5
  import { IntentService } from '../intent.js';
6
+ const DEVELOPMENT_CONTROL_PLANE_CAPABILITIES = {
7
+ contract: 'feltdb.control-plane.capabilities',
8
+ version: 1,
9
+ capabilities: [
10
+ { id: 'overview.instance', area: 'overview', title: 'Development authority overview', status: 'available', surface: ['GET /v1/control-plane/overview'], note: '' },
11
+ { id: 'data.collections.list', area: 'data', title: 'List declared collections', status: 'available', surface: ['GET /v1/application/schema'], note: '' },
12
+ { id: 'data.schema.inspect', area: 'data', title: 'Inspect the application schema', status: 'available', surface: ['GET /v1/application/schema'], note: '' },
13
+ { id: 'data.records.browse', area: 'data', title: 'Browse records', status: 'available', surface: ['GET /v1/data/{collection}'], note: '' },
14
+ { id: 'provenance.transactions', area: 'operations', title: 'Recent attributed transactions', status: 'unsupported', surface: [], note: 'Transaction observability is not available from the lightweight development authority.' },
15
+ { id: 'replication.health', area: 'replication', title: 'Replication health', status: 'unsupported', surface: [], note: 'Replication health is not available from the lightweight development authority.' },
16
+ ],
17
+ };
6
18
  /** Start the durable, unauthenticated loopback authority used by `feltdb dev`. */
7
19
  export async function startLocalDevelopmentAuthority(options) {
8
20
  const host = options.host || '127.0.0.1';
@@ -25,6 +37,7 @@ export async function startLocalDevelopmentAuthority(options) {
25
37
  const proposalService = options.proposalContext ? new FeltDBProposalService(store, options.proposalContext, proposalAuthorityToken) : undefined;
26
38
  const intentService = proposalService && options.proposalContext ? new IntentService(store, options.proposalContext, proposalService, options.intentObservations) : undefined;
27
39
  const streams = new Set();
40
+ let endpoint = '';
28
41
  const server = http.createServer(async (request, response) => {
29
42
  try {
30
43
  response.setHeader('Access-Control-Allow-Origin', '*');
@@ -54,6 +67,124 @@ export async function startLocalDevelopmentAuthority(options) {
54
67
  request.once('close', () => streams.delete(response));
55
68
  return;
56
69
  }
70
+ if (request.method === 'GET' && pathname === '/v1/application/schema') {
71
+ if (!options.proposalContext) {
72
+ json(response, 503, { code: 'application_contract_unavailable', message: 'The development application contract is unavailable.' });
73
+ return;
74
+ }
75
+ const { snapshot } = await options.proposalContext();
76
+ const collections = snapshot.schema.map(collection => {
77
+ const direct = collection.fields.flatMap(field => field.reference ? [{
78
+ name: field.name,
79
+ source_collection: collection.name,
80
+ target_collection: field.reference,
81
+ cardinality: 'one',
82
+ foreign_field: field.name,
83
+ }] : []);
84
+ const reverse = snapshot.schema.flatMap(source => source.fields.flatMap(field => field.reference === collection.name ? [{
85
+ name: `${source.name}_${field.name}`,
86
+ source_collection: source.name,
87
+ target_collection: collection.name,
88
+ cardinality: 'many',
89
+ foreign_field: field.name,
90
+ }] : []));
91
+ return { collection: collection.name, description: '', fields: collection.fields, relationships: [...direct, ...reverse] };
92
+ });
93
+ json(response, 200, {
94
+ application: snapshot.application,
95
+ contract_version: snapshot.contract_version,
96
+ collections,
97
+ capabilities: snapshot.capabilities,
98
+ workflows: snapshot.workflows,
99
+ agents: snapshot.agents,
100
+ policies: snapshot.policies,
101
+ });
102
+ return;
103
+ }
104
+ if (request.method === 'GET' && pathname === '/v1/control-plane/capabilities') {
105
+ json(response, 200, DEVELOPMENT_CONTROL_PLANE_CAPABILITIES);
106
+ return;
107
+ }
108
+ if (request.method === 'GET' && pathname === '/v1/control-plane/overview') {
109
+ const context = options.runtimeContext;
110
+ const authorityState = db.authorityStateSummary();
111
+ json(response, 200, {
112
+ instance: {
113
+ instance_id: db.instance_id(),
114
+ namespace: context?.namespace ?? 'default',
115
+ runtime: context?.runtime ?? 'node',
116
+ storage: context?.storage ?? 'durable',
117
+ distributed: context?.distributed ?? false,
118
+ application_lifecycle: context?.applicationLifecycle ?? 'attached',
119
+ application_url: context?.applicationUrl ?? null,
120
+ },
121
+ authority: {
122
+ kind: 'local-development',
123
+ advertise_url: endpoint,
124
+ state_version: authorityState.current_sequence,
125
+ },
126
+ authority_state: authorityState,
127
+ storage: {
128
+ records: authorityState.records,
129
+ collections: authorityState.collections,
130
+ },
131
+ });
132
+ return;
133
+ }
134
+ const dataMatch = pathname.match(/^\/v1\/data\/([^/]+)$/);
135
+ if (request.method === 'GET' && dataMatch) {
136
+ if (!options.proposalContext) {
137
+ json(response, 503, { code: 'application_contract_unavailable', message: 'The development application contract is unavailable.' });
138
+ return;
139
+ }
140
+ const { snapshot } = await options.proposalContext();
141
+ const collection = decodeURIComponent(dataMatch[1]);
142
+ if (!snapshot.schema.some(value => value.name === collection)) {
143
+ json(response, 404, { code: 'collection_not_found', message: `Collection ${collection} is not declared by this application.` });
144
+ return;
145
+ }
146
+ const requestedLimit = Number(requestUrl.searchParams.get('limit') || 50);
147
+ if (!Number.isInteger(requestedLimit) || requestedLimit < 1) {
148
+ json(response, 422, { code: 'invalid_limit', message: 'limit must be a positive integer.' });
149
+ return;
150
+ }
151
+ const limit = Math.min(requestedLimit, 100);
152
+ const stateVersion = db.get_sequence();
153
+ let offset = 0;
154
+ const cursor = requestUrl.searchParams.get('cursor');
155
+ if (cursor) {
156
+ try {
157
+ const decoded = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
158
+ if (decoded.v !== 1 || decoded.collection !== collection || decoded.state !== stateVersion
159
+ || !Number.isInteger(decoded.offset) || (decoded.offset ?? -1) < 0)
160
+ throw new Error('invalid cursor');
161
+ offset = decoded.offset;
162
+ }
163
+ catch {
164
+ json(response, 422, { code: 'invalid_cursor', message: 'The cursor is invalid, stale, or belongs to another collection.' });
165
+ return;
166
+ }
167
+ }
168
+ const result = db.query(collection);
169
+ if (!result.success) {
170
+ json(response, 500, { code: 'authority_read_failed', message: result.error });
171
+ return;
172
+ }
173
+ const records = JSON.parse(result.data || '[]')
174
+ .sort((left, right) => String(left.id ?? JSON.stringify(left)).localeCompare(String(right.id ?? JSON.stringify(right))));
175
+ const page = records.slice(offset, offset + limit);
176
+ const nextOffset = offset + page.length;
177
+ const nextCursor = nextOffset < records.length
178
+ ? Buffer.from(JSON.stringify({ v: 1, collection, state: stateVersion, offset: nextOffset })).toString('base64url')
179
+ : null;
180
+ json(response, 200, {
181
+ collection,
182
+ records: page,
183
+ pagination: { limit, nextCursor },
184
+ state_version: stateVersion,
185
+ });
186
+ return;
187
+ }
57
188
  const previewSimulationMatch = pathname.match(/^\/v1\/previews\/([^/]+)\/simulate$/);
58
189
  if (previewSimulationMatch) {
59
190
  if (!proposalService) {
@@ -290,8 +421,12 @@ export async function startLocalDevelopmentAuthority(options) {
290
421
  server.once('error', reject);
291
422
  server.listen(port, host, resolve);
292
423
  });
424
+ const address = server.address();
425
+ if (!address || typeof address === 'string')
426
+ throw new Error('Development authority did not expose a TCP address');
427
+ endpoint = `http://${host}:${address.port}`;
293
428
  return {
294
- endpoint: `http://${host}:${port}`,
429
+ endpoint,
295
430
  proposalAuthorityToken,
296
431
  close: () => new Promise((resolve, reject) => {
297
432
  for (const stream of streams)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feltdb/core",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "FeltDB Core - Application-facing database with Browser, Local, and Server runtimes. Durable state, reactive APIs.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -63,7 +63,7 @@
63
63
  "scripts": {
64
64
  "build": "rm -rf dist && tsc && node ../../tools/stage-core-wasm.mjs && npm run build --workspace @feltdb/react && npm run build --workspace @feltdb/migration-sherpa && npm run build --workspace @feltdb/studio && npm run build --workspace @feltdb/cli && npm run build --workspace create-feltdb && node ../../tools/assemble-core-sdk.mjs",
65
65
  "test": "node ../../test-runner.ts",
66
- "test:workspace-e2e": "node --test test/workspace-connection.e2e.test.mjs",
66
+ "test:workspace-e2e": "node --test test/workspace-connection.e2e.test.mjs test/local-development-authority-read-contract.test.mjs",
67
67
  "type-check": "tsc --noEmit"
68
68
  },
69
69
  "keywords": [