@impetik/xeer-mcp 0.2.5 → 0.2.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.
Files changed (54) hide show
  1. package/README.md +4 -1
  2. package/dist/dev-session.d.ts +1 -1
  3. package/dist/network-policy.js +1 -1
  4. package/dist/server.d.ts +1 -1
  5. package/dist/server.js +4 -4
  6. package/dist/test-run.d.ts +1 -1
  7. package/dist/xeer-cli.d.ts +1 -1
  8. package/package.json +8 -5
  9. package/vendor/spec/actions.d.ts +1250 -0
  10. package/vendor/spec/actions.js +805 -0
  11. package/vendor/spec/admin-sql.d.ts +59 -0
  12. package/vendor/spec/admin-sql.js +147 -0
  13. package/vendor/spec/admin.d.ts +110 -0
  14. package/vendor/spec/admin.js +58 -0
  15. package/vendor/spec/canonical.d.ts +3 -0
  16. package/vendor/spec/canonical.js +36 -0
  17. package/vendor/spec/diagnostics.d.ts +49 -0
  18. package/vendor/spec/diagnostics.js +500 -0
  19. package/vendor/spec/docs.d.ts +21 -0
  20. package/vendor/spec/docs.js +57 -0
  21. package/vendor/spec/events.d.ts +8 -0
  22. package/vendor/spec/events.js +21 -0
  23. package/vendor/spec/identity-keys.d.ts +36 -0
  24. package/vendor/spec/identity-keys.js +72 -0
  25. package/vendor/spec/index.d.ts +20 -0
  26. package/vendor/spec/index.js +20 -0
  27. package/vendor/spec/local-identity.d.ts +69 -0
  28. package/vendor/spec/local-identity.js +132 -0
  29. package/vendor/spec/network-policy.d.ts +16 -0
  30. package/vendor/spec/network-policy.js +50 -0
  31. package/vendor/spec/public-assets.d.ts +153 -0
  32. package/vendor/spec/public-assets.js +166 -0
  33. package/vendor/spec/review.d.ts +120 -0
  34. package/vendor/spec/review.js +226 -0
  35. package/vendor/spec/route.d.ts +43 -0
  36. package/vendor/spec/route.js +87 -0
  37. package/vendor/spec/schema-lifecycle.d.ts +27 -0
  38. package/vendor/spec/schema-lifecycle.js +146 -0
  39. package/vendor/spec/schema-plan.d.ts +98 -0
  40. package/vendor/spec/schema-plan.js +194 -0
  41. package/vendor/spec/schema.d.ts +166 -0
  42. package/vendor/spec/schema.js +409 -0
  43. package/vendor/spec/sql-expression.d.ts +91 -0
  44. package/vendor/spec/sql-expression.js +650 -0
  45. package/vendor/spec/state-export.d.ts +143 -0
  46. package/vendor/spec/state-export.js +341 -0
  47. package/vendor/spec/storage.d.ts +61 -0
  48. package/vendor/spec/storage.js +120 -0
  49. package/vendor/spec/table-ddl.d.ts +162 -0
  50. package/vendor/spec/table-ddl.js +508 -0
  51. package/vendor/spec/types.d.ts +275 -0
  52. package/vendor/spec/types.js +11 -0
  53. package/vendor/spec/value.d.ts +22 -0
  54. package/vendor/spec/value.js +72 -0
