@antcde/connect-ts 0.4.27-rc.1 → 0.4.27-rc.11
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 +67 -3
- package/build/AntConnect.d.ts +2 -0
- package/build/AntConnect.d.ts.map +1 -1
- package/build/AntConnect.js +2 -0
- package/build/AntHttpClient.d.ts +0 -5
- package/build/AntHttpClient.d.ts.map +1 -1
- package/build/AntHttpClient.js +0 -5
- package/build/ai/index.d.ts +5 -0
- package/build/ai/index.d.ts.map +1 -0
- package/build/ai/index.js +3 -0
- package/build/ai/mutationDescriptors.d.ts +3 -0
- package/build/ai/mutationDescriptors.d.ts.map +1 -0
- package/build/ai/mutationDescriptors.js +207 -0
- package/build/ai/mutationTargets.d.ts +21 -0
- package/build/ai/mutationTargets.d.ts.map +1 -0
- package/build/ai/mutationTargets.js +72 -0
- package/build/ai/queryDescriptors.d.ts +3 -0
- package/build/ai/queryDescriptors.d.ts.map +1 -0
- package/build/ai/queryDescriptors.js +174 -0
- package/build/ai/types.d.ts +35 -0
- package/build/ai/types.d.ts.map +1 -0
- package/build/ai/types.js +1 -0
- package/build/comms/client.d.ts.map +1 -1
- package/build/comms/client.js +39 -41
- package/build/comms/connection.d.ts +32 -0
- package/build/comms/connection.d.ts.map +1 -0
- package/build/comms/connection.js +159 -0
- package/build/comms/handshake.d.ts +16 -0
- package/build/comms/handshake.d.ts.map +1 -0
- package/build/comms/handshake.js +73 -0
- package/build/comms/host.d.ts.map +1 -1
- package/build/comms/host.js +22 -26
- package/build/comms/hostAPI.js +1 -1
- package/build/comms/hostSlot.d.ts +23 -0
- package/build/comms/hostSlot.d.ts.map +1 -0
- package/build/comms/hostSlot.js +55 -0
- package/build/comms/models.d.ts +31 -2
- package/build/comms/models.d.ts.map +1 -1
- package/build/comms/signalTypes.d.ts +1 -1
- package/build/comms/signalTypes.d.ts.map +1 -1
- package/build/comms/transport.d.ts +18 -2
- package/build/comms/transport.d.ts.map +1 -1
- package/build/comms/transport.js +25 -10
- package/build/index.d.ts +4 -2
- package/build/index.d.ts.map +1 -1
- package/build/service-runtime.d.ts +4 -1
- package/build/service-runtime.d.ts.map +1 -1
- package/build/service-runtime.js +4 -1
- package/build/service-types-app.d.ts +1 -1
- package/build/service-types-app.d.ts.map +1 -1
- package/build/service-types.d.ts +2 -1
- package/build/service-types.d.ts.map +1 -1
- package/build/services/AiService.d.ts +18 -0
- package/build/services/AiService.d.ts.map +1 -0
- package/build/services/AiService.js +9 -0
- package/build/services/AppService/factory/categories.d.ts +30 -0
- package/build/services/AppService/factory/categories.d.ts.map +1 -0
- package/build/services/AppService/factory/categories.js +11 -0
- package/build/services/AppService/factory/resourceAccess.d.ts +21 -0
- package/build/services/AppService/factory/resourceAccess.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceAccess.js +49 -0
- package/build/services/AppService/factory/resourceAssignments.d.ts +66 -0
- package/build/services/AppService/factory/resourceAssignments.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceAssignments.js +12 -0
- package/build/services/AppService/factory/resourceChannels.d.ts +89 -0
- package/build/services/AppService/factory/resourceChannels.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceChannels.js +19 -0
- package/build/services/AppService/factory/resourceCommerce.d.ts +52 -0
- package/build/services/AppService/factory/resourceCommerce.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceCommerce.js +18 -0
- package/build/services/AppService/factory/resourceSnapshot.d.ts +75 -0
- package/build/services/AppService/factory/resourceSnapshot.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceSnapshot.js +55 -0
- package/build/services/AppService/factory/resourceUploads.d.ts +37 -0
- package/build/services/AppService/factory/resourceUploads.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceUploads.js +8 -0
- package/build/services/AppService/factory/resources.d.ts +167 -0
- package/build/services/AppService/factory/resources.d.ts.map +1 -0
- package/build/services/AppService/factory/resources.js +45 -0
- package/build/services/AppService/factory/taxonomy.d.ts +25 -0
- package/build/services/AppService/factory/taxonomy.d.ts.map +1 -0
- package/build/services/AppService/factory/taxonomy.js +5 -0
- package/build/services/AppService/index.d.ts +5 -5
- package/build/services/AppService/index.d.ts.map +1 -1
- package/build/services/AppService/index.js +13 -8
- package/build/services/AppService/types/appCategories.d.ts +28 -0
- package/build/services/AppService/types/appCategories.d.ts.map +1 -1
- package/build/services/AppService/types/appList.d.ts +28 -0
- package/build/services/AppService/types/appList.d.ts.map +1 -1
- package/build/services/AppService/types/appManifest.d.ts +46 -0
- package/build/services/AppService/types/appManifest.d.ts.map +1 -1
- package/build/services/AppService/types/appRequests.d.ts +13 -0
- package/build/services/AppService/types/appRequests.d.ts.map +1 -1
- package/build/services/AppService/types/resourceAssignments.d.ts +38 -0
- package/build/services/AppService/types/resourceAssignments.d.ts.map +1 -0
- package/build/services/AppService/types/resourceAssignments.js +10 -0
- package/build/services/AppService/types/resourceEntitlements.d.ts +118 -0
- package/build/services/AppService/types/resourceEntitlements.d.ts.map +1 -0
- package/build/services/AppService/types/resourceEntitlements.js +1 -0
- package/build/services/AppService/types/resourceReleases.d.ts +230 -0
- package/build/services/AppService/types/resourceReleases.d.ts.map +1 -0
- package/build/services/AppService/types/resourceReleases.js +1 -0
- package/build/services/AppService/types/resourceRequests.d.ts +115 -0
- package/build/services/AppService/types/resourceRequests.d.ts.map +1 -0
- package/build/services/AppService/types/resourceRequests.js +1 -0
- package/build/services/AppService/types/sellableResources.d.ts +231 -0
- package/build/services/AppService/types/sellableResources.d.ts.map +1 -0
- package/build/services/AppService/types/sellableResources.js +1 -0
- package/build/services/AppService/types/snapshotFileSource.d.ts +110 -0
- package/build/services/AppService/types/snapshotFileSource.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotFileSource.js +8 -0
- package/build/services/AppService/types/snapshotPayload.d.ts +166 -0
- package/build/services/AppService/types/snapshotPayload.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotPayload.js +19 -0
- package/build/services/AppService/types/snapshotSources.d.ts +116 -0
- package/build/services/AppService/types/snapshotSources.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotSources.js +7 -0
- package/build/services/AppService/types/snapshotUploads.d.ts +109 -0
- package/build/services/AppService/types/snapshotUploads.d.ts.map +1 -0
- package/build/services/AppService/types/snapshotUploads.js +20 -0
- package/build/services/AppService/types/taxonomy.d.ts +76 -0
- package/build/services/AppService/types/taxonomy.d.ts.map +1 -0
- package/build/services/AppService/types/taxonomy.js +1 -0
- package/build/services/AppService/types.d.ts +10 -0
- package/build/services/AppService/types.d.ts.map +1 -1
- package/build/services/AppService/types.js +10 -0
- package/build/services/DmsService.d.ts +2 -160
- package/build/services/DmsService.d.ts.map +1 -1
- package/build/services/DmsService.types.d.ts +169 -0
- package/build/services/DmsService.types.d.ts.map +1 -0
- package/build/services/DmsService.types.js +1 -0
- package/build/services/ProjectService.d.ts +20 -0
- package/build/services/ProjectService.d.ts.map +1 -1
- package/build/services/ProjectService.js +1 -0
- package/build/services/TaskService.requests.d.ts +61 -0
- package/build/services/TaskService.requests.d.ts.map +1 -0
- package/build/services/TaskService.requests.js +1 -0
- package/build/services/TaskService.types.d.ts +2 -51
- package/build/services/TaskService.types.d.ts.map +1 -1
- package/build/services/TokenService.d.ts +0 -1
- package/build/services/TokenService.d.ts.map +1 -1
- package/build/services/TokenService.js +0 -2
- package/build/services/UserService.d.ts +3 -0
- package/build/services/UserService.d.ts.map +1 -1
- package/build/services/Webhook/EventService.d.ts +7 -0
- package/build/services/Webhook/EventService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerService.d.ts +80 -0
- package/build/services/Webhook/TriggerService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerService.js +15 -0
- package/build/services/Websockets/StoreEvents.d.ts +14 -1
- package/build/services/Websockets/StoreEvents.d.ts.map +1 -1
- package/build/services/userPreferences.d.ts +47 -0
- package/build/services/userPreferences.d.ts.map +1 -0
- package/build/services/userPreferences.js +42 -0
- package/package.json +7 -6
- package/schemas/app-config.schema.json +79 -8
package/README.md
CHANGED
|
@@ -568,7 +568,7 @@ const query = qs.stringify(params, {
|
|
|
568
568
|
|
|
569
569
|
## App Manifest (`app-config.json`)
|
|
570
570
|
|
|
571
|
-
Every ANT app can ship an `app-config.json` in its distribution bundle. The OS and App Store read this file to discover what the app declares about itself: its version, tagline, tables, and
|
|
571
|
+
Every ANT app can ship an `app-config.json` in its distribution bundle. The OS and App Store read this file to discover what the app declares about itself: its version, tagline, tables, signal topics, and — for the AI overlay — its capabilities.
|
|
572
572
|
|
|
573
573
|
### Schema validation
|
|
574
574
|
|
|
@@ -582,10 +582,16 @@ A JSON Schema is published with this package at `schemas/app-config.schema.json`
|
|
|
582
582
|
"tables": [],
|
|
583
583
|
"signals": {
|
|
584
584
|
"topics": {}
|
|
585
|
+
},
|
|
586
|
+
"capabilities": {
|
|
587
|
+
"queryParams": {},
|
|
588
|
+
"intents": []
|
|
585
589
|
}
|
|
586
590
|
}
|
|
587
591
|
```
|
|
588
592
|
|
|
593
|
+
TypeScript types for the whole manifest are exported from the package: `AppManifest`, `AppManifestCapabilities`, `AppManifestQueryParam`, `AppManifestIntent`, `AppManifestTable`, `AppManifestTopic`.
|
|
594
|
+
|
|
589
595
|
### Sending the manifest to the OS
|
|
590
596
|
|
|
591
597
|
Apps can send their manifest to the OS during the comms handshake. This makes tables and topics visible in the OS context menu without an extra API call, and works across CORS boundaries (e.g. remote OS + local dev server).
|
|
@@ -601,13 +607,14 @@ The OS receives the manifest via the handshake ACK and exposes it on the comms h
|
|
|
601
607
|
|
|
602
608
|
### Tables
|
|
603
609
|
|
|
604
|
-
Tables are created
|
|
610
|
+
Tables are created when the app is installed. Each entry declares a table name, where it lives (`context`), and its columns:
|
|
605
611
|
|
|
606
612
|
```json
|
|
607
613
|
{
|
|
608
614
|
"tables": [
|
|
609
615
|
{
|
|
610
616
|
"name": "MY_APP_ITEMS",
|
|
617
|
+
"context": "project",
|
|
611
618
|
"master_table": true,
|
|
612
619
|
"columns": [
|
|
613
620
|
{ "name": "title", "type": "text", "required": true },
|
|
@@ -618,7 +625,14 @@ Tables are created in the project when the app is installed. Each entry declares
|
|
|
618
625
|
}
|
|
619
626
|
```
|
|
620
627
|
|
|
621
|
-
|
|
628
|
+
| Field | Required | Description |
|
|
629
|
+
|----------------|----------|--------------------------------------------------------|
|
|
630
|
+
| `name` | yes | Table name, unique within the app |
|
|
631
|
+
| `context` | no | `"project"` (default) creates the table in the project on install; `"license"` creates it at the license level |
|
|
632
|
+
| `master_table` | no | Marks the app's primary table (default `false`) |
|
|
633
|
+
| `columns` | yes | Column definitions (at least one) |
|
|
634
|
+
|
|
635
|
+
Column types: `integer`, `text`, `text-field`, `boolean`, `date`, `link`, `email`, `dropdown`, `document`, `float`, `sbscode`, `table`. Column fields include `required`, `is_unique`, `is_indexed` (max 2 per table), `default_value`, `options_value` (required for `dropdown`), `hint`, and `field_name`.
|
|
622
636
|
|
|
623
637
|
### Topic declarations
|
|
624
638
|
|
|
@@ -662,6 +676,56 @@ signal.receive((s) => {
|
|
|
662
676
|
|
|
663
677
|
The OS handles fan-out: when an app publishes a topic signal, the OS redistributes it to all other loaded apps and whispers it on the scoped Echo channel so apps in other browser tabs receive it too.
|
|
664
678
|
|
|
679
|
+
### Capabilities
|
|
680
|
+
|
|
681
|
+
`capabilities` declares **what the app can be driven to do through its URL** — the query params it reads and the named actions (intents) it exposes. The AI overlay reads this to turn a natural-language request ("open the app on the sockets tab") into a concrete launch with the right query string. It is metadata *about* the app's URL surface — it does not change how the app renders.
|
|
682
|
+
|
|
683
|
+
```json
|
|
684
|
+
{
|
|
685
|
+
"capabilities": {
|
|
686
|
+
"queryParams": {
|
|
687
|
+
"tab": {
|
|
688
|
+
"type": "string",
|
|
689
|
+
"description": "Which tab to open on load.",
|
|
690
|
+
"enum": ["overview", "items", "settings"]
|
|
691
|
+
},
|
|
692
|
+
"status": {
|
|
693
|
+
"type": "string",
|
|
694
|
+
"description": "Filter the list to this status.",
|
|
695
|
+
"enum": ["draft", "active", "archived"]
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
"intents": [
|
|
699
|
+
{ "id": "open-tab", "description": "Open the app on a specific tab", "params": ["tab"] },
|
|
700
|
+
{ "id": "filter-items", "description": "Open the app filtered to a status", "params": ["tab", "status"] }
|
|
701
|
+
]
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
**`queryParams`** — a map keyed by param name. Each entry describes one query param the app reads off its URL.
|
|
707
|
+
|
|
708
|
+
| Field | Required | Description |
|
|
709
|
+
|---------------|----------|-----------------------------------------------------------------|
|
|
710
|
+
| `type` | yes | Value type — `"string"`, `"number"`, `"boolean"`, `"date"`, `"time"` or `"datetime"`. On the URL everything is a string; the non-string types are rendering + validation hints |
|
|
711
|
+
| `description` | no | What the param does. Surfaced to the AI as tool-parameter help — write it for a model to read |
|
|
712
|
+
| `enum` | no | Allowed values. Becomes a hard constraint, so the AI can only pick a listed value |
|
|
713
|
+
| `multiple` | no | Accept several values (multi-select, CSV on the wire) (default `false`) |
|
|
714
|
+
| `required` | no | Whether the param must be supplied to invoke the app (default `false`) |
|
|
715
|
+
| `access` | no | `"readwrite"` (default) or `"write"` — commandable. `"read"` only *reflects* app state on the URL: the AI sees the current value and the confirm form shows it disabled, but neither may set it |
|
|
716
|
+
|
|
717
|
+
**`intents`** — named actions that group `queryParams` into a recognizable target. An intent adds no behavior; it points at params that already exist, giving the AI a labelled action to match a request against.
|
|
718
|
+
|
|
719
|
+
| Field | Required | Description |
|
|
720
|
+
|---------------|----------|-----------------------------------------------------------------|
|
|
721
|
+
| `id` | yes | Stable intent identifier |
|
|
722
|
+
| `description` | yes | What the intent does. Read by the AI to match a user request |
|
|
723
|
+
| `params` | no | Names of `queryParams` this intent uses (each must exist in the map) |
|
|
724
|
+
|
|
725
|
+
The overlay builds **one tool per available app** from the live app list: each `queryParams` entry becomes a tool parameter (`enum` → constrained choice, `required` → non-optional, `description` → parameter help), plus a built-in pane selector. `access: "read"` params are excluded from the tool schema. How reliably the model fills the right param is a direct function of good `description`s and tight `enum`s — treat them as prompt engineering. Your app must then read these params off its own URL (`window.location.search`) and act on them.
|
|
726
|
+
|
|
727
|
+
For the app currently open, the overlay also reads the declared params **back off** the URL and feeds them to the model as current state, and pre-fills the confirm form from them (URL loses to session memory, which loses to the prompt). That only works if your app keeps the params in sync as the user navigates — writing them on load is not enough. Declare a param `read` when the app maintains it as state the AI should know about but must not command.
|
|
728
|
+
|
|
665
729
|
---
|
|
666
730
|
|
|
667
731
|
## Resource Signals
|
package/build/AntConnect.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AntHttpClient } from './AntHttpClient';
|
|
2
|
+
import type AiService from './services/AiService';
|
|
2
3
|
import type AppService from './services/AppService';
|
|
3
4
|
import type ClientService from './services/ClientService';
|
|
4
5
|
import type ColumnService from './services/ColumnService';
|
|
@@ -59,6 +60,7 @@ export interface AntConnect {
|
|
|
59
60
|
readonly taskTemplates?: TaskTemplateService;
|
|
60
61
|
readonly tasksQuery: TaskQueryService;
|
|
61
62
|
readonly tokens: TokenService;
|
|
63
|
+
readonly ai: AiService;
|
|
62
64
|
readonly clients: ClientService;
|
|
63
65
|
readonly users: UserService;
|
|
64
66
|
readonly workflows: WorkflowService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AntConnect.d.ts","sourceRoot":"","sources":["../src/AntConnect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,eAAe,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,O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AAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,CAAC,CAAA;AAE1F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,CAAC,GAAG,iBAAiB,EAAE,EAAE,UAAU,CAAC,GAAG,UAAU,CAE1F;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAU7E"}
|
package/build/AntConnect.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { newAiService } from './services/AiService';
|
|
1
2
|
import { newAppService } from './services/AppService';
|
|
2
3
|
import { newClientService } from './services/ClientService';
|
|
3
4
|
import { newColumnService } from './services/ColumnService';
|
|
@@ -56,6 +57,7 @@ export function newAntConnect(httpClient) {
|
|
|
56
57
|
taskTemplates: newTaskTemplateService(httpClient),
|
|
57
58
|
tasksQuery: newTaskQueryService(httpClient),
|
|
58
59
|
tokens: newTokenService(httpClient),
|
|
60
|
+
ai: newAiService(httpClient),
|
|
59
61
|
clients: newClientService(httpClient),
|
|
60
62
|
users: newUserService(httpClient),
|
|
61
63
|
workflows: newWorkflowService(httpClient),
|
package/build/AntHttpClient.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
import type { Blob } from 'node:buffer';
|
|
3
|
-
import type { TokenResponse } from './types';
|
|
4
3
|
export interface NewAntHttpClientConfig {
|
|
5
4
|
baseUrl?: string;
|
|
6
5
|
apiUrl?: string;
|
|
@@ -25,10 +24,6 @@ export declare class AntHttpClient {
|
|
|
25
24
|
put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
26
25
|
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
27
26
|
patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
28
|
-
authenticate(userData: {
|
|
29
|
-
username: string;
|
|
30
|
-
password: string;
|
|
31
|
-
}, client_id: string | undefined, client_secret: string | undefined): Promise<TokenResponse>;
|
|
32
27
|
params(values: Record<string | number, any>, prefix?: string): string;
|
|
33
28
|
}
|
|
34
29
|
//# sourceMappingURL=AntHttpClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AntHttpClient.d.ts","sourceRoot":"","sources":["../src/AntHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"AntHttpClient.d.ts","sourceRoot":"","sources":["../src/AntHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAGvC,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,sBAAsB,GAAG,aAAa,CAgBzG;AAED,qBAAa,aAAa;aAIN,OAAO,EAAE,MAAM;IAE/B,OAAO,CAAC,QAAQ,CAAC,KAAK;IALxB,SAAgB,IAAI,EAAE,aAAa,CAAA;gBAGjB,OAAO,EAAE,MAAM,EAC/B,MAAM,EAAE,MAAM,EACG,KAAK,GAAE,eAAuC;IAM1D,sBAAsB;;;;IAItB,UAAU;IAIJ,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAI7E,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IASrE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAI5D,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAIxE,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/D,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAIvF,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;CAqBtE"}
|
package/build/AntHttpClient.js
CHANGED
|
@@ -44,11 +44,6 @@ export class AntHttpClient {
|
|
|
44
44
|
async patch(url, data, config) {
|
|
45
45
|
return this.http.patch(url, data, { ...this.scope, ...config }).then(r => r.data);
|
|
46
46
|
}
|
|
47
|
-
async authenticate(userData, client_id, client_secret) {
|
|
48
|
-
return this.http
|
|
49
|
-
.post('/oauth/token', { ...userData, client_id, client_secret, grant_type: 'password' }, { baseURL: this.baseUrl, ...this.scope })
|
|
50
|
-
.then(e => e.data);
|
|
51
|
-
}
|
|
52
47
|
params(values, prefix) {
|
|
53
48
|
const encode = encodeURIComponent;
|
|
54
49
|
if (Array.isArray(values)) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { mutationDescriptors } from './mutationDescriptors';
|
|
2
|
+
export { COLUMN_TYPES } from './mutationTargets';
|
|
3
|
+
export { queryDescriptors } from './queryDescriptors';
|
|
4
|
+
export type { AiMutationDescriptor, AiToolContext, AiToolDescriptor, MutationOperation, MutationTarget, QueryKind, } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,SAAS,GACV,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutationDescriptors.d.ts","sourceRoot":"","sources":["../../src/ai/mutationDescriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AA2NnD,eAAO,MAAM,mBAAmB,EAAE,oBAAoB,EAIrD,CAAA"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { alignValues, COLUMN_TYPES, columnInput, findColumn, projectInput, recordInput, str, tableInput, targetTable, valuesInput, } from './mutationTargets';
|
|
3
|
+
// The write tools, mirroring `queryDescriptors`. Same framework-agnostic
|
|
4
|
+
// contract — zod in, a plain `run` out — so ant-os, the MCP bridge and the
|
|
5
|
+
// Streamlit bridge all expose one vocabulary.
|
|
6
|
+
//
|
|
7
|
+
// None of these validates permissions or locks: that is the caller's confirm
|
|
8
|
+
// step, which has the `Table` detail (`permissions`, `is_locked`, `limits`) and
|
|
9
|
+
// a place to show the user why a button is off. A descriptor that guessed would
|
|
10
|
+
// duplicate the check and still race the server.
|
|
11
|
+
const tableDescriptors = [
|
|
12
|
+
{
|
|
13
|
+
name: 'mutate_create_table',
|
|
14
|
+
target: 'table',
|
|
15
|
+
operation: 'create',
|
|
16
|
+
description: 'Create a new empty dynamic table in a project. Add its columns afterwards with mutate_create_column.',
|
|
17
|
+
inputSchema: z.object({ project: projectInput, name: z.string().describe('Name of the new table') }),
|
|
18
|
+
requiredInputs: ['project', 'name'],
|
|
19
|
+
destructive: false,
|
|
20
|
+
run: async (ctx, input) => {
|
|
21
|
+
const project = str(input, 'project') || ctx.projectId || '';
|
|
22
|
+
return ctx.client.tables.createTable({ name: str(input, 'name'), project });
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'mutate_update_table',
|
|
27
|
+
target: 'table',
|
|
28
|
+
operation: 'update',
|
|
29
|
+
description: 'Rename a dynamic table or toggle its history. Use when the user wants to change a table itself, not its contents.',
|
|
30
|
+
inputSchema: z.object({
|
|
31
|
+
project: projectInput,
|
|
32
|
+
table: tableInput,
|
|
33
|
+
name: z.string().optional().describe('New name for the table'),
|
|
34
|
+
history_enabled: z.boolean().optional().describe('Whether to keep a revision history'),
|
|
35
|
+
}),
|
|
36
|
+
requiredInputs: ['project', 'table'],
|
|
37
|
+
destructive: false,
|
|
38
|
+
run: async (ctx, input) => {
|
|
39
|
+
const { table } = await targetTable(ctx, input);
|
|
40
|
+
if (!table)
|
|
41
|
+
throw new Error('Table not found');
|
|
42
|
+
const name = str(input, 'name');
|
|
43
|
+
return ctx.client.tables.updateTable(table.id, {
|
|
44
|
+
...name ? { name } : {},
|
|
45
|
+
...typeof input.history_enabled === 'boolean' ? { history_enabled: input.history_enabled } : {},
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'mutate_delete_table',
|
|
51
|
+
target: 'table',
|
|
52
|
+
operation: 'delete',
|
|
53
|
+
description: 'Delete a dynamic table and every record in it. Permanent.',
|
|
54
|
+
inputSchema: z.object({ project: projectInput, table: tableInput }),
|
|
55
|
+
requiredInputs: ['project', 'table'],
|
|
56
|
+
destructive: true,
|
|
57
|
+
run: async (ctx, input) => {
|
|
58
|
+
const { table } = await targetTable(ctx, input);
|
|
59
|
+
if (!table)
|
|
60
|
+
throw new Error('Table not found');
|
|
61
|
+
return ctx.client.tables.deleteTable(table.id);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'mutate_clear_table',
|
|
66
|
+
target: 'table',
|
|
67
|
+
operation: 'clear',
|
|
68
|
+
description: 'Delete every record in a dynamic table while keeping the table and its columns. Permanent.',
|
|
69
|
+
inputSchema: z.object({ project: projectInput, table: tableInput }),
|
|
70
|
+
requiredInputs: ['project', 'table'],
|
|
71
|
+
destructive: true,
|
|
72
|
+
run: async (ctx, input) => {
|
|
73
|
+
const { table } = await targetTable(ctx, input);
|
|
74
|
+
if (!table)
|
|
75
|
+
throw new Error('Table not found');
|
|
76
|
+
return ctx.client.tables.clearTable(table.id);
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
const columnDescriptors = [
|
|
81
|
+
{
|
|
82
|
+
name: 'mutate_create_column',
|
|
83
|
+
target: 'column',
|
|
84
|
+
operation: 'create',
|
|
85
|
+
description: 'Add a column to a dynamic table.',
|
|
86
|
+
inputSchema: z.object({
|
|
87
|
+
project: projectInput,
|
|
88
|
+
table: tableInput,
|
|
89
|
+
name: z.string().describe('Name of the new column'),
|
|
90
|
+
type: z.enum(COLUMN_TYPES).optional().describe('Data type of the column, text when unsure'),
|
|
91
|
+
required: z.boolean().optional().describe('Whether every record must fill this column'),
|
|
92
|
+
options: z.array(z.string()).optional().describe('Allowed values, dropdown columns only'),
|
|
93
|
+
}),
|
|
94
|
+
requiredInputs: ['project', 'table', 'name'],
|
|
95
|
+
destructive: false,
|
|
96
|
+
run: async (ctx, input) => {
|
|
97
|
+
const { table } = await targetTable(ctx, input);
|
|
98
|
+
if (!table)
|
|
99
|
+
throw new Error('Table not found');
|
|
100
|
+
return ctx.client.columns.createColumn({
|
|
101
|
+
table: table.id,
|
|
102
|
+
name: str(input, 'name'),
|
|
103
|
+
type: str(input, 'type') || 'text',
|
|
104
|
+
required: input.required === true,
|
|
105
|
+
...Array.isArray(input.options) ? { options_value: input.options.map(String) } : {},
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'mutate_update_column',
|
|
111
|
+
target: 'column',
|
|
112
|
+
operation: 'update',
|
|
113
|
+
description: 'Rename a column or change whether it is required / its allowed values. The column type cannot be changed.',
|
|
114
|
+
inputSchema: z.object({
|
|
115
|
+
project: projectInput,
|
|
116
|
+
table: tableInput,
|
|
117
|
+
column: columnInput,
|
|
118
|
+
name: z.string().optional().describe('New name for the column'),
|
|
119
|
+
required: z.boolean().optional().describe('Whether every record must fill this column'),
|
|
120
|
+
options: z.array(z.string()).optional().describe('Allowed values, dropdown columns only'),
|
|
121
|
+
}),
|
|
122
|
+
requiredInputs: ['project', 'table', 'column'],
|
|
123
|
+
destructive: false,
|
|
124
|
+
run: async (ctx, input) => {
|
|
125
|
+
const { table } = await targetTable(ctx, input);
|
|
126
|
+
const column = findColumn(table, str(input, 'column'));
|
|
127
|
+
if (!column)
|
|
128
|
+
throw new Error('Column not found');
|
|
129
|
+
const name = str(input, 'name');
|
|
130
|
+
return ctx.client.columns.updateColumn(column.id, {
|
|
131
|
+
...name ? { name } : {},
|
|
132
|
+
...typeof input.required === 'boolean' ? { required: input.required } : {},
|
|
133
|
+
...Array.isArray(input.options) ? { options_value: input.options.map(String) } : {},
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'mutate_delete_column',
|
|
139
|
+
target: 'column',
|
|
140
|
+
operation: 'delete',
|
|
141
|
+
description: 'Delete a column from a dynamic table, including its value in every record. Permanent.',
|
|
142
|
+
inputSchema: z.object({ project: projectInput, table: tableInput, column: columnInput }),
|
|
143
|
+
requiredInputs: ['project', 'table', 'column'],
|
|
144
|
+
destructive: true,
|
|
145
|
+
run: async (ctx, input) => {
|
|
146
|
+
const { table } = await targetTable(ctx, input);
|
|
147
|
+
const column = findColumn(table, str(input, 'column'));
|
|
148
|
+
if (!column)
|
|
149
|
+
throw new Error('Column not found');
|
|
150
|
+
return ctx.client.columns.deleteColumn(column.id);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
const recordDescriptors = [
|
|
155
|
+
{
|
|
156
|
+
name: 'mutate_create_record',
|
|
157
|
+
target: 'record',
|
|
158
|
+
operation: 'create',
|
|
159
|
+
description: 'Add a record (row) to a dynamic table. Use the table\'s real column names as the keys of values.',
|
|
160
|
+
inputSchema: z.object({ project: projectInput, table: tableInput, values: valuesInput }),
|
|
161
|
+
requiredInputs: ['project', 'table'],
|
|
162
|
+
destructive: false,
|
|
163
|
+
run: async (ctx, input) => {
|
|
164
|
+
const { table } = await targetTable(ctx, input);
|
|
165
|
+
if (!table)
|
|
166
|
+
throw new Error('Table not found');
|
|
167
|
+
return ctx.client.records.createRecord(table.id, { record: alignValues(input.values, table) });
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'mutate_update_record',
|
|
172
|
+
target: 'record',
|
|
173
|
+
operation: 'update',
|
|
174
|
+
description: 'Change the values of one existing record. Only the columns named in values are touched.',
|
|
175
|
+
inputSchema: z.object({ project: projectInput, table: tableInput, record: recordInput, values: valuesInput }),
|
|
176
|
+
requiredInputs: ['project', 'table', 'record'],
|
|
177
|
+
destructive: false,
|
|
178
|
+
run: async (ctx, input) => {
|
|
179
|
+
const { table } = await targetTable(ctx, input);
|
|
180
|
+
const record = str(input, 'record');
|
|
181
|
+
if (!table || !record)
|
|
182
|
+
throw new Error('Record not found');
|
|
183
|
+
return ctx.client.records.updateRecord(table.id, record, { record: alignValues(input.values, table) });
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'mutate_delete_record',
|
|
188
|
+
target: 'record',
|
|
189
|
+
operation: 'delete',
|
|
190
|
+
description: 'Delete one record from a dynamic table. Permanent.',
|
|
191
|
+
inputSchema: z.object({ project: projectInput, table: tableInput, record: recordInput }),
|
|
192
|
+
requiredInputs: ['project', 'table', 'record'],
|
|
193
|
+
destructive: true,
|
|
194
|
+
run: async (ctx, input) => {
|
|
195
|
+
const { project, table } = await targetTable(ctx, input);
|
|
196
|
+
const record = str(input, 'record');
|
|
197
|
+
if (!table || !record)
|
|
198
|
+
throw new Error('Record not found');
|
|
199
|
+
return ctx.client.records.deleteRecords(project, table.id, [record]);
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
export const mutationDescriptors = [
|
|
204
|
+
...tableDescriptors,
|
|
205
|
+
...columnDescriptors,
|
|
206
|
+
...recordDescriptors,
|
|
207
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AiToolContext } from './types';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const projectInput: z.ZodOptional<z.ZodString>;
|
|
4
|
+
export declare const tableInput: z.ZodOptional<z.ZodString>;
|
|
5
|
+
export declare const columnInput: z.ZodOptional<z.ZodString>;
|
|
6
|
+
export declare const recordInput: z.ZodOptional<z.ZodString>;
|
|
7
|
+
export declare const COLUMN_TYPES: readonly ["text", "text-field", "number", "integer", "float", "boolean", "date", "dropdown", "email", "link", "sbscode"];
|
|
8
|
+
export declare const valuesInput: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
9
|
+
export declare function str(input: Record<string, unknown>, key: string): string;
|
|
10
|
+
/** Tables of a project WITH their columns — one call resolves table and column. */
|
|
11
|
+
declare function loadTables(ctx: AiToolContext, project: string): Promise<import("..").TableList[]>;
|
|
12
|
+
type LoadedTable = Awaited<ReturnType<typeof loadTables>>[number];
|
|
13
|
+
export declare function findColumn(table: LoadedTable | undefined, term: string): import("..").Column | undefined;
|
|
14
|
+
export declare function alignValues(raw: unknown, table: LoadedTable | undefined): Record<string, string | number | boolean | null>;
|
|
15
|
+
/** Resolve project → table in one step; every column/record tool starts here. */
|
|
16
|
+
export declare function targetTable(ctx: AiToolContext, input: Record<string, unknown>): Promise<{
|
|
17
|
+
project: string;
|
|
18
|
+
table: import("..").TableList | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=mutationTargets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutationTargets.d.ts","sourceRoot":"","sources":["../../src/ai/mutationTargets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,YAAY,4BAA8D,CAAA;AACvF,eAAO,MAAM,UAAU,4BAA4D,CAAA;AACnF,eAAO,MAAM,WAAW,4BAA6D,CAAA;AACrF,eAAO,MAAM,WAAW,4BAA6F,CAAA;AAKrH,eAAO,MAAM,YAAY,0HAA2H,CAAA;AAGpJ,eAAO,MAAM,WAAW,oGAC8C,CAAA;AAEtE,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,mFAAmF;AACnF,iBAAS,UAAU,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,qCAEtD;AAED,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AAWjE,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,mCAKtE;AAmBD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,SAAS,oDAWvE;AAED,iFAAiF;AACjF,wBAAsB,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;GAMnF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// Shared input contracts and entity resolution for the mutation descriptors.
|
|
3
|
+
// Split out of `mutationDescriptors` so that file stays a flat, readable list of
|
|
4
|
+
// tools rather than tools interleaved with lookup plumbing.
|
|
5
|
+
export const projectInput = z.string().optional().describe('Id or name of the project');
|
|
6
|
+
export const tableInput = z.string().optional().describe('Id or name of the table');
|
|
7
|
+
export const columnInput = z.string().optional().describe('Id or name of the column');
|
|
8
|
+
export const recordInput = z.string().optional().describe('Id of the record. Records have no name — never guess one');
|
|
9
|
+
// The safe subset of `ColumnType`. `document`, `uuid` and `table` are omitted on
|
|
10
|
+
// purpose: they need a file upload or a relation target that the prompt cannot
|
|
11
|
+
// express and the confirm form does not render.
|
|
12
|
+
export const COLUMN_TYPES = ['text', 'text-field', 'number', 'integer', 'float', 'boolean', 'date', 'dropdown', 'email', 'link', 'sbscode'];
|
|
13
|
+
const cellValue = z.union([z.string(), z.number(), z.boolean(), z.null()]);
|
|
14
|
+
export const valuesInput = z.record(z.string(), cellValue)
|
|
15
|
+
.describe('Column name → value. Use the table\'s real column names');
|
|
16
|
+
export function str(input, key) {
|
|
17
|
+
return typeof input[key] === 'string' ? input[key].trim() : '';
|
|
18
|
+
}
|
|
19
|
+
/** Tables of a project WITH their columns — one call resolves table and column. */
|
|
20
|
+
function loadTables(ctx, project) {
|
|
21
|
+
return ctx.client.tables.getTables(project, true);
|
|
22
|
+
}
|
|
23
|
+
/** The prompt may name a table; the confirm form picks an id — accept both. */
|
|
24
|
+
function findTable(tables, term) {
|
|
25
|
+
if (!term)
|
|
26
|
+
return undefined;
|
|
27
|
+
return tables.find(t => t.id === term)
|
|
28
|
+
?? tables.find(t => t.name.toLowerCase() === term.toLowerCase())
|
|
29
|
+
?? tables.find(t => t.name.toLowerCase().includes(term.toLowerCase()));
|
|
30
|
+
}
|
|
31
|
+
export function findColumn(table, term) {
|
|
32
|
+
const columns = table?.columns ?? [];
|
|
33
|
+
return columns.find(c => c.id === term)
|
|
34
|
+
?? columns.find(c => c.name.toLowerCase() === term.toLowerCase())
|
|
35
|
+
?? columns.find(c => c.name.toLowerCase().includes(term.toLowerCase()));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Map free-form `values` onto the table's real column names.
|
|
39
|
+
*
|
|
40
|
+
* The model writes `values` without having seen the schema, so keys arrive in
|
|
41
|
+
* whatever casing the user typed and sometimes name a column that does not
|
|
42
|
+
* exist. An unknown key makes the API reject the WHOLE payload, taking the
|
|
43
|
+
* correct values down with it — so unknown keys are dropped, not forwarded.
|
|
44
|
+
* The confirm form renders the real columns, which is where the user sees and
|
|
45
|
+
* fixes anything that fell out.
|
|
46
|
+
*/
|
|
47
|
+
// A predicate rather than an inline check: this package compiles without
|
|
48
|
+
// strictNullChecks, so `value === null` narrows nothing and the inline form
|
|
49
|
+
// leaves `value` as `unknown` at the assignment.
|
|
50
|
+
function isCellValue(value) {
|
|
51
|
+
return value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
52
|
+
}
|
|
53
|
+
export function alignValues(raw, table) {
|
|
54
|
+
const out = {};
|
|
55
|
+
if (!raw || typeof raw !== 'object')
|
|
56
|
+
return out;
|
|
57
|
+
const byName = new Map((table?.columns ?? []).map(c => [c.name.toLowerCase(), c.name]));
|
|
58
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
59
|
+
const name = byName.get(key.toLowerCase());
|
|
60
|
+
if (name && isCellValue(value))
|
|
61
|
+
out[name] = value;
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/** Resolve project → table in one step; every column/record tool starts here. */
|
|
66
|
+
export async function targetTable(ctx, input) {
|
|
67
|
+
const project = str(input, 'project') || ctx.projectId || '';
|
|
68
|
+
if (!project)
|
|
69
|
+
return { project: '', table: undefined };
|
|
70
|
+
const table = findTable(await loadTables(ctx, project), str(input, 'table'));
|
|
71
|
+
return { project, table };
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryDescriptors.d.ts","sourceRoot":"","sources":["../../src/ai/queryDescriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAc/C,eAAO,MAAM,gBAAgB,EAAE,gBAAgB,EAkK9C,CAAA"}
|