@ganju/utils 0.0.15 → 0.0.16
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 +23 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +95 -8
- package/dist/data.d.ts +9 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +78 -0
- package/dist/dataApi.d.ts +511 -0
- package/dist/dataApi.d.ts.map +1 -0
- package/dist/dataApi.js +355 -0
- package/dist/dataCompiler.d.ts +68 -0
- package/dist/dataCompiler.d.ts.map +1 -0
- package/dist/dataCompiler.js +726 -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 +2022 -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 +77 -0
- package/dist/dataImport.d.ts.map +1 -0
- package/dist/dataImport.js +450 -0
- package/dist/dataRpc.d.ts +131 -0
- package/dist/dataRpc.d.ts.map +1 -0
- package/dist/dataRpc.js +2 -0
- package/dist/dataTypes.d.ts +157 -0
- package/dist/dataTypes.d.ts.map +1 -0
- package/dist/dataTypes.js +160 -0
- package/dist/index.d.ts +308 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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 +285 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +203 -0
- package/package.json +17 -2
- package/src/constants.ts +108 -8
- package/src/data.ts +74 -0
- package/src/dataApi.ts +428 -0
- package/src/dataCompiler.ts +948 -0
- package/src/dataDdl.ts +419 -0
- package/src/dataEngine.ts +2753 -0
- package/src/dataIdentifiers.ts +63 -0
- package/src/dataImport.ts +554 -0
- package/src/dataRpc.ts +121 -0
- package/src/dataTypes.ts +312 -0
- package/src/index.ts +4 -0
- package/src/oauth.ts +42 -1
- package/src/resourceRerank.ts +5 -2
- package/src/schema.ts +246 -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;
|
|
@@ -665,6 +687,7 @@ export declare const constants: {
|
|
|
665
687
|
CUSTOM_CODE_RESOURCE_FILE_TOO_LARGE_MESSAGE: string;
|
|
666
688
|
RESERVED_SLUGS: string[];
|
|
667
689
|
MCP_INTERNAL_HEADER: string;
|
|
690
|
+
MCP_EVAL_RERANK_HEADER: string;
|
|
668
691
|
MCP_CHANNEL_ID_HEADER: string;
|
|
669
692
|
MCP_CHANNEL_PLATFORM_HEADER: string;
|
|
670
693
|
MCP_CHANNEL_CONVERSATION_HEADER: string;
|
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":"AAkKA,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,C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C,OAAO,+BAA+B,GACtC,OAAO,8BAA8B,GACrC,OAAO,wBAAwB;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6lEnE,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
|
|
@@ -1568,6 +1586,10 @@ const MCP_AUTH_KIND_INTERNAL = 'internal';
|
|
|
1568
1586
|
const MCP_AUTH_KINDS = [MCP_AUTH_KIND_JWT, MCP_AUTH_KIND_INTERNAL];
|
|
1569
1587
|
const MCP_SESSION_HEADER = 'mcp-session-id';
|
|
1570
1588
|
const MCP_INTERNAL_HEADER = 'x-ganju-internal-secret';
|
|
1589
|
+
// Sent with the internal secret by the search eval to measure the reranker:
|
|
1590
|
+
// `on` or `off` overrides RESOURCE_SEARCH_RERANK_ENABLED for that request.
|
|
1591
|
+
// Ignored on any other request.
|
|
1592
|
+
const MCP_EVAL_RERANK_HEADER = 'x-ganju-eval-rerank';
|
|
1571
1593
|
const MCP_CHANNEL_ID_HEADER = 'x-ganju-channel-id';
|
|
1572
1594
|
const MCP_CHANNEL_PLATFORM_HEADER = 'x-ganju-channel-platform';
|
|
1573
1595
|
// The conversation a channel turn belongs to. The MCP worker files that turn's
|
|
@@ -1836,6 +1858,39 @@ const PRICING_TOOL_CALL_PER_M_USD = 5;
|
|
|
1836
1858
|
// million calls a month, so a fixed ceiling there would fight a real customer.
|
|
1837
1859
|
const PRICING_TOOL_CALL_HARD_CAP = 20_000_000;
|
|
1838
1860
|
const PRICING_CUSTOM_DOMAIN_USD = 15;
|
|
1861
|
+
// Project data (one SQLite Durable Object per artifact). Cloudflare caps a
|
|
1862
|
+
// database at 10 GB; we stop writes that add data at 9 GB so there is room to
|
|
1863
|
+
// delete, archive and export.
|
|
1864
|
+
const DATA_MAX_DATABASE_BYTES = 9 * GB;
|
|
1865
|
+
const DATA_MAX_TABLES_PER_DATABASE = 50;
|
|
1866
|
+
const DATA_TRIGGER_RUN_HARD_CAP = 5_000_000;
|
|
1867
|
+
// A deleted database can be restored for this long before its storage is
|
|
1868
|
+
// freed.
|
|
1869
|
+
const DATA_DELETE_GRACE_DAYS = 7;
|
|
1870
|
+
const ARTIFACT_DATABASE_STATUS_CREATING = 'CREATING';
|
|
1871
|
+
const ARTIFACT_DATABASE_STATUS_READY = 'READY';
|
|
1872
|
+
const ARTIFACT_DATABASE_STATUS_FAILED = 'FAILED';
|
|
1873
|
+
const ARTIFACT_DATABASE_STATUS_DELETING = 'DELETING';
|
|
1874
|
+
// The hourly purge has claimed the row and is emptying the object; a restore
|
|
1875
|
+
// can no longer take it back.
|
|
1876
|
+
const ARTIFACT_DATABASE_STATUS_PURGING = 'PURGING';
|
|
1877
|
+
const ARTIFACT_DATABASE_STATUS_DELETED = 'DELETED';
|
|
1878
|
+
const ARTIFACT_DATABASE_STATUSES = [
|
|
1879
|
+
ARTIFACT_DATABASE_STATUS_CREATING,
|
|
1880
|
+
ARTIFACT_DATABASE_STATUS_READY,
|
|
1881
|
+
ARTIFACT_DATABASE_STATUS_FAILED,
|
|
1882
|
+
ARTIFACT_DATABASE_STATUS_DELETING,
|
|
1883
|
+
ARTIFACT_DATABASE_STATUS_PURGING,
|
|
1884
|
+
ARTIFACT_DATABASE_STATUS_DELETED
|
|
1885
|
+
];
|
|
1886
|
+
// A purge that claimed a row and never finished (the Worker died) is picked
|
|
1887
|
+
// up again after this long.
|
|
1888
|
+
const DATA_PURGE_STALE_MS = 60 * 60 * 1000;
|
|
1889
|
+
// Rows purged per hourly run: each is a call to its database object.
|
|
1890
|
+
const DATA_PURGE_BATCH = 20;
|
|
1891
|
+
// last_read_at / last_write_at move at most this often, so they aren't a
|
|
1892
|
+
// Postgres write per query.
|
|
1893
|
+
const DATA_ACTIVITY_THROTTLE_MS = 60 * 60 * 1000;
|
|
1839
1894
|
const PLAN_LIMITS = {
|
|
1840
1895
|
FREE: {
|
|
1841
1896
|
maxProjects: 1,
|
|
@@ -1871,7 +1926,11 @@ const PLAN_LIMITS = {
|
|
|
1871
1926
|
toolCallHardCap: 10_000,
|
|
1872
1927
|
includedMessages: 100,
|
|
1873
1928
|
includedEmbeddedBytes: 5 * MB,
|
|
1874
|
-
autoSyncIntervals: []
|
|
1929
|
+
autoSyncIntervals: [],
|
|
1930
|
+
canUseData: false,
|
|
1931
|
+
maxDataBytes: null,
|
|
1932
|
+
maxDataTablesPerDatabase: null,
|
|
1933
|
+
triggerRunHardCap: 0
|
|
1875
1934
|
},
|
|
1876
1935
|
PRO: {
|
|
1877
1936
|
maxProjects: null,
|
|
@@ -1898,7 +1957,11 @@ const PLAN_LIMITS = {
|
|
|
1898
1957
|
autoSyncIntervals: [
|
|
1899
1958
|
RESOURCE_SYNC_INTERVAL_DAILY,
|
|
1900
1959
|
RESOURCE_SYNC_INTERVAL_WEEKLY
|
|
1901
|
-
]
|
|
1960
|
+
],
|
|
1961
|
+
canUseData: true,
|
|
1962
|
+
maxDataBytes: DATA_MAX_DATABASE_BYTES,
|
|
1963
|
+
maxDataTablesPerDatabase: DATA_MAX_TABLES_PER_DATABASE,
|
|
1964
|
+
triggerRunHardCap: DATA_TRIGGER_RUN_HARD_CAP
|
|
1902
1965
|
},
|
|
1903
1966
|
ENTERPRISE: {
|
|
1904
1967
|
maxProjects: null,
|
|
@@ -1925,7 +1988,11 @@ const PLAN_LIMITS = {
|
|
|
1925
1988
|
autoSyncIntervals: [
|
|
1926
1989
|
RESOURCE_SYNC_INTERVAL_DAILY,
|
|
1927
1990
|
RESOURCE_SYNC_INTERVAL_WEEKLY
|
|
1928
|
-
]
|
|
1991
|
+
],
|
|
1992
|
+
canUseData: true,
|
|
1993
|
+
maxDataBytes: DATA_MAX_DATABASE_BYTES,
|
|
1994
|
+
maxDataTablesPerDatabase: DATA_MAX_TABLES_PER_DATABASE,
|
|
1995
|
+
triggerRunHardCap: null
|
|
1929
1996
|
}
|
|
1930
1997
|
};
|
|
1931
1998
|
// Quota features — used as the `feature` discriminator on PlanLimitError so the
|
|
@@ -1944,6 +2011,7 @@ const PLAN_FEATURE_EMBEDDED_STORAGE = 'embeddedStorage';
|
|
|
1944
2011
|
const PLAN_FEATURE_MESSAGE = 'message';
|
|
1945
2012
|
const PLAN_FEATURE_TOOL_CALL = 'toolCall';
|
|
1946
2013
|
const PLAN_FEATURE_RESOURCE_SYNC = 'resourceSync';
|
|
2014
|
+
const PLAN_FEATURE_DATA = 'data';
|
|
1947
2015
|
// Stable code returned on a quota block so clients can branch on it (402).
|
|
1948
2016
|
const PLAN_LIMIT_ERROR_CODE = 'PLAN_LIMIT_EXCEEDED';
|
|
1949
2017
|
// Billing meter event names. The metering cron reports per-period OVERAGE
|
|
@@ -2098,6 +2166,20 @@ exports.constants = {
|
|
|
2098
2166
|
PRICING_TOOL_CALL_PER_M_USD,
|
|
2099
2167
|
PRICING_TOOL_CALL_HARD_CAP,
|
|
2100
2168
|
PRICING_CUSTOM_DOMAIN_USD,
|
|
2169
|
+
DATA_MAX_DATABASE_BYTES,
|
|
2170
|
+
DATA_MAX_TABLES_PER_DATABASE,
|
|
2171
|
+
DATA_TRIGGER_RUN_HARD_CAP,
|
|
2172
|
+
DATA_DELETE_GRACE_DAYS,
|
|
2173
|
+
DATA_PURGE_BATCH,
|
|
2174
|
+
DATA_ACTIVITY_THROTTLE_MS,
|
|
2175
|
+
ARTIFACT_DATABASE_STATUS_CREATING,
|
|
2176
|
+
ARTIFACT_DATABASE_STATUS_READY,
|
|
2177
|
+
ARTIFACT_DATABASE_STATUS_FAILED,
|
|
2178
|
+
ARTIFACT_DATABASE_STATUS_DELETING,
|
|
2179
|
+
ARTIFACT_DATABASE_STATUS_PURGING,
|
|
2180
|
+
ARTIFACT_DATABASE_STATUS_DELETED,
|
|
2181
|
+
DATA_PURGE_STALE_MS,
|
|
2182
|
+
ARTIFACT_DATABASE_STATUSES,
|
|
2101
2183
|
PLAN_FEATURE_ORGANIZATION,
|
|
2102
2184
|
PLAN_FEATURE_PROJECT,
|
|
2103
2185
|
PLAN_FEATURE_TOOL,
|
|
@@ -2112,6 +2194,7 @@ exports.constants = {
|
|
|
2112
2194
|
PLAN_FEATURE_MESSAGE,
|
|
2113
2195
|
PLAN_FEATURE_TOOL_CALL,
|
|
2114
2196
|
PLAN_FEATURE_RESOURCE_SYNC,
|
|
2197
|
+
PLAN_FEATURE_DATA,
|
|
2115
2198
|
PLAN_LIMIT_ERROR_CODE,
|
|
2116
2199
|
BILLING_METER_MESSAGES,
|
|
2117
2200
|
BILLING_METER_SHARED_MESSAGES,
|
|
@@ -2200,6 +2283,7 @@ exports.constants = {
|
|
|
2200
2283
|
SLACK_OAUTH_TOKEN_URL,
|
|
2201
2284
|
OAUTH_TOKEN_URLS,
|
|
2202
2285
|
CREDENTIAL_REFRESH_BUFFER_MS,
|
|
2286
|
+
CREDENTIAL_REFRESH_GIVE_UP_MS,
|
|
2203
2287
|
GOOGLE_CALENDAR_API_BASE,
|
|
2204
2288
|
GOOGLE_DRIVE_API_BASE,
|
|
2205
2289
|
GOOGLE_DRIVE_DEFAULT_PAGE_SIZE,
|
|
@@ -2235,6 +2319,7 @@ exports.constants = {
|
|
|
2235
2319
|
ONE_DRIVE_TAB_LABEL_DRIVES,
|
|
2236
2320
|
ONE_DRIVE_TAB_LABELS,
|
|
2237
2321
|
REAUTH_ERROR_CODES,
|
|
2322
|
+
OAUTH_CLIENT_ERROR_CODES,
|
|
2238
2323
|
RESOURCE_TYPE_TOOLTIP_MIN_WIDTH,
|
|
2239
2324
|
SEARCH_DEBOUNCE_MS,
|
|
2240
2325
|
GOOGLE_DRIVE_EXPORT_MIME_TYPES,
|
|
@@ -2463,6 +2548,7 @@ exports.constants = {
|
|
|
2463
2548
|
RESOURCE_SEARCH_RRF_K,
|
|
2464
2549
|
RESOURCE_SEARCH_COMMON_TERM_DIVISOR,
|
|
2465
2550
|
RESOURCE_SEARCH_COMMON_TERM_MIN,
|
|
2551
|
+
RESOURCE_SEARCH_RERANK_ENABLED,
|
|
2466
2552
|
RESOURCE_SEARCH_RERANK_CANDIDATES,
|
|
2467
2553
|
RESOURCE_SEARCH_RERANK_MODEL,
|
|
2468
2554
|
RESOURCE_SEARCH_EXACT_MAX_RESOURCES,
|
|
@@ -2648,6 +2734,7 @@ exports.constants = {
|
|
|
2648
2734
|
CUSTOM_CODE_RESOURCE_FILE_TOO_LARGE_MESSAGE,
|
|
2649
2735
|
RESERVED_SLUGS,
|
|
2650
2736
|
MCP_INTERNAL_HEADER,
|
|
2737
|
+
MCP_EVAL_RERANK_HEADER,
|
|
2651
2738
|
MCP_CHANNEL_ID_HEADER,
|
|
2652
2739
|
MCP_CHANNEL_PLATFORM_HEADER,
|
|
2653
2740
|
MCP_CHANNEL_CONVERSATION_HEADER,
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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 type { ProjectDatabaseRpc, DatabaseInfo, ExportFile, ExportFormat, ExportState, RestoreResult } from './dataRpc';
|
|
9
|
+
//# 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,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACd,MAAM,WAAW,CAAC"}
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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.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; } });
|