@@ -0,0 +1,275 @@
1
+ import type { PublicAssetsV0 } from './public-assets.js';
2
+ export declare const SOURCE_FORMAT: "xeer.application-source.v0";
3
+ export declare const ARTIFACT_FORMAT: "xeer.application.v0";
4
+ export declare const DEV_PROTOCOL: "xeer.dev.v0";
5
+ export declare const INSPECT_PROTOCOL: "xeer.inspect.v0";
6
+ export type DiagnosticSeverity = 'error' | 'warning' | 'info';
7
+ export interface SourceSpan {
8
+ line: number;
9
+ column: number;
10
+ length?: number;
11
+ }
12
+ export interface Diagnostic {
13
+ code: string;
14
+ severity: DiagnosticSeverity;
15
+ message: string;
16
+ file?: string;
17
+ span?: SourceSpan;
18
+ hint?: string;
19
+ }
20
+ /**
21
+ * `ref` is a scalar in the only sense that matters here: it is one TEXT column holding one row id.
22
+ * What distinguishes it is that the column carries a FOREIGN KEY to the declared table it names, so
23
+ * the database — not the application — is what keeps the pointer honest.
24
+ */
25
+ export type ScalarType = 'string' | 'number' | 'boolean' | 'datetime' | 'bytes' | 'json' | 'ref';
26
+ /** SQLite's three built-in collating sequences; there are no others to declare. */
27
+ export type CollationName = 'binary' | 'nocase' | 'rtrim';
28
+ /** SQLite's five referential actions, spelled the way the rest of the manifest spells things. */
29
+ export type ReferentialAction = 'noAction' | 'restrict' | 'cascade' | 'setNull' | 'setDefault';
30
+ /**
31
+ * A field's default, in the JavaScript type its field type is written in: a `boolean` field defaults
32
+ * to `true`, a `number` to a number, and every text-shaped type to a string. A `bytes` default is
33
+ * lowercase hex, which is the only unambiguous way to spell a byte sequence in JSON.
34
+ */
35
+ export type FieldDefaultValue = string | number | boolean;
36
+ export interface GeneratedColumnDefinition {
37
+ /** A SQL expression over this table's other columns. See `sql-expression.ts` for what may appear. */
38
+ expression: string;
39
+ /** `true` writes the value to disk; the default recomputes it on read. */
40
+ stored?: boolean;
41
+ }
42
+ export interface FieldDefinition {
43
+ type: ScalarType;
44
+ optional?: boolean;
45
+ maxLength?: number;
46
+ /** A single-column UNIQUE. Optional columns may still repeat NULL, as SQL defines UNIQUE. */
47
+ unique?: boolean;
48
+ /** Permitted values for a string field, enforced as a membership CHECK. */
49
+ enum?: string[];
50
+ default?: FieldDefaultValue;
51
+ collate?: CollationName;
52
+ /** `ref` only: the declared table whose `id` this column points at. */
53
+ table?: string;
54
+ /** `ref` only. Absent means SQLite's default, NO ACTION. */
55
+ onDelete?: ReferentialAction;
56
+ onUpdate?: ReferentialAction;
57
+ /** Makes the column computed. A generated column may not also carry a default. */
58
+ generated?: GeneratedColumnDefinition;
59
+ }
60
+ /** One member of an index: a column, a column with options, or an expression to index. */
61
+ export type IndexTermDefinition = string | {
62
+ column: string;
63
+ collate?: CollationName;
64
+ desc?: boolean;
65
+ } | {
66
+ expression: string;
67
+ desc?: boolean;
68
+ };
69
+ export interface IndexDefinition {
70
+ columns: IndexTermDefinition[];
71
+ unique?: boolean;
72
+ /**
73
+ * A partial index's predicate: the index then covers only the rows it matches.
74
+ *
75
+ * Note for anything that writes through one: an upsert targeting a *unique* partial index has to
76
+ * repeat the predicate — `ON CONFLICT ("slug") WHERE "deletedAt" IS NULL DO UPDATE …` — or SQLite
77
+ * answers "ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint". The predicate
78
+ * is part of the constraint's identity, not a detail of it.
79
+ */
80
+ where?: string;
81
+ }
82
+ /**
83
+ * An index is either a bare list of column names or the full form. The shorthand is not legacy: an
84
+ * index over two ascending columns is most of them, and `["status", "position"]` says that better
85
+ * than the object it normalizes to.
86
+ */
87
+ export type TableIndexDefinition = string[] | IndexDefinition;
88
+ export interface TableDefinition {
89
+ fields: Record<string, FieldDefinition>;
90
+ indexes?: Record<string, TableIndexDefinition>;
91
+ /** Composite UNIQUE constraints, each a tuple of declared field names. */
92
+ unique?: string[][];
93
+ /** Table-level CHECK expressions by name. The name is what SQLite reports when one fails. */
94
+ checks?: Record<string, string>;
95
+ }
96
+ /**
97
+ * The capabilities an application may declare. A capability name in `capabilities[]` and its config
98
+ * block are one declaration in two halves: either both are present or neither is, checked in both
99
+ * directions by the schema. `database` has worked this way since v0; `storage` is the first
100
+ * Cloudflare-primitive-backed capability to follow it (#29, design in #51).
101
+ */
102
+ export declare const CAPABILITIES: readonly ["database", "storage"];
103
+ export type Capability = (typeof CAPABILITIES)[number];
104
+ /**
105
+ * The `storage` capability's declared limits. Every field is optional and normalized to a default,
106
+ * and every one is a *logical* limit — a byte count the runtime enforces at call time. Nothing here
107
+ * names a bucket, a region, or an account: the provisioned resource's identity is deployment state
108
+ * owned by the control plane and is deliberately absent from the manifest and the artifact (#51 §7).
109
+ */
110
+ export interface StorageConfigV0 {
111
+ /** Largest single stored object, capped at `STORAGE_MAX_OBJECT_BYTES`. */
112
+ maxObjectBytes?: number;
113
+ /** Bytes one handler may read out of storage, capped at `STORAGE_MAX_READ_BYTES`. */
114
+ readBytes?: number;
115
+ /** Bytes one handler may write into storage, capped at `STORAGE_MAX_WRITE_BYTES`. */
116
+ writeBytes?: number;
117
+ }
118
+ export interface NormalizedStorageConfigV0 {
119
+ maxObjectBytes: number;
120
+ readBytes: number;
121
+ writeBytes: number;
122
+ }
123
+ export interface ApplicationManifestV0 {
124
+ $schema?: string;
125
+ format: typeof SOURCE_FORMAT;
126
+ name: string;
127
+ entrypoints: {
128
+ client: string;
129
+ server: string;
130
+ };
131
+ app?: {
132
+ spa?: boolean;
133
+ title?: string;
134
+ language?: string;
135
+ description?: string;
136
+ favicon?: string;
137
+ };
138
+ database?: {
139
+ version?: number;
140
+ tables: Record<string, TableDefinition>;
141
+ };
142
+ storage?: StorageConfigV0;
143
+ capabilities?: Capability[];
144
+ budgets?: {
145
+ queryRows?: number;
146
+ mutationWrites?: number;
147
+ requestBytes?: number;
148
+ responseBytes?: number;
149
+ /**
150
+ * Simultaneous server-push invalidation streams the application's state object will hold.
151
+ * `0` disables server push for the application: the client never opens `/__xeer/events` and the
152
+ * runtime answers a terminal `live_disabled` without waking the state object.
153
+ */
154
+ liveConnections?: number;
155
+ };
156
+ }
157
+ export interface NormalizedApplicationManifestV0 {
158
+ format: typeof SOURCE_FORMAT;
159
+ name: string;
160
+ entrypoints: ApplicationManifestV0['entrypoints'];
161
+ app: {
162
+ spa: boolean;
163
+ title: string;
164
+ language: string;
165
+ description: string;
166
+ favicon: string | null;
167
+ };
168
+ database: {
169
+ version: number;
170
+ tables: Record<string, TableDefinition>;
171
+ };
172
+ /**
173
+ * The normalized `storage` block, or `null` when the capability is not declared. Null rather than a
174
+ * zeroed record, because "this application has no storage" and "this application has storage with
175
+ * a limit of nothing" are different statements and only the first one is ever true.
176
+ */
177
+ storage: NormalizedStorageConfigV0 | null;
178
+ capabilities: Capability[];
179
+ budgets: {
180
+ queryRows: number;
181
+ mutationWrites: number;
182
+ requestBytes: number;
183
+ responseBytes: number;
184
+ /** `0` means server push is off for this application; see {@link ApplicationManifestV0}. */
185
+ liveConnections: number;
186
+ };
187
+ }
188
+ export interface SourceReceipt {
189
+ path: string;
190
+ size: number;
191
+ hash: `sha256:${string}`;
192
+ }
193
+ export interface ApplicationSchemaIdentityV0 {
194
+ applicationSchemaVersion: number;
195
+ schemaHash: `sha256:${string}`;
196
+ }
197
+ export interface ApplicationArtifactV0 {
198
+ format: typeof ARTIFACT_FORMAT;
199
+ artifactId: `sha256:${string}`;
200
+ compiler: {
201
+ name: '@impetik/xeer';
202
+ version: string;
203
+ };
204
+ application: {
205
+ name: string;
206
+ sourceFormat: typeof SOURCE_FORMAT;
207
+ app: NormalizedApplicationManifestV0['app'];
208
+ };
209
+ runtime: {
210
+ family: 'workerd';
211
+ compatibilityDate: string;
212
+ compatibilityFlags: string[];
213
+ };
214
+ capabilities: NormalizedApplicationManifestV0['capabilities'];
215
+ /**
216
+ * The normalized `storage` limits, present only when the capability is declared.
217
+ *
218
+ * Present-only-when-declared rather than `storage: null`, so an application that does not use the
219
+ * capability produces byte-identical artifact bytes — and therefore the same `artifactId` — as it
220
+ * did before the capability existed. What is deliberately *not* here is the provisioned bucket's
221
+ * name: it is derived from `(appId, environment)` by the control plane at deploy time, so the same
222
+ * artifact binds different buckets in preview and production, which is correct (#51 §7).
223
+ */
224
+ storage?: NormalizedStorageConfigV0;
225
+ budgets: NormalizedApplicationManifestV0['budgets'];
226
+ schema: NormalizedApplicationManifestV0['database'];
227
+ schemaIdentity: ApplicationSchemaIdentityV0;
228
+ operations: {
229
+ queries: Array<{
230
+ name: string;
231
+ }>;
232
+ mutations: Array<{
233
+ name: string;
234
+ }>;
235
+ endpoints: Array<{
236
+ method: string;
237
+ path: string;
238
+ }>;
239
+ };
240
+ modules: Array<{
241
+ path: string;
242
+ size: number;
243
+ hash: `sha256:${string}`;
244
+ sourceMap?: {
245
+ format: 'source-map.v3';
246
+ size: number;
247
+ hash: `sha256:${string}`;
248
+ };
249
+ }>;
250
+ assets: Array<{
251
+ path: string;
252
+ contentType: string;
253
+ size: number;
254
+ hash: `sha256:${string}`;
255
+ }>;
256
+ /**
257
+ * Which of the paths in `assets` are content addresses and which are stable contracts — the only
258
+ * sanctioned basis for deciding what may be cached and for how long. It is part of the artifact
259
+ * rather than something the CLI derives at deploy time because the document is generated
260
+ * downstream by a CLI whose version is not pinned to this build: two CLI versions hashing
261
+ * independently could name different URLs for identical bytes, and the hashed URL has to be a
262
+ * property of the bytes alone. Being here also makes it covered by `artifactId`.
263
+ */
264
+ publicAssets: PublicAssetsV0;
265
+ source: {
266
+ files: SourceReceipt[];
267
+ };
268
+ }
269
+ export interface DevEvent<T = unknown> {
270
+ protocol: typeof DEV_PROTOCOL;
271
+ seq: number;
272
+ time: string;
273
+ type: string;
274
+ data: T;
275
+ }
@@ -0,0 +1,11 @@
1
+ export const SOURCE_FORMAT = 'xeer.application-source.v0';
2
+ export const ARTIFACT_FORMAT = 'xeer.application.v0';
3
+ export const DEV_PROTOCOL = 'xeer.dev.v0';
4
+ export const INSPECT_PROTOCOL = 'xeer.inspect.v0';
5
+ /**
6
+ * The capabilities an application may declare. A capability name in `capabilities[]` and its config
7
+ * block are one declaration in two halves: either both are present or neither is, checked in both
8
+ * directions by the schema. `database` has worked this way since v0; `storage` is the first
9
+ * Cloudflare-primitive-backed capability to follow it (#29, design in #51).
10
+ */
11
+ export const CAPABILITIES = Object.freeze(['database', 'storage']);
@@ -0,0 +1,22 @@
1
+ export type RuntimeValue = null | boolean | number | string | Date | Uint8Array | undefined | RuntimeValue[] | {
2
+ [key: string]: RuntimeValue;
3
+ };
4
+ export type EncodedValue = null | boolean | number | string | {
5
+ $xeer: 'undefined';
6
+ } | {
7
+ $xeer: 'date';
8
+ value: string;
9
+ } | {
10
+ $xeer: 'bytes';
11
+ value: string;
12
+ } | {
13
+ $xeer: 'array';
14
+ value: EncodedValue[];
15
+ } | {
16
+ $xeer: 'object';
17
+ value: Record<string, EncodedValue>;
18
+ };
19
+ export declare function encodeValue(value: RuntimeValue): EncodedValue;
20
+ export declare function decodeValue(value: EncodedValue): RuntimeValue;
21
+ export declare function stringifyValue(value: RuntimeValue): string;
22
+ export declare function parseValue(value: string): RuntimeValue;
@@ -0,0 +1,72 @@
1
+ function bytesToBase64(bytes) {
2
+ let binary = '';
3
+ const chunk = 0x8000;
4
+ for (let offset = 0; offset < bytes.length; offset += chunk) {
5
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + chunk));
6
+ }
7
+ return btoa(binary);
8
+ }
9
+ function base64ToBytes(value) {
10
+ const binary = atob(value);
11
+ const bytes = new Uint8Array(binary.length);
12
+ for (let index = 0; index < binary.length; index += 1)
13
+ bytes[index] = binary.charCodeAt(index);
14
+ return bytes;
15
+ }
16
+ export function encodeValue(value) {
17
+ const ancestors = new Set();
18
+ const encode = (current) => {
19
+ if (current === null || typeof current === 'string' || typeof current === 'boolean')
20
+ return current;
21
+ if (typeof current === 'number') {
22
+ if (!Number.isFinite(current))
23
+ throw new TypeError('Xeer values cannot contain non-finite numbers.');
24
+ return Object.is(current, -0) ? 0 : current;
25
+ }
26
+ if (current === undefined)
27
+ return { $xeer: 'undefined' };
28
+ if (current instanceof Date) {
29
+ if (Number.isNaN(current.getTime()))
30
+ throw new TypeError('Xeer values cannot contain an invalid Date.');
31
+ return { $xeer: 'date', value: current.toISOString() };
32
+ }
33
+ if (current instanceof Uint8Array)
34
+ return { $xeer: 'bytes', value: bytesToBase64(current) };
35
+ if (ancestors.has(current))
36
+ throw new TypeError('Xeer values cannot contain cycles.');
37
+ ancestors.add(current);
38
+ try {
39
+ if (Array.isArray(current))
40
+ return { $xeer: 'array', value: current.map(encode) };
41
+ const prototype = Object.getPrototypeOf(current);
42
+ if (prototype !== Object.prototype && prototype !== null) {
43
+ throw new TypeError('Xeer values only support plain objects.');
44
+ }
45
+ const encoded = {};
46
+ for (const key of Object.keys(current).sort())
47
+ encoded[key] = encode(current[key]);
48
+ return { $xeer: 'object', value: encoded };
49
+ }
50
+ finally {
51
+ ancestors.delete(current);
52
+ }
53
+ };
54
+ return encode(value);
55
+ }
56
+ export function decodeValue(value) {
57
+ if (value === null || typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number')
58
+ return value;
59
+ switch (value.$xeer) {
60
+ case 'undefined': return undefined;
61
+ case 'date': return new Date(value.value);
62
+ case 'bytes': return base64ToBytes(value.value);
63
+ case 'array': return value.value.map(decodeValue);
64
+ case 'object': return Object.fromEntries(Object.entries(value.value).map(([key, item]) => [key, decodeValue(item)]));
65
+ }
66
+ }
67
+ export function stringifyValue(value) {
68
+ return JSON.stringify(encodeValue(value));
69
+ }
70
+ export function parseValue(value) {
71
+ return decodeValue(JSON.parse(value));
72
+ }