@ganju/utils 0.0.15 → 0.0.17
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/dist/constants.d.ts +26 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +107 -9
- package/dist/customCodeToken.d.ts +11 -0
- package/dist/customCodeToken.d.ts.map +1 -1
- package/dist/customCodeToken.js +41 -1
- package/dist/data.d.ts +13 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +103 -0
- package/dist/dataApi.d.ts +578 -0
- package/dist/dataApi.d.ts.map +1 -0
- package/dist/dataApi.js +399 -0
- package/dist/dataCompiler.d.ts +68 -0
- package/dist/dataCompiler.d.ts.map +1 -0
- package/dist/dataCompiler.js +730 -0
- package/dist/dataCsv.d.ts +20 -0
- package/dist/dataCsv.d.ts.map +1 -0
- package/dist/dataCsv.js +102 -0
- package/dist/dataDdl.d.ts +29 -0
- package/dist/dataDdl.d.ts.map +1 -0
- package/dist/dataDdl.js +354 -0
- package/dist/dataEngine.d.ts +143 -0
- package/dist/dataEngine.d.ts.map +1 -0
- package/dist/dataEngine.js +2042 -0
- package/dist/dataIdentifiers.d.ts +8 -0
- package/dist/dataIdentifiers.d.ts.map +1 -0
- package/dist/dataIdentifiers.js +55 -0
- package/dist/dataImport.d.ts +79 -0
- package/dist/dataImport.d.ts.map +1 -0
- package/dist/dataImport.js +453 -0
- package/dist/dataQueries.d.ts +73 -0
- package/dist/dataQueries.d.ts.map +1 -0
- package/dist/dataQueries.js +513 -0
- package/dist/dataRpc.d.ts +150 -0
- package/dist/dataRpc.d.ts.map +1 -0
- package/dist/dataRpc.js +2 -0
- package/dist/dataTools.d.ts +40 -0
- package/dist/dataTools.d.ts.map +1 -0
- package/dist/dataTools.js +280 -0
- package/dist/dataTypes.d.ts +159 -0
- package/dist/dataTypes.d.ts.map +1 -0
- package/dist/dataTypes.js +160 -0
- package/dist/index.d.ts +394 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/oauth.d.ts +14 -0
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +42 -2
- package/dist/resourceRerank.d.ts +3 -2
- package/dist/resourceRerank.d.ts.map +1 -1
- package/dist/resourceRerank.js +5 -2
- package/dist/schema.d.ts +376 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +268 -1
- package/dist/sdkConstants.d.ts +1 -0
- package/dist/sdkConstants.d.ts.map +1 -1
- package/dist/sdkConstants.js +2 -1
- package/package.json +17 -2
- package/src/constants.ts +121 -9
- package/src/customCodeToken.ts +74 -0
- package/src/data.ts +108 -0
- package/src/dataApi.ts +479 -0
- package/src/dataCompiler.ts +952 -0
- package/src/dataCsv.ts +99 -0
- package/src/dataDdl.ts +419 -0
- package/src/dataEngine.ts +2773 -0
- package/src/dataIdentifiers.ts +63 -0
- package/src/dataImport.ts +557 -0
- package/src/dataQueries.ts +730 -0
- package/src/dataRpc.ts +132 -0
- package/src/dataTools.ts +338 -0
- package/src/dataTypes.ts +318 -0
- package/src/index.ts +13 -1
- package/src/oauth.ts +42 -1
- package/src/resourceRerank.ts +5 -2
- package/src/schema.ts +315 -1
- package/src/sdkConstants.ts +1 -0
package/dist/constants.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ interface PlanLimits {
|
|
|
62
62
|
includedMessages: number;
|
|
63
63
|
includedEmbeddedBytes: number;
|
|
64
64
|
autoSyncIntervals: ReadonlyArray<typeof RESOURCE_SYNC_INTERVAL_DAILY | typeof RESOURCE_SYNC_INTERVAL_WEEKLY>;
|
|
65
|
+
canUseData: boolean;
|
|
66
|
+
maxDataBytes: number | null;
|
|
67
|
+
maxDataTablesPerDatabase: number | null;
|
|
68
|
+
triggerRunHardCap: number | null;
|
|
65
69
|
}
|
|
66
70
|
export type { PlanLimits };
|
|
67
71
|
export declare const constants: {
|
|
@@ -94,6 +98,20 @@ export declare const constants: {
|
|
|
94
98
|
PRICING_TOOL_CALL_PER_M_USD: number;
|
|
95
99
|
PRICING_TOOL_CALL_HARD_CAP: number;
|
|
96
100
|
PRICING_CUSTOM_DOMAIN_USD: number;
|
|
101
|
+
DATA_MAX_DATABASE_BYTES: number;
|
|
102
|
+
DATA_MAX_TABLES_PER_DATABASE: number;
|
|
103
|
+
DATA_TRIGGER_RUN_HARD_CAP: number;
|
|
104
|
+
DATA_DELETE_GRACE_DAYS: number;
|
|
105
|
+
DATA_PURGE_BATCH: number;
|
|
106
|
+
DATA_ACTIVITY_THROTTLE_MS: number;
|
|
107
|
+
ARTIFACT_DATABASE_STATUS_CREATING: "CREATING";
|
|
108
|
+
ARTIFACT_DATABASE_STATUS_READY: "READY";
|
|
109
|
+
ARTIFACT_DATABASE_STATUS_FAILED: "FAILED";
|
|
110
|
+
ARTIFACT_DATABASE_STATUS_DELETING: "DELETING";
|
|
111
|
+
ARTIFACT_DATABASE_STATUS_PURGING: "PURGING";
|
|
112
|
+
ARTIFACT_DATABASE_STATUS_DELETED: "DELETED";
|
|
113
|
+
DATA_PURGE_STALE_MS: number;
|
|
114
|
+
ARTIFACT_DATABASE_STATUSES: ("FAILED" | "CREATING" | "READY" | "DELETING" | "PURGING" | "DELETED")[];
|
|
97
115
|
PLAN_FEATURE_ORGANIZATION: "organization";
|
|
98
116
|
PLAN_FEATURE_PROJECT: "project";
|
|
99
117
|
PLAN_FEATURE_TOOL: "tool";
|
|
@@ -108,6 +126,7 @@ export declare const constants: {
|
|
|
108
126
|
PLAN_FEATURE_MESSAGE: "message";
|
|
109
127
|
PLAN_FEATURE_TOOL_CALL: "toolCall";
|
|
110
128
|
PLAN_FEATURE_RESOURCE_SYNC: "resourceSync";
|
|
129
|
+
PLAN_FEATURE_DATA: "data";
|
|
111
130
|
PLAN_LIMIT_ERROR_CODE: string;
|
|
112
131
|
BILLING_METER_MESSAGES: string;
|
|
113
132
|
BILLING_METER_SHARED_MESSAGES: string;
|
|
@@ -201,6 +220,7 @@ export declare const constants: {
|
|
|
201
220
|
SLACK_OAUTH_TOKEN_URL: string;
|
|
202
221
|
OAUTH_TOKEN_URLS: Record<string, string>;
|
|
203
222
|
CREDENTIAL_REFRESH_BUFFER_MS: number;
|
|
223
|
+
CREDENTIAL_REFRESH_GIVE_UP_MS: number;
|
|
204
224
|
GOOGLE_CALENDAR_API_BASE: string;
|
|
205
225
|
GOOGLE_DRIVE_API_BASE: string;
|
|
206
226
|
GOOGLE_DRIVE_DEFAULT_PAGE_SIZE: number;
|
|
@@ -242,6 +262,7 @@ export declare const constants: {
|
|
|
242
262
|
label: string;
|
|
243
263
|
}[];
|
|
244
264
|
REAUTH_ERROR_CODES: string[];
|
|
265
|
+
OAUTH_CLIENT_ERROR_CODES: string[];
|
|
245
266
|
RESOURCE_TYPE_TOOLTIP_MIN_WIDTH: number;
|
|
246
267
|
SEARCH_DEBOUNCE_MS: number;
|
|
247
268
|
GOOGLE_DRIVE_EXPORT_MIME_TYPES: Record<string, string>;
|
|
@@ -477,6 +498,7 @@ export declare const constants: {
|
|
|
477
498
|
RESOURCE_SEARCH_RRF_K: number;
|
|
478
499
|
RESOURCE_SEARCH_COMMON_TERM_DIVISOR: number;
|
|
479
500
|
RESOURCE_SEARCH_COMMON_TERM_MIN: number;
|
|
501
|
+
RESOURCE_SEARCH_RERANK_ENABLED: boolean;
|
|
480
502
|
RESOURCE_SEARCH_RERANK_CANDIDATES: number;
|
|
481
503
|
RESOURCE_SEARCH_RERANK_MODEL: string;
|
|
482
504
|
RESOURCE_SEARCH_EXACT_MAX_RESOURCES: number;
|
|
@@ -628,6 +650,7 @@ export declare const constants: {
|
|
|
628
650
|
CUSTOM_CODE_BROKER_PATH_RESOURCES_CREATE: string;
|
|
629
651
|
CUSTOM_CODE_BROKER_PATH_RESOURCES_DELETE: string;
|
|
630
652
|
CUSTOM_CODE_BROKER_PATH_SEND_FILE: string;
|
|
653
|
+
CUSTOM_CODE_BROKER_PATH_DATA: string;
|
|
631
654
|
CUSTOM_CODE_OUTBOUND_PARAM_ARTIFACT_ID: "artifactId";
|
|
632
655
|
CUSTOM_CODE_OUTBOUND_PARAM_ALLOWED_HOSTS: "allowedHosts";
|
|
633
656
|
CUSTOM_CODE_PLATFORM_HOSTS: string[];
|
|
@@ -665,10 +688,13 @@ export declare const constants: {
|
|
|
665
688
|
CUSTOM_CODE_RESOURCE_FILE_TOO_LARGE_MESSAGE: string;
|
|
666
689
|
RESERVED_SLUGS: string[];
|
|
667
690
|
MCP_INTERNAL_HEADER: string;
|
|
691
|
+
MCP_EVAL_RERANK_HEADER: string;
|
|
668
692
|
MCP_CHANNEL_ID_HEADER: string;
|
|
669
693
|
MCP_CHANNEL_PLATFORM_HEADER: string;
|
|
670
694
|
MCP_CHANNEL_CONVERSATION_HEADER: string;
|
|
671
695
|
MCP_CHANNEL_CLIENT_USER_AGENT: string;
|
|
696
|
+
MCP_CHANNEL_PARTICIPANT_HEADER: string;
|
|
697
|
+
MCP_CHANNEL_TIME_ZONE_HEADER: string;
|
|
672
698
|
MCP_SESSION_HEADER: string;
|
|
673
699
|
MCP_REQUEST_METHOD_INITIALIZE: "initialize";
|
|
674
700
|
MCP_REQUEST_METHOD_PING: "ping";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAmKA,QAAA,MAAM,yBAAyB,EAAiB,UAAU,CAAC;AAC3D,QAAA,MAAM,+BAA+B,EAAuB,gBAAgB,CAAC;AAC7E,QAAA,MAAM,8BAA8B,EAAsB,eAAe,CAAC;AAC1E,QAAA,MAAM,wBAAwB,EAAgB,SAAS,CAAC;AAuCxD,QAAA,MAAM,sBAAsB,EAAiB,UAAU,CAAC;AACxD,QAAA,MAAM,4BAA4B,EAAuB,gBAAgB,CAAC;AAC1E,QAAA,MAAM,oBAAoB,EAAe,QAAQ,CAAC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BAAwB;eAC5B,MAAM;;;;;;;;;;;;;;;;;;eAsCT,OAAO,sBAAsB,GAC7B,OAAO,4BAA4B,GACnC,OAAO,oBAAoB,GAC3B,OAAO,oBAAoB;eACxB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAqcT,OAAO,mBAAmB,GAC1B,OAAO,mBAAmB,GAC1B,OAAO,sBAAsB;eAC1B,MAAM;eACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAyWwB,MAAM,GAAG,MAAM;cAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwmEnE,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -104,6 +104,10 @@ const OAUTH_TOKEN_URLS = {
|
|
|
104
104
|
// expire mid-flight. Shared by every credential-refresh path (native OAuth and
|
|
105
105
|
// MCP-proxy OAuth, in both apps/api and apps/mcp).
|
|
106
106
|
const CREDENTIAL_REFRESH_BUFFER_MS = 60 * 1000;
|
|
107
|
+
// A refresh the token endpoint rejects (4xx) without a reauth code still flags
|
|
108
|
+
// the credential once its access token has been expired this long, so the
|
|
109
|
+
// owner sees it as expired instead of every call failing behind "Connected".
|
|
110
|
+
const CREDENTIAL_REFRESH_GIVE_UP_MS = 60 * 60 * 1000;
|
|
107
111
|
const GOOGLE_CALENDAR_API_BASE = 'https://www.googleapis.com/calendar/v3';
|
|
108
112
|
const GOOGLE_DRIVE_API_BASE = 'https://www.googleapis.com/drive/v3';
|
|
109
113
|
const GOOGLE_DRIVE_DEFAULT_PAGE_SIZE = 200;
|
|
@@ -167,7 +171,17 @@ const ONE_DRIVE_TAB_LABELS = [
|
|
|
167
171
|
{ value: ONE_DRIVE_TAB_RECENT, label: ONE_DRIVE_TAB_LABEL_RECENT },
|
|
168
172
|
{ value: ONE_DRIVE_TAB_DRIVES, label: ONE_DRIVE_TAB_LABEL_DRIVES }
|
|
169
173
|
];
|
|
170
|
-
|
|
174
|
+
// Token-endpoint error codes that mean the stored refresh token is dead and
|
|
175
|
+
// only a reconnect brings it back. `unauthorized_client` is Google's answer
|
|
176
|
+
// when a token no longer belongs to the app it is refreshed with.
|
|
177
|
+
const REAUTH_ERROR_CODES = [
|
|
178
|
+
'invalid_grant',
|
|
179
|
+
'invalid_token',
|
|
180
|
+
'unauthorized_client'
|
|
181
|
+
];
|
|
182
|
+
// Token-endpoint error codes that are about our own client id / secret, not
|
|
183
|
+
// the user's token: a reconnect can't fix them, so they never flag one.
|
|
184
|
+
const OAUTH_CLIENT_ERROR_CODES = ['invalid_client'];
|
|
171
185
|
const RESOURCE_TYPE_TOOLTIP_MIN_WIDTH = 300;
|
|
172
186
|
const SEARCH_DEBOUNCE_MS = 300;
|
|
173
187
|
const SCHEMA_DEFINITION_TYPES = [
|
|
@@ -840,10 +854,14 @@ const RESOURCE_SEARCH_RRF_K = 60;
|
|
|
840
854
|
// keeps its words.
|
|
841
855
|
const RESOURCE_SEARCH_COMMON_TERM_DIVISOR = 10;
|
|
842
856
|
const RESOURCE_SEARCH_COMMON_TERM_MIN = 5;
|
|
843
|
-
// Second stage
|
|
844
|
-
//
|
|
845
|
-
//
|
|
846
|
-
//
|
|
857
|
+
// Second stage: the top fused candidates re-scored by a cross-encoder, which
|
|
858
|
+
// reads query and chunk together instead of comparing two independently
|
|
859
|
+
// computed vectors. One model call per search; a failure falls back to the
|
|
860
|
+
// fused order. Off by default: on the golden sets (Spanish and English) the
|
|
861
|
+
// fused order matched or beat it on every set — 10 cases better, 5 worse — and
|
|
862
|
+
// it added 0.5–0.9 s a search plus a ~6 s cold start. The search eval can
|
|
863
|
+
// still turn it on per request to re-measure.
|
|
864
|
+
const RESOURCE_SEARCH_RERANK_ENABLED = false;
|
|
847
865
|
const RESOURCE_SEARCH_RERANK_CANDIDATES = 30;
|
|
848
866
|
const RESOURCE_SEARCH_RERANK_MODEL = '@cf/baai/bge-reranker-base';
|
|
849
867
|
// An identifier in the query (a code mixing letters and digits, a snake_case
|
|
@@ -1326,7 +1344,10 @@ const RESERVED_TOOL_NAME_PREFIXES = [
|
|
|
1326
1344
|
'slack-',
|
|
1327
1345
|
CALENDAR_TOOL_KEY_PREFIX,
|
|
1328
1346
|
CALCOM_TOOL_KEY_PREFIX,
|
|
1329
|
-
WEB_TOOL_KEY_PREFIX
|
|
1347
|
+
WEB_TOOL_KEY_PREFIX,
|
|
1348
|
+
// data-describe, data-query, data-write and data-admin, registered for a
|
|
1349
|
+
// project with a database.
|
|
1350
|
+
'data-'
|
|
1330
1351
|
];
|
|
1331
1352
|
// The keys that don't belong to a prefixed group: the RAG core the channel
|
|
1332
1353
|
// runner intercepts by name, the smoke-test tool, the three proxied definition
|
|
@@ -1568,6 +1589,10 @@ const MCP_AUTH_KIND_INTERNAL = 'internal';
|
|
|
1568
1589
|
const MCP_AUTH_KINDS = [MCP_AUTH_KIND_JWT, MCP_AUTH_KIND_INTERNAL];
|
|
1569
1590
|
const MCP_SESSION_HEADER = 'mcp-session-id';
|
|
1570
1591
|
const MCP_INTERNAL_HEADER = 'x-ganju-internal-secret';
|
|
1592
|
+
// Sent with the internal secret by the search eval to measure the reranker:
|
|
1593
|
+
// `on` or `off` overrides RESOURCE_SEARCH_RERANK_ENABLED for that request.
|
|
1594
|
+
// Ignored on any other request.
|
|
1595
|
+
const MCP_EVAL_RERANK_HEADER = 'x-ganju-eval-rerank';
|
|
1571
1596
|
const MCP_CHANNEL_ID_HEADER = 'x-ganju-channel-id';
|
|
1572
1597
|
const MCP_CHANNEL_PLATFORM_HEADER = 'x-ganju-channel-platform';
|
|
1573
1598
|
// The conversation a channel turn belongs to. The MCP worker files that turn's
|
|
@@ -1575,6 +1600,11 @@ const MCP_CHANNEL_PLATFORM_HEADER = 'x-ganju-channel-platform';
|
|
|
1575
1600
|
// the chat it ran in.
|
|
1576
1601
|
const MCP_CHANNEL_CONVERSATION_HEADER = 'x-ganju-channel-conversation-id';
|
|
1577
1602
|
const MCP_CHANNEL_CLIENT_USER_AGENT = 'ganju-channel/0.0.1';
|
|
1603
|
+
// The participant a channel turn is for: customer-scoped tables fill and
|
|
1604
|
+
// filter their rows with it. Trusted only on the channel's own auth paths.
|
|
1605
|
+
const MCP_CHANNEL_PARTICIPANT_HEADER = 'x-ganju-channel-participant-id';
|
|
1606
|
+
// The zone the channel resolves dates in; the data tools answer in it.
|
|
1607
|
+
const MCP_CHANNEL_TIME_ZONE_HEADER = 'x-ganju-channel-time-zone';
|
|
1578
1608
|
const JWKS_KV_KEY = 'jwks:v1';
|
|
1579
1609
|
const JWKS_TTL_SECONDS = 600;
|
|
1580
1610
|
// Standard OIDC scopes the better-auth oauthProvider honors for user OAuth
|
|
@@ -1836,6 +1866,39 @@ const PRICING_TOOL_CALL_PER_M_USD = 5;
|
|
|
1836
1866
|
// million calls a month, so a fixed ceiling there would fight a real customer.
|
|
1837
1867
|
const PRICING_TOOL_CALL_HARD_CAP = 20_000_000;
|
|
1838
1868
|
const PRICING_CUSTOM_DOMAIN_USD = 15;
|
|
1869
|
+
// Project data (one SQLite Durable Object per artifact). Cloudflare caps a
|
|
1870
|
+
// database at 10 GB; we stop writes that add data at 9 GB so there is room to
|
|
1871
|
+
// delete, archive and export.
|
|
1872
|
+
const DATA_MAX_DATABASE_BYTES = 9 * GB;
|
|
1873
|
+
const DATA_MAX_TABLES_PER_DATABASE = 50;
|
|
1874
|
+
const DATA_TRIGGER_RUN_HARD_CAP = 5_000_000;
|
|
1875
|
+
// A deleted database can be restored for this long before its storage is
|
|
1876
|
+
// freed.
|
|
1877
|
+
const DATA_DELETE_GRACE_DAYS = 7;
|
|
1878
|
+
const ARTIFACT_DATABASE_STATUS_CREATING = 'CREATING';
|
|
1879
|
+
const ARTIFACT_DATABASE_STATUS_READY = 'READY';
|
|
1880
|
+
const ARTIFACT_DATABASE_STATUS_FAILED = 'FAILED';
|
|
1881
|
+
const ARTIFACT_DATABASE_STATUS_DELETING = 'DELETING';
|
|
1882
|
+
// The hourly purge has claimed the row and is emptying the object; a restore
|
|
1883
|
+
// can no longer take it back.
|
|
1884
|
+
const ARTIFACT_DATABASE_STATUS_PURGING = 'PURGING';
|
|
1885
|
+
const ARTIFACT_DATABASE_STATUS_DELETED = 'DELETED';
|
|
1886
|
+
const ARTIFACT_DATABASE_STATUSES = [
|
|
1887
|
+
ARTIFACT_DATABASE_STATUS_CREATING,
|
|
1888
|
+
ARTIFACT_DATABASE_STATUS_READY,
|
|
1889
|
+
ARTIFACT_DATABASE_STATUS_FAILED,
|
|
1890
|
+
ARTIFACT_DATABASE_STATUS_DELETING,
|
|
1891
|
+
ARTIFACT_DATABASE_STATUS_PURGING,
|
|
1892
|
+
ARTIFACT_DATABASE_STATUS_DELETED
|
|
1893
|
+
];
|
|
1894
|
+
// A purge that claimed a row and never finished (the Worker died) is picked
|
|
1895
|
+
// up again after this long.
|
|
1896
|
+
const DATA_PURGE_STALE_MS = 60 * 60 * 1000;
|
|
1897
|
+
// Rows purged per hourly run: each is a call to its database object.
|
|
1898
|
+
const DATA_PURGE_BATCH = 20;
|
|
1899
|
+
// last_read_at / last_write_at move at most this often, so they aren't a
|
|
1900
|
+
// Postgres write per query.
|
|
1901
|
+
const DATA_ACTIVITY_THROTTLE_MS = 60 * 60 * 1000;
|
|
1839
1902
|
const PLAN_LIMITS = {
|
|
1840
1903
|
FREE: {
|
|
1841
1904
|
maxProjects: 1,
|
|
@@ -1871,7 +1934,11 @@ const PLAN_LIMITS = {
|
|
|
1871
1934
|
toolCallHardCap: 10_000,
|
|
1872
1935
|
includedMessages: 100,
|
|
1873
1936
|
includedEmbeddedBytes: 5 * MB,
|
|
1874
|
-
autoSyncIntervals: []
|
|
1937
|
+
autoSyncIntervals: [],
|
|
1938
|
+
canUseData: false,
|
|
1939
|
+
maxDataBytes: null,
|
|
1940
|
+
maxDataTablesPerDatabase: null,
|
|
1941
|
+
triggerRunHardCap: 0
|
|
1875
1942
|
},
|
|
1876
1943
|
PRO: {
|
|
1877
1944
|
maxProjects: null,
|
|
@@ -1898,7 +1965,11 @@ const PLAN_LIMITS = {
|
|
|
1898
1965
|
autoSyncIntervals: [
|
|
1899
1966
|
RESOURCE_SYNC_INTERVAL_DAILY,
|
|
1900
1967
|
RESOURCE_SYNC_INTERVAL_WEEKLY
|
|
1901
|
-
]
|
|
1968
|
+
],
|
|
1969
|
+
canUseData: true,
|
|
1970
|
+
maxDataBytes: DATA_MAX_DATABASE_BYTES,
|
|
1971
|
+
maxDataTablesPerDatabase: DATA_MAX_TABLES_PER_DATABASE,
|
|
1972
|
+
triggerRunHardCap: DATA_TRIGGER_RUN_HARD_CAP
|
|
1902
1973
|
},
|
|
1903
1974
|
ENTERPRISE: {
|
|
1904
1975
|
maxProjects: null,
|
|
@@ -1925,7 +1996,11 @@ const PLAN_LIMITS = {
|
|
|
1925
1996
|
autoSyncIntervals: [
|
|
1926
1997
|
RESOURCE_SYNC_INTERVAL_DAILY,
|
|
1927
1998
|
RESOURCE_SYNC_INTERVAL_WEEKLY
|
|
1928
|
-
]
|
|
1999
|
+
],
|
|
2000
|
+
canUseData: true,
|
|
2001
|
+
maxDataBytes: DATA_MAX_DATABASE_BYTES,
|
|
2002
|
+
maxDataTablesPerDatabase: DATA_MAX_TABLES_PER_DATABASE,
|
|
2003
|
+
triggerRunHardCap: null
|
|
1929
2004
|
}
|
|
1930
2005
|
};
|
|
1931
2006
|
// Quota features — used as the `feature` discriminator on PlanLimitError so the
|
|
@@ -1944,6 +2019,7 @@ const PLAN_FEATURE_EMBEDDED_STORAGE = 'embeddedStorage';
|
|
|
1944
2019
|
const PLAN_FEATURE_MESSAGE = 'message';
|
|
1945
2020
|
const PLAN_FEATURE_TOOL_CALL = 'toolCall';
|
|
1946
2021
|
const PLAN_FEATURE_RESOURCE_SYNC = 'resourceSync';
|
|
2022
|
+
const PLAN_FEATURE_DATA = 'data';
|
|
1947
2023
|
// Stable code returned on a quota block so clients can branch on it (402).
|
|
1948
2024
|
const PLAN_LIMIT_ERROR_CODE = 'PLAN_LIMIT_EXCEEDED';
|
|
1949
2025
|
// Billing meter event names. The metering cron reports per-period OVERAGE
|
|
@@ -2098,6 +2174,20 @@ exports.constants = {
|
|
|
2098
2174
|
PRICING_TOOL_CALL_PER_M_USD,
|
|
2099
2175
|
PRICING_TOOL_CALL_HARD_CAP,
|
|
2100
2176
|
PRICING_CUSTOM_DOMAIN_USD,
|
|
2177
|
+
DATA_MAX_DATABASE_BYTES,
|
|
2178
|
+
DATA_MAX_TABLES_PER_DATABASE,
|
|
2179
|
+
DATA_TRIGGER_RUN_HARD_CAP,
|
|
2180
|
+
DATA_DELETE_GRACE_DAYS,
|
|
2181
|
+
DATA_PURGE_BATCH,
|
|
2182
|
+
DATA_ACTIVITY_THROTTLE_MS,
|
|
2183
|
+
ARTIFACT_DATABASE_STATUS_CREATING,
|
|
2184
|
+
ARTIFACT_DATABASE_STATUS_READY,
|
|
2185
|
+
ARTIFACT_DATABASE_STATUS_FAILED,
|
|
2186
|
+
ARTIFACT_DATABASE_STATUS_DELETING,
|
|
2187
|
+
ARTIFACT_DATABASE_STATUS_PURGING,
|
|
2188
|
+
ARTIFACT_DATABASE_STATUS_DELETED,
|
|
2189
|
+
DATA_PURGE_STALE_MS,
|
|
2190
|
+
ARTIFACT_DATABASE_STATUSES,
|
|
2101
2191
|
PLAN_FEATURE_ORGANIZATION,
|
|
2102
2192
|
PLAN_FEATURE_PROJECT,
|
|
2103
2193
|
PLAN_FEATURE_TOOL,
|
|
@@ -2112,6 +2202,7 @@ exports.constants = {
|
|
|
2112
2202
|
PLAN_FEATURE_MESSAGE,
|
|
2113
2203
|
PLAN_FEATURE_TOOL_CALL,
|
|
2114
2204
|
PLAN_FEATURE_RESOURCE_SYNC,
|
|
2205
|
+
PLAN_FEATURE_DATA,
|
|
2115
2206
|
PLAN_LIMIT_ERROR_CODE,
|
|
2116
2207
|
BILLING_METER_MESSAGES,
|
|
2117
2208
|
BILLING_METER_SHARED_MESSAGES,
|
|
@@ -2200,6 +2291,7 @@ exports.constants = {
|
|
|
2200
2291
|
SLACK_OAUTH_TOKEN_URL,
|
|
2201
2292
|
OAUTH_TOKEN_URLS,
|
|
2202
2293
|
CREDENTIAL_REFRESH_BUFFER_MS,
|
|
2294
|
+
CREDENTIAL_REFRESH_GIVE_UP_MS,
|
|
2203
2295
|
GOOGLE_CALENDAR_API_BASE,
|
|
2204
2296
|
GOOGLE_DRIVE_API_BASE,
|
|
2205
2297
|
GOOGLE_DRIVE_DEFAULT_PAGE_SIZE,
|
|
@@ -2235,6 +2327,7 @@ exports.constants = {
|
|
|
2235
2327
|
ONE_DRIVE_TAB_LABEL_DRIVES,
|
|
2236
2328
|
ONE_DRIVE_TAB_LABELS,
|
|
2237
2329
|
REAUTH_ERROR_CODES,
|
|
2330
|
+
OAUTH_CLIENT_ERROR_CODES,
|
|
2238
2331
|
RESOURCE_TYPE_TOOLTIP_MIN_WIDTH,
|
|
2239
2332
|
SEARCH_DEBOUNCE_MS,
|
|
2240
2333
|
GOOGLE_DRIVE_EXPORT_MIME_TYPES,
|
|
@@ -2463,6 +2556,7 @@ exports.constants = {
|
|
|
2463
2556
|
RESOURCE_SEARCH_RRF_K,
|
|
2464
2557
|
RESOURCE_SEARCH_COMMON_TERM_DIVISOR,
|
|
2465
2558
|
RESOURCE_SEARCH_COMMON_TERM_MIN,
|
|
2559
|
+
RESOURCE_SEARCH_RERANK_ENABLED,
|
|
2466
2560
|
RESOURCE_SEARCH_RERANK_CANDIDATES,
|
|
2467
2561
|
RESOURCE_SEARCH_RERANK_MODEL,
|
|
2468
2562
|
RESOURCE_SEARCH_EXACT_MAX_RESOURCES,
|
|
@@ -2611,6 +2705,7 @@ exports.constants = {
|
|
|
2611
2705
|
CUSTOM_CODE_BROKER_PATH_RESOURCES_CREATE: sdkConstants_1.CUSTOM_CODE_BROKER_PATH_RESOURCES_CREATE,
|
|
2612
2706
|
CUSTOM_CODE_BROKER_PATH_RESOURCES_DELETE: sdkConstants_1.CUSTOM_CODE_BROKER_PATH_RESOURCES_DELETE,
|
|
2613
2707
|
CUSTOM_CODE_BROKER_PATH_SEND_FILE: sdkConstants_1.CUSTOM_CODE_BROKER_PATH_SEND_FILE,
|
|
2708
|
+
CUSTOM_CODE_BROKER_PATH_DATA: sdkConstants_1.CUSTOM_CODE_BROKER_PATH_DATA,
|
|
2614
2709
|
CUSTOM_CODE_OUTBOUND_PARAM_ARTIFACT_ID,
|
|
2615
2710
|
CUSTOM_CODE_OUTBOUND_PARAM_ALLOWED_HOSTS,
|
|
2616
2711
|
CUSTOM_CODE_PLATFORM_HOSTS,
|
|
@@ -2648,10 +2743,13 @@ exports.constants = {
|
|
|
2648
2743
|
CUSTOM_CODE_RESOURCE_FILE_TOO_LARGE_MESSAGE,
|
|
2649
2744
|
RESERVED_SLUGS,
|
|
2650
2745
|
MCP_INTERNAL_HEADER,
|
|
2746
|
+
MCP_EVAL_RERANK_HEADER,
|
|
2651
2747
|
MCP_CHANNEL_ID_HEADER,
|
|
2652
2748
|
MCP_CHANNEL_PLATFORM_HEADER,
|
|
2653
2749
|
MCP_CHANNEL_CONVERSATION_HEADER,
|
|
2654
2750
|
MCP_CHANNEL_CLIENT_USER_AGENT,
|
|
2751
|
+
MCP_CHANNEL_PARTICIPANT_HEADER,
|
|
2752
|
+
MCP_CHANNEL_TIME_ZONE_HEADER,
|
|
2655
2753
|
MCP_SESSION_HEADER,
|
|
2656
2754
|
MCP_REQUEST_METHOD_INITIALIZE,
|
|
2657
2755
|
MCP_REQUEST_METHOD_PING,
|
|
@@ -23,6 +23,17 @@ export declare const mintCustomCodeToken: (payload: Omit<CustomCodeTokenPayload,
|
|
|
23
23
|
* failed.
|
|
24
24
|
*/
|
|
25
25
|
export declare const verifyCustomCodeToken: (token: string, secret: string, now?: number) => Promise<CustomCodeTokenPayload | null>;
|
|
26
|
+
export interface CustomCodeCallPayload {
|
|
27
|
+
v: string;
|
|
28
|
+
artifactId: string;
|
|
29
|
+
versionId: string;
|
|
30
|
+
tool: string;
|
|
31
|
+
exp: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const mintCustomCodeCallToken: (payload: Omit<CustomCodeCallPayload, "v" | "exp"> & {
|
|
34
|
+
ttlMs: number;
|
|
35
|
+
}, secret: string, issuedAt?: number) => Promise<string>;
|
|
36
|
+
export declare const verifyCustomCodeCallToken: (token: string, secret: string, now?: number) => Promise<CustomCodeCallPayload | null>;
|
|
26
37
|
/**
|
|
27
38
|
* The legacy dispatch-namespace script name for an artifact: `artifact_<id>`.
|
|
28
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customCodeToken.d.ts","sourceRoot":"","sources":["../src/customCodeToken.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,sBAAsB;IAGrC,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IAGnB,SAAS,EAAE,MAAM,CAAC;IAIlB,GAAG,EAAE,MAAM,CAAC;IAOZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAGlB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA0BD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,SAAS,IAAI,CAAC,sBAAsB,EAAE,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC,GAAG;IAC3D,KAAK,CAAC,EAAE,MAAM,CAA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ACX,OAAO,CAAC,sBAAsB,GAAG,IAAI,CA+DvC,CAAC;AAWF,MAAM,WAAW,qBAAqB;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAID,eAAO,MAAM,uBAAuB,GAClC,SAAS,IAAI,CAAC,qBAAqB,EAAE,GAAG,GAAG,KAAK,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EACrE,QAAQ,MAAM,EACd,WAAU,MAAmB,KAC5B,OAAO,CAAC,MAAM,CAahB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,MAAK,MAAmB,KACvB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CA8BtC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,KAAG,MACE,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAI,YAAY,MAAM,KAAG,MACoB,CAAC;AAEtF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,KAAG,MACR,CAAC;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GAAI,YAAY,MAAM,KAAG,MACR,CAAC"}
|
package/dist/customCodeToken.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customCodePreviewUploadName = exports.customCodeUploadName = exports.customCodePreviewScriptName = exports.customCodeScriptName = exports.verifyCustomCodeToken = exports.mintCustomCodeToken = void 0;
|
|
3
|
+
exports.customCodePreviewUploadName = exports.customCodeUploadName = exports.customCodePreviewScriptName = exports.customCodeScriptName = exports.verifyCustomCodeCallToken = exports.mintCustomCodeCallToken = exports.verifyCustomCodeToken = exports.mintCustomCodeToken = void 0;
|
|
4
4
|
const base64_1 = require("./base64");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const encoder = new TextEncoder();
|
|
@@ -96,6 +96,46 @@ const verifyCustomCodeToken = async (token, secret, now) => {
|
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
98
|
exports.verifyCustomCodeToken = verifyCustomCodeToken;
|
|
99
|
+
const callSecret = (secret) => `${secret}:call`;
|
|
100
|
+
const mintCustomCodeCallToken = async (payload, secret, issuedAt = Date.now()) => {
|
|
101
|
+
const body = {
|
|
102
|
+
v: constants_1.constants.CUSTOM_CODE_TOKEN_VERSION,
|
|
103
|
+
artifactId: payload.artifactId,
|
|
104
|
+
versionId: payload.versionId,
|
|
105
|
+
tool: payload.tool,
|
|
106
|
+
exp: Math.ceil((issuedAt + payload.ttlMs) / 1000)
|
|
107
|
+
};
|
|
108
|
+
const encodedPayload = (0, base64_1.toBase64Url)((0, base64_1.bytesToBase64)(encoder.encode(JSON.stringify(body))));
|
|
109
|
+
const signature = await signPayload(encodedPayload, callSecret(secret));
|
|
110
|
+
return `${encodedPayload}.${signature}`;
|
|
111
|
+
};
|
|
112
|
+
exports.mintCustomCodeCallToken = mintCustomCodeCallToken;
|
|
113
|
+
const verifyCustomCodeCallToken = async (token, secret, now = Date.now()) => {
|
|
114
|
+
const separator = token.lastIndexOf('.');
|
|
115
|
+
if (separator <= 0)
|
|
116
|
+
return null;
|
|
117
|
+
const encodedPayload = token.slice(0, separator);
|
|
118
|
+
try {
|
|
119
|
+
const key = await importKey(callSecret(secret));
|
|
120
|
+
const valid = await crypto.subtle.verify('HMAC', key, new Uint8Array((0, base64_1.base64ToBytes)((0, base64_1.fromBase64Url)(token.slice(separator + 1)))), encoder.encode(encodedPayload));
|
|
121
|
+
if (!valid)
|
|
122
|
+
return null;
|
|
123
|
+
const candidate = JSON.parse(new TextDecoder().decode((0, base64_1.base64ToBytes)((0, base64_1.fromBase64Url)(encodedPayload))));
|
|
124
|
+
if (candidate.v !== constants_1.constants.CUSTOM_CODE_TOKEN_VERSION ||
|
|
125
|
+
typeof candidate.artifactId !== 'string' ||
|
|
126
|
+
typeof candidate.versionId !== 'string' ||
|
|
127
|
+
typeof candidate.tool !== 'string' ||
|
|
128
|
+
typeof candidate.exp !== 'number' ||
|
|
129
|
+
candidate.exp * 1000 <= now) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return candidate;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
exports.verifyCustomCodeCallToken = verifyCustomCodeCallToken;
|
|
99
139
|
/**
|
|
100
140
|
* The legacy dispatch-namespace script name for an artifact: `artifact_<id>`.
|
|
101
141
|
*
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './dataTypes';
|
|
2
|
+
export { DATA_IDENTIFIER_PATTERN, DATA_SYSTEM_COLUMNS, DATA_HIDDEN_COLUMNS, identifierIssue, isValidIdentifier } from './dataIdentifiers';
|
|
3
|
+
export { createTableSql, columnDefinitionSql, desiredIndexes, desiredTriggers, ftsCreateSql, ftsTableName, searchableColumns, sqlLiteral } from './dataDdl';
|
|
4
|
+
export { chunkRows, rowsPerInsert, ftsMatch, keysetCondition, encodeCursor, decodeCursor, isSensitiveWrite, tidyArgs, zoned } from './dataCompiler';
|
|
5
|
+
export type { SqlValue, KeysetCursor, SortKey } from './dataCompiler';
|
|
6
|
+
export { INTERNAL_MIGRATIONS, INTERNAL_SCHEMA_VERSION, hasInternalTables, getMeta, setMeta, migrateInternal, loadSchema, toTableInput, normaliseColumn, translateSqliteError, describe, query, write, rowHistory, pruneHistory, deleteImpact, createTable, updateTable, dropTable, addColumn, updateColumn, dropColumn, columnChangeNeedsRebuild, dropColumnNeedsRebuild, readTableCopy, clearFailedTableCopy, copyTableStep, writeReachesCopy, assertActor, assertWritable, exportRows } from './dataEngine';
|
|
7
|
+
export type { SqlRow, SqlRunner } from './dataEngine';
|
|
8
|
+
export { DATA_QUERY_PARAM_TYPES, DATA_MAX_QUERIES, DATA_MAX_QUERY_SQL, DATA_MAX_QUERY_PARAMS, DATA_DEFAULT_QUERY_ROWS, compileQuerySql, checkQueryPlan, listQueries, queriesFor, saveQuery, dropQuery, runQuery } from './dataQueries';
|
|
9
|
+
export type { DataQuery, DataQueryInput, DataQueryParam, DataQueryParamType } from './dataQueries';
|
|
10
|
+
export type { ProjectDatabaseRpc, DatabaseInfo, ExportFile, ExportFormat, ExportState, RestoreResult } from './dataRpc';
|
|
11
|
+
export { DATA_TOOL_DESCRIBE, DATA_TOOL_QUERY, DATA_TOOL_WRITE, DATA_TOOL_ADMIN, DATA_TOOL_NAMES, DATA_TOOL_TITLES, DATA_TOOL_MAX_LIMIT, DATA_ADMIN_ACTIONS, hasDataToolTables, dataToolDefinitions, dataAdminToolDefinition } from './dataTools';
|
|
12
|
+
export type { DataToolDefinition, DataAdminAction } from './dataTools';
|
|
13
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,KAAK,EACN,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,eAAe,EACf,UAAU,EACV,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,KAAK,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,UAAU,EACX,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACT,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.writeReachesCopy = exports.copyTableStep = exports.clearFailedTableCopy = exports.readTableCopy = exports.dropColumnNeedsRebuild = exports.columnChangeNeedsRebuild = exports.dropColumn = exports.updateColumn = exports.addColumn = exports.dropTable = exports.updateTable = exports.createTable = exports.deleteImpact = exports.pruneHistory = exports.rowHistory = exports.write = exports.query = exports.describe = exports.translateSqliteError = exports.normaliseColumn = exports.toTableInput = exports.loadSchema = exports.migrateInternal = exports.setMeta = exports.getMeta = exports.hasInternalTables = exports.INTERNAL_SCHEMA_VERSION = exports.INTERNAL_MIGRATIONS = exports.zoned = exports.tidyArgs = exports.isSensitiveWrite = exports.decodeCursor = exports.encodeCursor = exports.keysetCondition = exports.ftsMatch = exports.rowsPerInsert = exports.chunkRows = exports.sqlLiteral = exports.searchableColumns = exports.ftsTableName = exports.ftsCreateSql = exports.desiredTriggers = exports.desiredIndexes = exports.columnDefinitionSql = exports.createTableSql = exports.isValidIdentifier = exports.identifierIssue = exports.DATA_HIDDEN_COLUMNS = exports.DATA_SYSTEM_COLUMNS = exports.DATA_IDENTIFIER_PATTERN = void 0;
|
|
18
|
+
exports.dataAdminToolDefinition = exports.dataToolDefinitions = exports.hasDataToolTables = exports.DATA_ADMIN_ACTIONS = exports.DATA_TOOL_MAX_LIMIT = exports.DATA_TOOL_TITLES = exports.DATA_TOOL_NAMES = exports.DATA_TOOL_ADMIN = exports.DATA_TOOL_WRITE = exports.DATA_TOOL_QUERY = exports.DATA_TOOL_DESCRIBE = exports.runQuery = exports.dropQuery = exports.saveQuery = exports.queriesFor = exports.listQueries = exports.checkQueryPlan = exports.compileQuerySql = exports.DATA_DEFAULT_QUERY_ROWS = exports.DATA_MAX_QUERY_PARAMS = exports.DATA_MAX_QUERY_SQL = exports.DATA_MAX_QUERIES = exports.DATA_QUERY_PARAM_TYPES = exports.exportRows = exports.assertWritable = exports.assertActor = void 0;
|
|
19
|
+
// Entry point for `@ganju/utils/data`: everything a project's database and
|
|
20
|
+
// its callers share, without pulling in the rest of the package.
|
|
21
|
+
__exportStar(require("./dataTypes"), exports);
|
|
22
|
+
var dataIdentifiers_1 = require("./dataIdentifiers");
|
|
23
|
+
Object.defineProperty(exports, "DATA_IDENTIFIER_PATTERN", { enumerable: true, get: function () { return dataIdentifiers_1.DATA_IDENTIFIER_PATTERN; } });
|
|
24
|
+
Object.defineProperty(exports, "DATA_SYSTEM_COLUMNS", { enumerable: true, get: function () { return dataIdentifiers_1.DATA_SYSTEM_COLUMNS; } });
|
|
25
|
+
Object.defineProperty(exports, "DATA_HIDDEN_COLUMNS", { enumerable: true, get: function () { return dataIdentifiers_1.DATA_HIDDEN_COLUMNS; } });
|
|
26
|
+
Object.defineProperty(exports, "identifierIssue", { enumerable: true, get: function () { return dataIdentifiers_1.identifierIssue; } });
|
|
27
|
+
Object.defineProperty(exports, "isValidIdentifier", { enumerable: true, get: function () { return dataIdentifiers_1.isValidIdentifier; } });
|
|
28
|
+
var dataDdl_1 = require("./dataDdl");
|
|
29
|
+
Object.defineProperty(exports, "createTableSql", { enumerable: true, get: function () { return dataDdl_1.createTableSql; } });
|
|
30
|
+
Object.defineProperty(exports, "columnDefinitionSql", { enumerable: true, get: function () { return dataDdl_1.columnDefinitionSql; } });
|
|
31
|
+
Object.defineProperty(exports, "desiredIndexes", { enumerable: true, get: function () { return dataDdl_1.desiredIndexes; } });
|
|
32
|
+
Object.defineProperty(exports, "desiredTriggers", { enumerable: true, get: function () { return dataDdl_1.desiredTriggers; } });
|
|
33
|
+
Object.defineProperty(exports, "ftsCreateSql", { enumerable: true, get: function () { return dataDdl_1.ftsCreateSql; } });
|
|
34
|
+
Object.defineProperty(exports, "ftsTableName", { enumerable: true, get: function () { return dataDdl_1.ftsTableName; } });
|
|
35
|
+
Object.defineProperty(exports, "searchableColumns", { enumerable: true, get: function () { return dataDdl_1.searchableColumns; } });
|
|
36
|
+
Object.defineProperty(exports, "sqlLiteral", { enumerable: true, get: function () { return dataDdl_1.sqlLiteral; } });
|
|
37
|
+
var dataCompiler_1 = require("./dataCompiler");
|
|
38
|
+
Object.defineProperty(exports, "chunkRows", { enumerable: true, get: function () { return dataCompiler_1.chunkRows; } });
|
|
39
|
+
Object.defineProperty(exports, "rowsPerInsert", { enumerable: true, get: function () { return dataCompiler_1.rowsPerInsert; } });
|
|
40
|
+
Object.defineProperty(exports, "ftsMatch", { enumerable: true, get: function () { return dataCompiler_1.ftsMatch; } });
|
|
41
|
+
Object.defineProperty(exports, "keysetCondition", { enumerable: true, get: function () { return dataCompiler_1.keysetCondition; } });
|
|
42
|
+
Object.defineProperty(exports, "encodeCursor", { enumerable: true, get: function () { return dataCompiler_1.encodeCursor; } });
|
|
43
|
+
Object.defineProperty(exports, "decodeCursor", { enumerable: true, get: function () { return dataCompiler_1.decodeCursor; } });
|
|
44
|
+
Object.defineProperty(exports, "isSensitiveWrite", { enumerable: true, get: function () { return dataCompiler_1.isSensitiveWrite; } });
|
|
45
|
+
Object.defineProperty(exports, "tidyArgs", { enumerable: true, get: function () { return dataCompiler_1.tidyArgs; } });
|
|
46
|
+
Object.defineProperty(exports, "zoned", { enumerable: true, get: function () { return dataCompiler_1.zoned; } });
|
|
47
|
+
var dataEngine_1 = require("./dataEngine");
|
|
48
|
+
Object.defineProperty(exports, "INTERNAL_MIGRATIONS", { enumerable: true, get: function () { return dataEngine_1.INTERNAL_MIGRATIONS; } });
|
|
49
|
+
Object.defineProperty(exports, "INTERNAL_SCHEMA_VERSION", { enumerable: true, get: function () { return dataEngine_1.INTERNAL_SCHEMA_VERSION; } });
|
|
50
|
+
Object.defineProperty(exports, "hasInternalTables", { enumerable: true, get: function () { return dataEngine_1.hasInternalTables; } });
|
|
51
|
+
Object.defineProperty(exports, "getMeta", { enumerable: true, get: function () { return dataEngine_1.getMeta; } });
|
|
52
|
+
Object.defineProperty(exports, "setMeta", { enumerable: true, get: function () { return dataEngine_1.setMeta; } });
|
|
53
|
+
Object.defineProperty(exports, "migrateInternal", { enumerable: true, get: function () { return dataEngine_1.migrateInternal; } });
|
|
54
|
+
Object.defineProperty(exports, "loadSchema", { enumerable: true, get: function () { return dataEngine_1.loadSchema; } });
|
|
55
|
+
Object.defineProperty(exports, "toTableInput", { enumerable: true, get: function () { return dataEngine_1.toTableInput; } });
|
|
56
|
+
Object.defineProperty(exports, "normaliseColumn", { enumerable: true, get: function () { return dataEngine_1.normaliseColumn; } });
|
|
57
|
+
Object.defineProperty(exports, "translateSqliteError", { enumerable: true, get: function () { return dataEngine_1.translateSqliteError; } });
|
|
58
|
+
Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return dataEngine_1.describe; } });
|
|
59
|
+
Object.defineProperty(exports, "query", { enumerable: true, get: function () { return dataEngine_1.query; } });
|
|
60
|
+
Object.defineProperty(exports, "write", { enumerable: true, get: function () { return dataEngine_1.write; } });
|
|
61
|
+
Object.defineProperty(exports, "rowHistory", { enumerable: true, get: function () { return dataEngine_1.rowHistory; } });
|
|
62
|
+
Object.defineProperty(exports, "pruneHistory", { enumerable: true, get: function () { return dataEngine_1.pruneHistory; } });
|
|
63
|
+
Object.defineProperty(exports, "deleteImpact", { enumerable: true, get: function () { return dataEngine_1.deleteImpact; } });
|
|
64
|
+
Object.defineProperty(exports, "createTable", { enumerable: true, get: function () { return dataEngine_1.createTable; } });
|
|
65
|
+
Object.defineProperty(exports, "updateTable", { enumerable: true, get: function () { return dataEngine_1.updateTable; } });
|
|
66
|
+
Object.defineProperty(exports, "dropTable", { enumerable: true, get: function () { return dataEngine_1.dropTable; } });
|
|
67
|
+
Object.defineProperty(exports, "addColumn", { enumerable: true, get: function () { return dataEngine_1.addColumn; } });
|
|
68
|
+
Object.defineProperty(exports, "updateColumn", { enumerable: true, get: function () { return dataEngine_1.updateColumn; } });
|
|
69
|
+
Object.defineProperty(exports, "dropColumn", { enumerable: true, get: function () { return dataEngine_1.dropColumn; } });
|
|
70
|
+
Object.defineProperty(exports, "columnChangeNeedsRebuild", { enumerable: true, get: function () { return dataEngine_1.columnChangeNeedsRebuild; } });
|
|
71
|
+
Object.defineProperty(exports, "dropColumnNeedsRebuild", { enumerable: true, get: function () { return dataEngine_1.dropColumnNeedsRebuild; } });
|
|
72
|
+
Object.defineProperty(exports, "readTableCopy", { enumerable: true, get: function () { return dataEngine_1.readTableCopy; } });
|
|
73
|
+
Object.defineProperty(exports, "clearFailedTableCopy", { enumerable: true, get: function () { return dataEngine_1.clearFailedTableCopy; } });
|
|
74
|
+
Object.defineProperty(exports, "copyTableStep", { enumerable: true, get: function () { return dataEngine_1.copyTableStep; } });
|
|
75
|
+
Object.defineProperty(exports, "writeReachesCopy", { enumerable: true, get: function () { return dataEngine_1.writeReachesCopy; } });
|
|
76
|
+
Object.defineProperty(exports, "assertActor", { enumerable: true, get: function () { return dataEngine_1.assertActor; } });
|
|
77
|
+
Object.defineProperty(exports, "assertWritable", { enumerable: true, get: function () { return dataEngine_1.assertWritable; } });
|
|
78
|
+
Object.defineProperty(exports, "exportRows", { enumerable: true, get: function () { return dataEngine_1.exportRows; } });
|
|
79
|
+
var dataQueries_1 = require("./dataQueries");
|
|
80
|
+
Object.defineProperty(exports, "DATA_QUERY_PARAM_TYPES", { enumerable: true, get: function () { return dataQueries_1.DATA_QUERY_PARAM_TYPES; } });
|
|
81
|
+
Object.defineProperty(exports, "DATA_MAX_QUERIES", { enumerable: true, get: function () { return dataQueries_1.DATA_MAX_QUERIES; } });
|
|
82
|
+
Object.defineProperty(exports, "DATA_MAX_QUERY_SQL", { enumerable: true, get: function () { return dataQueries_1.DATA_MAX_QUERY_SQL; } });
|
|
83
|
+
Object.defineProperty(exports, "DATA_MAX_QUERY_PARAMS", { enumerable: true, get: function () { return dataQueries_1.DATA_MAX_QUERY_PARAMS; } });
|
|
84
|
+
Object.defineProperty(exports, "DATA_DEFAULT_QUERY_ROWS", { enumerable: true, get: function () { return dataQueries_1.DATA_DEFAULT_QUERY_ROWS; } });
|
|
85
|
+
Object.defineProperty(exports, "compileQuerySql", { enumerable: true, get: function () { return dataQueries_1.compileQuerySql; } });
|
|
86
|
+
Object.defineProperty(exports, "checkQueryPlan", { enumerable: true, get: function () { return dataQueries_1.checkQueryPlan; } });
|
|
87
|
+
Object.defineProperty(exports, "listQueries", { enumerable: true, get: function () { return dataQueries_1.listQueries; } });
|
|
88
|
+
Object.defineProperty(exports, "queriesFor", { enumerable: true, get: function () { return dataQueries_1.queriesFor; } });
|
|
89
|
+
Object.defineProperty(exports, "saveQuery", { enumerable: true, get: function () { return dataQueries_1.saveQuery; } });
|
|
90
|
+
Object.defineProperty(exports, "dropQuery", { enumerable: true, get: function () { return dataQueries_1.dropQuery; } });
|
|
91
|
+
Object.defineProperty(exports, "runQuery", { enumerable: true, get: function () { return dataQueries_1.runQuery; } });
|
|
92
|
+
var dataTools_1 = require("./dataTools");
|
|
93
|
+
Object.defineProperty(exports, "DATA_TOOL_DESCRIBE", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_DESCRIBE; } });
|
|
94
|
+
Object.defineProperty(exports, "DATA_TOOL_QUERY", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_QUERY; } });
|
|
95
|
+
Object.defineProperty(exports, "DATA_TOOL_WRITE", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_WRITE; } });
|
|
96
|
+
Object.defineProperty(exports, "DATA_TOOL_ADMIN", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_ADMIN; } });
|
|
97
|
+
Object.defineProperty(exports, "DATA_TOOL_NAMES", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_NAMES; } });
|
|
98
|
+
Object.defineProperty(exports, "DATA_TOOL_TITLES", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_TITLES; } });
|
|
99
|
+
Object.defineProperty(exports, "DATA_TOOL_MAX_LIMIT", { enumerable: true, get: function () { return dataTools_1.DATA_TOOL_MAX_LIMIT; } });
|
|
100
|
+
Object.defineProperty(exports, "DATA_ADMIN_ACTIONS", { enumerable: true, get: function () { return dataTools_1.DATA_ADMIN_ACTIONS; } });
|
|
101
|
+
Object.defineProperty(exports, "hasDataToolTables", { enumerable: true, get: function () { return dataTools_1.hasDataToolTables; } });
|
|
102
|
+
Object.defineProperty(exports, "dataToolDefinitions", { enumerable: true, get: function () { return dataTools_1.dataToolDefinitions; } });
|
|
103
|
+
Object.defineProperty(exports, "dataAdminToolDefinition", { enumerable: true, get: function () { return dataTools_1.dataAdminToolDefinition; } });
|