@ganju/utils 0.0.20 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/constants.d.ts +16 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +43 -0
  4. package/dist/data.d.ts +6 -4
  5. package/dist/data.d.ts.map +1 -1
  6. package/dist/data.js +13 -3
  7. package/dist/dataApi.d.ts +50 -4
  8. package/dist/dataApi.d.ts.map +1 -1
  9. package/dist/dataApi.js +36 -3
  10. package/dist/dataAttachment.d.ts +8 -0
  11. package/dist/dataAttachment.d.ts.map +1 -0
  12. package/dist/dataAttachment.js +19 -0
  13. package/dist/dataCompiler.d.ts +3 -0
  14. package/dist/dataCompiler.d.ts.map +1 -1
  15. package/dist/dataCompiler.js +25 -1
  16. package/dist/dataDdl.d.ts.map +1 -1
  17. package/dist/dataDdl.js +5 -0
  18. package/dist/dataEngine.d.ts +9 -3
  19. package/dist/dataEngine.d.ts.map +1 -1
  20. package/dist/dataEngine.js +141 -5
  21. package/dist/dataIndexAdvice.d.ts +36 -0
  22. package/dist/dataIndexAdvice.d.ts.map +1 -0
  23. package/dist/dataIndexAdvice.js +89 -0
  24. package/dist/dataRpc.d.ts +12 -1
  25. package/dist/dataRpc.d.ts.map +1 -1
  26. package/dist/dataTools.js +3 -3
  27. package/dist/dataTriggers.d.ts +23 -0
  28. package/dist/dataTriggers.d.ts.map +1 -1
  29. package/dist/dataTriggers.js +46 -2
  30. package/dist/dataTypes.d.ts +46 -0
  31. package/dist/dataTypes.d.ts.map +1 -1
  32. package/dist/dataTypes.js +7 -1
  33. package/dist/index.d.ts +56 -3
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +6 -0
  36. package/dist/localizeDataError.d.ts.map +1 -1
  37. package/dist/localizeDataError.js +64 -2
  38. package/dist/schema.d.ts +34 -2
  39. package/dist/schema.d.ts.map +1 -1
  40. package/dist/schema.js +32 -0
  41. package/dist/whatsappWebhook.d.ts +28 -0
  42. package/dist/whatsappWebhook.d.ts.map +1 -0
  43. package/dist/whatsappWebhook.js +30 -0
  44. package/package.json +1 -1
  45. package/src/constants.ts +46 -0
  46. package/src/data.ts +14 -0
  47. package/src/dataApi.ts +40 -2
  48. package/src/dataAttachment.ts +23 -0
  49. package/src/dataCompiler.ts +37 -0
  50. package/src/dataDdl.ts +7 -0
  51. package/src/dataEngine.ts +195 -5
  52. package/src/dataIndexAdvice.ts +127 -0
  53. package/src/dataRpc.ts +17 -1
  54. package/src/dataTools.ts +3 -3
  55. package/src/dataTriggers.ts +71 -1
  56. package/src/dataTypes.ts +62 -0
  57. package/src/index.ts +11 -0
  58. package/src/localizeDataError.ts +101 -3
  59. package/src/schema.ts +34 -0
  60. package/src/whatsappWebhook.ts +55 -0
@@ -105,6 +105,22 @@ export declare const constants: {
105
105
  DATA_DELETE_GRACE_DAYS: number;
106
106
  DATA_PURGE_BATCH: number;
107
107
  DATA_ACTIVITY_THROTTLE_MS: number;
108
+ DATA_INDEX_ADVICE_WINDOW_DAYS: number;
109
+ DATA_INDEX_ADVICE_MIN_QUERIES: number;
110
+ DATA_INDEX_ADVICE_MIN_ROWS_READ: number;
111
+ DATA_INDEX_ADVICE_MIN_READ_RATIO: number;
112
+ DATA_INDEX_UNUSED_WINDOW_DAYS: number;
113
+ DATA_INDEX_UNUSED_MIN_ROWS_WRITTEN: number;
114
+ DATA_QUERY_STAT_KEEP_DAYS: number;
115
+ DATA_INDEX_ADVICE_ADD: "add";
116
+ DATA_INDEX_ADVICE_UNUSED: "unused";
117
+ DATA_INDEX_ADVICE_OPEN: "open";
118
+ DATA_INDEX_ADVICE_DISMISSED: "dismissed";
119
+ DATA_DAILY_JOB_HOUR_UTC: number;
120
+ DATA_ABANDON_WARN_DAYS: number;
121
+ DATA_ABANDON_REMIND_DAYS: number;
122
+ DATA_ABANDON_DELETE_DAYS: number;
123
+ DATA_ABANDON_EXPORT_KEEP_DAYS: number;
108
124
  ARTIFACT_DATABASE_STATUS_CREATING: "CREATING";
109
125
  ARTIFACT_DATABASE_STATUS_READY: "READY";
110
126
  ARTIFACT_DATABASE_STATUS_FAILED: "FAILED";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAsKA,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;AAClD,QAAA,MAAM,oBAAoB,EAAe,QAAQ,CAAC;AA+FlD,QAAA,MAAM,4BAA4B,EAAc,OAAO,CAAC;AACxD,QAAA,MAAM,6BAA6B,EAAe,QAAQ,CAAC;AA2V3D,QAAA,MAAM,sBAAsB,EAAkB,WAAW,CAAC;AAC1D,QAAA,MAAM,mBAAmB,EAAe,QAAQ,CAAC;AAGjD,QAAA,MAAM,mBAAmB,EAAe,QAAQ,CAAC;AAocjD,MAAM,MAAM,mBAAmB,GAC3B;IACE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC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M,GAAG,MAAM;cAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2qEnE,CAAC"}
package/dist/constants.js CHANGED
@@ -1899,6 +1899,33 @@ const DATA_PURGE_BATCH = 20;
1899
1899
  // last_read_at / last_write_at move at most this often, so they aren't a
1900
1900
  // Postgres write per query.
1901
1901
  const DATA_ACTIVITY_THROTTLE_MS = 60 * 60 * 1000;
1902
+ // Index advice. A column is worth an index when, over a week, at least 50
1903
+ // queries filtered or sorted on it and they read on average 1,000 rows and
1904
+ // 20 rows for every row returned. An index no query used in 30 days on a
1905
+ // table written at least 1,000 rows (and more rows written than queries) is
1906
+ // flagged as unused. Never dropped automatically.
1907
+ const DATA_INDEX_ADVICE_WINDOW_DAYS = 7;
1908
+ const DATA_INDEX_ADVICE_MIN_QUERIES = 50;
1909
+ const DATA_INDEX_ADVICE_MIN_ROWS_READ = 1_000;
1910
+ const DATA_INDEX_ADVICE_MIN_READ_RATIO = 20;
1911
+ const DATA_INDEX_UNUSED_WINDOW_DAYS = 30;
1912
+ const DATA_INDEX_UNUSED_MIN_ROWS_WRITTEN = 1_000;
1913
+ // Daily stats are kept past the longest window, then removed.
1914
+ const DATA_QUERY_STAT_KEEP_DAYS = 35;
1915
+ const DATA_INDEX_ADVICE_ADD = 'add';
1916
+ const DATA_INDEX_ADVICE_UNUSED = 'unused';
1917
+ const DATA_INDEX_ADVICE_OPEN = 'open';
1918
+ const DATA_INDEX_ADVICE_DISMISSED = 'dismissed';
1919
+ // The daily jobs (index advice and the abandoned-database flow) run on the
1920
+ // hourly cron at this UTC hour.
1921
+ const DATA_DAILY_JOB_HOUR_UTC = 13;
1922
+ // Days on Free before a database is warned about, reminded about, and listed
1923
+ // for Ganju to delete by hand.
1924
+ const DATA_ABANDON_WARN_DAYS = 30;
1925
+ const DATA_ABANDON_REMIND_DAYS = 41;
1926
+ const DATA_ABANDON_DELETE_DAYS = 44;
1927
+ // How long the export taken before a database is deleted is kept.
1928
+ const DATA_ABANDON_EXPORT_KEEP_DAYS = 90;
1902
1929
  const PLAN_LIMITS = {
1903
1930
  FREE: {
1904
1931
  maxProjects: 1,
@@ -2190,6 +2217,22 @@ exports.constants = {
2190
2217
  DATA_DELETE_GRACE_DAYS,
2191
2218
  DATA_PURGE_BATCH,
2192
2219
  DATA_ACTIVITY_THROTTLE_MS,
2220
+ DATA_INDEX_ADVICE_WINDOW_DAYS,
2221
+ DATA_INDEX_ADVICE_MIN_QUERIES,
2222
+ DATA_INDEX_ADVICE_MIN_ROWS_READ,
2223
+ DATA_INDEX_ADVICE_MIN_READ_RATIO,
2224
+ DATA_INDEX_UNUSED_WINDOW_DAYS,
2225
+ DATA_INDEX_UNUSED_MIN_ROWS_WRITTEN,
2226
+ DATA_QUERY_STAT_KEEP_DAYS,
2227
+ DATA_INDEX_ADVICE_ADD,
2228
+ DATA_INDEX_ADVICE_UNUSED,
2229
+ DATA_INDEX_ADVICE_OPEN,
2230
+ DATA_INDEX_ADVICE_DISMISSED,
2231
+ DATA_DAILY_JOB_HOUR_UTC,
2232
+ DATA_ABANDON_WARN_DAYS,
2233
+ DATA_ABANDON_REMIND_DAYS,
2234
+ DATA_ABANDON_DELETE_DAYS,
2235
+ DATA_ABANDON_EXPORT_KEEP_DAYS,
2193
2236
  ARTIFACT_DATABASE_STATUS_CREATING,
2194
2237
  ARTIFACT_DATABASE_STATUS_READY,
2195
2238
  ARTIFACT_DATABASE_STATUS_FAILED,
package/dist/data.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  export * from './dataTypes';
2
2
  export { DATA_IDENTIFIER_PATTERN, DATA_SYSTEM_COLUMNS, DATA_HIDDEN_COLUMNS, identifierIssue, isValidIdentifier } from './dataIdentifiers';
3
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';
4
+ export { chunkRows, rowsPerInsert, ftsMatch, keysetCondition, encodeCursor, decodeCursor, isSensitiveWrite, fileUriOf, unknownFileUris, tidyArgs, zoned } from './dataCompiler';
5
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';
6
+ export { INTERNAL_MIGRATIONS, INTERNAL_SCHEMA_VERSION, hasInternalTables, getMeta, setMeta, migrateInternal, loadSchema, toTableInput, normaliseColumn, translateSqliteError, describe, query, write, rowHistory, pruneHistory, deleteImpact, fileLinks, replaceFileLinks, createTable, updateTable, dropTable, addColumn, updateColumn, dropColumn, columnChangeNeedsRebuild, dropColumnNeedsRebuild, readTableCopy, clearFailedTableCopy, copyTableStep, writeReachesCopy, assertActor, assertWritable, exportRows } from './dataEngine';
7
7
  export type { SqlRow, SqlRunner } from './dataEngine';
8
+ export { adviseIndexes, adviceDoubled } from './dataIndexAdvice';
9
+ export type { IndexAdviceCandidate, IndexAdviceInput, IndexAdviceStat } from './dataIndexAdvice';
8
10
  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
11
  export type { DataQuery, DataQueryInput, DataQueryParam, DataQueryParamType } from './dataQueries';
10
12
  export type { ProjectDatabaseRpc, DatabaseInfo, ExportFile, ExportFormat, ExportState, RestoreResult } from './dataRpc';
11
13
  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
14
  export type { DataToolDefinition, DataAdminAction } from './dataTools';
13
- export { DATA_TRIGGER_EVENTS, DATA_TRIGGER_ACTIONS, DATA_MAX_TRIGGERS, DATA_TRIGGER_MAX_DEPTH, DATA_TRIGGER_DEFAULT_RATE, DATA_TRIGGER_MAX_RATE, DATA_OUTBOX_BATCH, DATA_TRIGGER_MAX_MESSAGE_BYTES, utf8Bytes, conditionMatches, renderTriggerText, normaliseTrigger, listTriggers, getTrigger, saveTrigger, dropTrigger, setTriggerEnabled, replaceManagedTriggers, collectTriggerEvents, readOutbox, deleteOutbox, outboxSize, clearOutbox, triggersUsingColumn, renameColumnInTriggers } from './dataTriggers';
14
- export type { DataTrigger, DataTriggerAction, DataTriggerActionType, DataTriggerCondition, DataTriggerEvent, DataTriggerEventMessage, DataTriggerInput, DataTriggerTemplate, DataTriggerTest, DataTriggerWithSecret, SavedTrigger } from './dataTriggers';
15
+ export { DATA_TRIGGER_EVENTS, DATA_TRIGGER_ACTIONS, DATA_MAX_TRIGGERS, DATA_TRIGGER_MAX_DEPTH, DATA_TRIGGER_DEFAULT_RATE, DATA_TRIGGER_MAX_RATE, DATA_OUTBOX_BATCH, DATA_TRIGGER_MAX_MESSAGE_BYTES, utf8Bytes, conditionMatches, renderTriggerText, renderCustomerMessage, readEventRow, normaliseTrigger, normaliseCustomerAction, listTriggers, getTrigger, saveTrigger, dropTrigger, setTriggerEnabled, replaceManagedTriggers, collectTriggerEvents, readOutbox, deleteOutbox, outboxSize, clearOutbox, triggersUsingColumn, renameColumnInTriggers } from './dataTriggers';
16
+ export type { DataTrigger, DataTriggerAction, DataTriggerActionType, DataTriggerCondition, DataTriggerCustomerMessage, DataTriggerEvent, DataTriggerEventMessage, DataTriggerInput, DataTriggerTemplate, DataTriggerTest, DataTriggerWithSecret, SavedTrigger } from './dataTriggers';
15
17
  //# sourceMappingURL=data.d.ts.map
@@ -1 +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,sBA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B,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACb,MAAM,gBAAgB,CAAC"}
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,SAAS,EACT,eAAe,EACf,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,SAAS,EACT,gBAAgB,EAChB,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,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC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B,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACb,MAAM,gBAAgB,CAAC"}
package/dist/data.js CHANGED
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
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.triggersUsingColumn = exports.clearOutbox = exports.outboxSize = exports.deleteOutbox = exports.readOutbox = exports.collectTriggerEvents = exports.replaceManagedTriggers = exports.setTriggerEnabled = exports.dropTrigger = exports.saveTrigger = exports.getTrigger = exports.listTriggers = exports.normaliseTrigger = exports.renderTriggerText = exports.conditionMatches = exports.utf8Bytes = exports.DATA_TRIGGER_MAX_MESSAGE_BYTES = exports.DATA_OUTBOX_BATCH = exports.DATA_TRIGGER_MAX_RATE = exports.DATA_TRIGGER_DEFAULT_RATE = exports.DATA_TRIGGER_MAX_DEPTH = exports.DATA_MAX_TRIGGERS = exports.DATA_TRIGGER_ACTIONS = exports.DATA_TRIGGER_EVENTS = 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
- exports.renameColumnInTriggers = void 0;
17
+ exports.dropColumnNeedsRebuild = exports.columnChangeNeedsRebuild = exports.dropColumn = exports.updateColumn = exports.addColumn = exports.dropTable = exports.updateTable = exports.createTable = exports.replaceFileLinks = exports.fileLinks = 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.unknownFileUris = exports.fileUriOf = 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.saveTrigger = exports.getTrigger = exports.listTriggers = exports.normaliseCustomerAction = exports.normaliseTrigger = exports.readEventRow = exports.renderCustomerMessage = exports.renderTriggerText = exports.conditionMatches = exports.utf8Bytes = exports.DATA_TRIGGER_MAX_MESSAGE_BYTES = exports.DATA_OUTBOX_BATCH = exports.DATA_TRIGGER_MAX_RATE = exports.DATA_TRIGGER_DEFAULT_RATE = exports.DATA_TRIGGER_MAX_DEPTH = exports.DATA_MAX_TRIGGERS = exports.DATA_TRIGGER_ACTIONS = exports.DATA_TRIGGER_EVENTS = 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.adviceDoubled = exports.adviseIndexes = exports.exportRows = exports.assertWritable = exports.assertActor = exports.writeReachesCopy = exports.copyTableStep = exports.clearFailedTableCopy = exports.readTableCopy = void 0;
19
+ exports.renameColumnInTriggers = exports.triggersUsingColumn = exports.clearOutbox = exports.outboxSize = exports.deleteOutbox = exports.readOutbox = exports.collectTriggerEvents = exports.replaceManagedTriggers = exports.setTriggerEnabled = exports.dropTrigger = void 0;
20
20
  // Entry point for `@ganju/utils/data`: everything a project's database and
21
21
  // its callers share, without pulling in the rest of the package.
22
22
  __exportStar(require("./dataTypes"), exports);
@@ -43,6 +43,8 @@ Object.defineProperty(exports, "keysetCondition", { enumerable: true, get: funct
43
43
  Object.defineProperty(exports, "encodeCursor", { enumerable: true, get: function () { return dataCompiler_1.encodeCursor; } });
44
44
  Object.defineProperty(exports, "decodeCursor", { enumerable: true, get: function () { return dataCompiler_1.decodeCursor; } });
45
45
  Object.defineProperty(exports, "isSensitiveWrite", { enumerable: true, get: function () { return dataCompiler_1.isSensitiveWrite; } });
46
+ Object.defineProperty(exports, "fileUriOf", { enumerable: true, get: function () { return dataCompiler_1.fileUriOf; } });
47
+ Object.defineProperty(exports, "unknownFileUris", { enumerable: true, get: function () { return dataCompiler_1.unknownFileUris; } });
46
48
  Object.defineProperty(exports, "tidyArgs", { enumerable: true, get: function () { return dataCompiler_1.tidyArgs; } });
47
49
  Object.defineProperty(exports, "zoned", { enumerable: true, get: function () { return dataCompiler_1.zoned; } });
48
50
  var dataEngine_1 = require("./dataEngine");
@@ -62,6 +64,8 @@ Object.defineProperty(exports, "write", { enumerable: true, get: function () { r
62
64
  Object.defineProperty(exports, "rowHistory", { enumerable: true, get: function () { return dataEngine_1.rowHistory; } });
63
65
  Object.defineProperty(exports, "pruneHistory", { enumerable: true, get: function () { return dataEngine_1.pruneHistory; } });
64
66
  Object.defineProperty(exports, "deleteImpact", { enumerable: true, get: function () { return dataEngine_1.deleteImpact; } });
67
+ Object.defineProperty(exports, "fileLinks", { enumerable: true, get: function () { return dataEngine_1.fileLinks; } });
68
+ Object.defineProperty(exports, "replaceFileLinks", { enumerable: true, get: function () { return dataEngine_1.replaceFileLinks; } });
65
69
  Object.defineProperty(exports, "createTable", { enumerable: true, get: function () { return dataEngine_1.createTable; } });
66
70
  Object.defineProperty(exports, "updateTable", { enumerable: true, get: function () { return dataEngine_1.updateTable; } });
67
71
  Object.defineProperty(exports, "dropTable", { enumerable: true, get: function () { return dataEngine_1.dropTable; } });
@@ -77,6 +81,9 @@ Object.defineProperty(exports, "writeReachesCopy", { enumerable: true, get: func
77
81
  Object.defineProperty(exports, "assertActor", { enumerable: true, get: function () { return dataEngine_1.assertActor; } });
78
82
  Object.defineProperty(exports, "assertWritable", { enumerable: true, get: function () { return dataEngine_1.assertWritable; } });
79
83
  Object.defineProperty(exports, "exportRows", { enumerable: true, get: function () { return dataEngine_1.exportRows; } });
84
+ var dataIndexAdvice_1 = require("./dataIndexAdvice");
85
+ Object.defineProperty(exports, "adviseIndexes", { enumerable: true, get: function () { return dataIndexAdvice_1.adviseIndexes; } });
86
+ Object.defineProperty(exports, "adviceDoubled", { enumerable: true, get: function () { return dataIndexAdvice_1.adviceDoubled; } });
80
87
  var dataQueries_1 = require("./dataQueries");
81
88
  Object.defineProperty(exports, "DATA_QUERY_PARAM_TYPES", { enumerable: true, get: function () { return dataQueries_1.DATA_QUERY_PARAM_TYPES; } });
82
89
  Object.defineProperty(exports, "DATA_MAX_QUERIES", { enumerable: true, get: function () { return dataQueries_1.DATA_MAX_QUERIES; } });
@@ -114,7 +121,10 @@ Object.defineProperty(exports, "DATA_TRIGGER_MAX_MESSAGE_BYTES", { enumerable: t
114
121
  Object.defineProperty(exports, "utf8Bytes", { enumerable: true, get: function () { return dataTriggers_1.utf8Bytes; } });
115
122
  Object.defineProperty(exports, "conditionMatches", { enumerable: true, get: function () { return dataTriggers_1.conditionMatches; } });
116
123
  Object.defineProperty(exports, "renderTriggerText", { enumerable: true, get: function () { return dataTriggers_1.renderTriggerText; } });
124
+ Object.defineProperty(exports, "renderCustomerMessage", { enumerable: true, get: function () { return dataTriggers_1.renderCustomerMessage; } });
125
+ Object.defineProperty(exports, "readEventRow", { enumerable: true, get: function () { return dataTriggers_1.readEventRow; } });
117
126
  Object.defineProperty(exports, "normaliseTrigger", { enumerable: true, get: function () { return dataTriggers_1.normaliseTrigger; } });
127
+ Object.defineProperty(exports, "normaliseCustomerAction", { enumerable: true, get: function () { return dataTriggers_1.normaliseCustomerAction; } });
118
128
  Object.defineProperty(exports, "listTriggers", { enumerable: true, get: function () { return dataTriggers_1.listTriggers; } });
119
129
  Object.defineProperty(exports, "getTrigger", { enumerable: true, get: function () { return dataTriggers_1.getTrigger; } });
120
130
  Object.defineProperty(exports, "saveTrigger", { enumerable: true, get: function () { return dataTriggers_1.saveTrigger; } });
package/dist/dataApi.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare const DATA_API_ROUTES: {
19
19
  readonly path: "";
20
20
  readonly tag: "Database";
21
21
  readonly summary: "The project's database";
22
- readonly description: "Its status and size, and its tables when it is ready. `database` is null when the project has none.";
22
+ readonly description: "Its status and size, and its tables when it is ready, with `indexAdvice`: the open index suggestions. `database` is null when the project has none.";
23
23
  readonly returns: "{ database }";
24
24
  };
25
25
  readonly create: {
@@ -94,6 +94,22 @@ export declare const DATA_API_ROUTES: {
94
94
  readonly description: "A column change on a table over 100,000 rows copies it in the background; table changes, and writes that would change its rows, wait until it finishes (`copy` on `GET` shows how far it got). A copy that failed left the table as it was and stays in `copy` with its `error` until dismissed, or until the next column change.";
95
95
  readonly returns: "{ copy: null }";
96
96
  };
97
+ readonly applyIndexAdvice: {
98
+ readonly method: "post";
99
+ readonly path: "/advice/:adviceId";
100
+ readonly tag: "Tables";
101
+ readonly summary: "Add a suggested index";
102
+ readonly description: "`GET` lists the open suggestions in `indexAdvice`: a column filtered or sorted on by 50 or more queries in a week that each read 1,000 or more rows, 20 for every row returned. This marks the column filterable, which indexes it, and records it in the change log. A suggestion of kind `unused` is only a flag; it can't be applied here, only dismissed.";
103
+ readonly returns: "{ table }";
104
+ };
105
+ readonly dismissIndexAdvice: {
106
+ readonly method: "delete";
107
+ readonly path: "/advice/:adviceId";
108
+ readonly tag: "Tables";
109
+ readonly summary: "Dismiss an index suggestion";
110
+ readonly description: "It stays dismissed until its numbers double (queries, rows read per query, or rows written for an unused index).";
111
+ readonly returns: "{ dismissed: true }";
112
+ };
97
113
  readonly listTables: {
98
114
  readonly method: "get";
99
115
  readonly path: "/table";
@@ -113,8 +129,8 @@ export declare const DATA_API_ROUTES: {
113
129
  displayColumn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
114
130
  access: z.ZodOptional<z.ZodEnum<{
115
131
  none: "none";
116
- read: "read";
117
132
  add: "add";
133
+ read: "read";
118
134
  full: "full";
119
135
  }>>;
120
136
  customerScoped: z.ZodOptional<z.ZodBoolean>;
@@ -170,8 +186,8 @@ export declare const DATA_API_ROUTES: {
170
186
  displayColumn: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
171
187
  access: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
172
188
  none: "none";
173
- read: "read";
174
189
  add: "add";
190
+ read: "read";
175
191
  full: "full";
176
192
  }>>>;
177
193
  customerScoped: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
@@ -289,7 +305,7 @@ export declare const DATA_API_ROUTES: {
289
305
  readonly path: "/table/:table/row";
290
306
  readonly tag: "Rows";
291
307
  readonly summary: "List, filter and search rows";
292
- readonly description: "Up to 500 rows or 1 MB a page; `nextCursor` reads the next. `where` is JSON, e.g. `{\"status\":\"open\",\"price\":{\"lt\":30000}}`. `sort` is a list of columns, `-` for descending. `q` searches the searchable columns.";
308
+ readonly description: "Up to 500 rows or 1 MB a page; `nextCursor` reads the next. `where` is JSON, e.g. `{\"status\":\"open\",\"price\":{\"lt\":30000}}`. `sort` is a list of columns, `-` for descending. `q` searches the searchable columns. A relation comes back as `{ id, label }`; a file column as `{ uri, id, title, mimeType }`, or `{ uri, missing: true }` when no resource has the uri any more. Writes take a file column's uri.";
293
309
  readonly query: z.ZodObject<{
294
310
  where: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<unknown, string>>>;
295
311
  sort: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
@@ -576,6 +592,36 @@ export declare const DATA_API_ROUTES: {
576
592
  }, z.core.$strict>;
577
593
  readonly returns: "{ triggers, removed, secrets, confirming? }";
578
594
  };
595
+ readonly listTestRecipients: {
596
+ readonly method: "get";
597
+ readonly path: "/trigger/test-send";
598
+ readonly tag: "Triggers";
599
+ readonly summary: "Where a test send can go";
600
+ readonly description: "The caller's own chats with this project's bots: the ones they linked to their Ganju account by sending `/link` to the bot. Empty when there are none.";
601
+ readonly returns: "{ recipients }";
602
+ };
603
+ readonly testSend: {
604
+ readonly method: "post";
605
+ readonly path: "/trigger/test-send";
606
+ readonly tag: "Triggers";
607
+ readonly summary: "Send a test of a customer message";
608
+ readonly description: "Sends a `customer` action, saved or not, to the caller's own chat with the bot instead of the row's customer: built from the row `rowId` (the table's newest row by default), the same as a real run. `participantId` picks one of `GET /trigger/test-send`'s recipients when there are several. With `asTemplate`, a WhatsApp template goes out even inside the 24-hour window. Not a run: it isn't listed with any trigger's runs and doesn't count toward the daily limit per customer. Five a minute per user. A channel's refusal (the template not approved, outside the window with no template, the daily limit) comes back as the error.";
609
+ readonly body: z.ZodObject<{
610
+ table: z.ZodString;
611
+ customer: z.ZodObject<{
612
+ text: z.ZodString;
613
+ template: z.ZodOptional<z.ZodObject<{
614
+ name: z.ZodString;
615
+ language: z.ZodString;
616
+ params: z.ZodOptional<z.ZodArray<z.ZodString>>;
617
+ }, z.core.$strict>>;
618
+ }, z.core.$strict>;
619
+ rowId: z.ZodOptional<z.ZodNumber>;
620
+ participantId: z.ZodOptional<z.ZodString>;
621
+ asTemplate: z.ZodOptional<z.ZodBoolean>;
622
+ }, z.core.$strict>;
623
+ readonly returns: "{ sent, text, template, rowId, recipient }";
624
+ };
579
625
  readonly listTriggerRuns: {
580
626
  readonly method: "get";
581
627
  readonly path: "/trigger/:name/run";
@@ -1 +1 @@
1
- {"version":3,"file":"dataApi.d.ts","sourceRoot":"","sources":["../src/dataApi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa,mEACwC,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhE,MAAM,WAAW,YAAY;IAC3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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwYqB,CAAC;AAElD,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,eAAe,CAAC;AAmB1D;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8G5C,CAAC"}
package/dist/dataApi.js CHANGED
@@ -7,14 +7,14 @@ exports.dataOpenApi = exports.DATA_API_ROUTES = exports.DATA_API_BASE = void 0;
7
7
  const zod_1 = require("zod");
8
8
  const schema_1 = require("./schema");
9
9
  exports.DATA_API_BASE = '/organization/:organizationId/project/:projectId/artifact/data';
10
- const { DATA_DATABASE_CREATE, DATA_DATABASE_DELETE, DATA_DATABASE_PATCH, DATA_TABLE_INPUT, DATA_TABLE_PATCH, DATA_COLUMN_INPUT, DATA_COLUMN_PATCH, DATA_TABLE_DROP_BODY, DATA_ROW_LIST_QUERY, DATA_ROW_GET_QUERY, DATA_ROW_CREATE_BODY, DATA_ROW_UPDATE_BODY, DATA_ROW_DELETE_BODY, DATA_DELETE_PREVIEW_BODY, DATA_WRITE_BODY, DATA_ROW_HISTORY_QUERY, DATA_RESTORE_POINT_BODY, DATA_EXPORT_BODY, DATA_EXPORT_QUERY, DATA_EXPORT_FILE_QUERY, DATA_CHANGE_LIST_QUERY, DATA_QUERY_INPUT, DATA_QUERY_RUN_BODY, DATA_TRIGGER_INPUT, DATA_TRIGGER_PATCH, DATA_TRIGGER_DEPLOY_BODY, DATA_TRIGGER_RUN_LIST_QUERY } = schema_1.Schema;
10
+ const { DATA_DATABASE_CREATE, DATA_DATABASE_DELETE, DATA_DATABASE_PATCH, DATA_TABLE_INPUT, DATA_TABLE_PATCH, DATA_COLUMN_INPUT, DATA_COLUMN_PATCH, DATA_TABLE_DROP_BODY, DATA_ROW_LIST_QUERY, DATA_ROW_GET_QUERY, DATA_ROW_CREATE_BODY, DATA_ROW_UPDATE_BODY, DATA_ROW_DELETE_BODY, DATA_DELETE_PREVIEW_BODY, DATA_WRITE_BODY, DATA_ROW_HISTORY_QUERY, DATA_RESTORE_POINT_BODY, DATA_EXPORT_BODY, DATA_EXPORT_QUERY, DATA_EXPORT_FILE_QUERY, DATA_CHANGE_LIST_QUERY, DATA_QUERY_INPUT, DATA_QUERY_RUN_BODY, DATA_TRIGGER_INPUT, DATA_TRIGGER_PATCH, DATA_TRIGGER_DEPLOY_BODY, DATA_TRIGGER_TEST_SEND_BODY, DATA_TRIGGER_RUN_LIST_QUERY } = schema_1.Schema;
11
11
  exports.DATA_API_ROUTES = {
12
12
  getDatabase: {
13
13
  method: 'get',
14
14
  path: '',
15
15
  tag: 'Database',
16
16
  summary: "The project's database",
17
- description: 'Its status and size, and its tables when it is ready. `database` is null when the project has none.',
17
+ description: 'Its status and size, and its tables when it is ready, with `indexAdvice`: the open index suggestions. `database` is null when the project has none.',
18
18
  returns: '{ database }'
19
19
  },
20
20
  create: {
@@ -78,6 +78,22 @@ exports.DATA_API_ROUTES = {
78
78
  description: 'A column change on a table over 100,000 rows copies it in the background; table changes, and writes that would change its rows, wait until it finishes (`copy` on `GET` shows how far it got). A copy that failed left the table as it was and stays in `copy` with its `error` until dismissed, or until the next column change.',
79
79
  returns: '{ copy: null }'
80
80
  },
81
+ applyIndexAdvice: {
82
+ method: 'post',
83
+ path: '/advice/:adviceId',
84
+ tag: 'Tables',
85
+ summary: 'Add a suggested index',
86
+ description: "`GET` lists the open suggestions in `indexAdvice`: a column filtered or sorted on by 50 or more queries in a week that each read 1,000 or more rows, 20 for every row returned. This marks the column filterable, which indexes it, and records it in the change log. A suggestion of kind `unused` is only a flag; it can't be applied here, only dismissed.",
87
+ returns: '{ table }'
88
+ },
89
+ dismissIndexAdvice: {
90
+ method: 'delete',
91
+ path: '/advice/:adviceId',
92
+ tag: 'Tables',
93
+ summary: 'Dismiss an index suggestion',
94
+ description: 'It stays dismissed until its numbers double (queries, rows read per query, or rows written for an unused index).',
95
+ returns: '{ dismissed: true }'
96
+ },
81
97
  listTables: {
82
98
  method: 'get',
83
99
  path: '/table',
@@ -142,7 +158,7 @@ exports.DATA_API_ROUTES = {
142
158
  path: '/table/:table/row',
143
159
  tag: 'Rows',
144
160
  summary: 'List, filter and search rows',
145
- description: 'Up to 500 rows or 1 MB a page; `nextCursor` reads the next. `where` is JSON, e.g. `{"status":"open","price":{"lt":30000}}`. `sort` is a list of columns, `-` for descending. `q` searches the searchable columns.',
161
+ description: 'Up to 500 rows or 1 MB a page; `nextCursor` reads the next. `where` is JSON, e.g. `{"status":"open","price":{"lt":30000}}`. `sort` is a list of columns, `-` for descending. `q` searches the searchable columns. A relation comes back as `{ id, label }`; a file column as `{ uri, id, title, mimeType }`, or `{ uri, missing: true }` when no resource has the uri any more. Writes take a file column\'s uri.',
146
162
  query: DATA_ROW_LIST_QUERY,
147
163
  returns: '{ table, rows, total?, nextCursor? }'
148
164
  },
@@ -285,6 +301,23 @@ exports.DATA_API_ROUTES = {
285
301
  body: DATA_TRIGGER_DEPLOY_BODY,
286
302
  returns: '{ triggers, removed, secrets, confirming? }'
287
303
  },
304
+ listTestRecipients: {
305
+ method: 'get',
306
+ path: '/trigger/test-send',
307
+ tag: 'Triggers',
308
+ summary: 'Where a test send can go',
309
+ description: "The caller's own chats with this project's bots: the ones they linked to their Ganju account by sending `/link` to the bot. Empty when there are none.",
310
+ returns: '{ recipients }'
311
+ },
312
+ testSend: {
313
+ method: 'post',
314
+ path: '/trigger/test-send',
315
+ tag: 'Triggers',
316
+ summary: 'Send a test of a customer message',
317
+ description: "Sends a `customer` action, saved or not, to the caller's own chat with the bot instead of the row's customer: built from the row `rowId` (the table's newest row by default), the same as a real run. `participantId` picks one of `GET /trigger/test-send`'s recipients when there are several. With `asTemplate`, a WhatsApp template goes out even inside the 24-hour window. Not a run: it isn't listed with any trigger's runs and doesn't count toward the daily limit per customer. Five a minute per user. A channel's refusal (the template not approved, outside the window with no template, the daily limit) comes back as the error.",
318
+ body: DATA_TRIGGER_TEST_SEND_BODY,
319
+ returns: '{ sent, text, template, rowId, recipient }'
320
+ },
288
321
  listTriggerRuns: {
289
322
  method: 'get',
290
323
  path: '/trigger/:name/run',
@@ -0,0 +1,8 @@
1
+ export interface DataAttachment {
2
+ table: string;
3
+ column: string;
4
+ index: boolean;
5
+ }
6
+ export declare const dataAttachmentOf: (metadata: unknown) => DataAttachment | null;
7
+ export declare const skipsIndexing: (metadata: unknown) => boolean;
8
+ //# sourceMappingURL=dataAttachment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataAttachment.d.ts","sourceRoot":"","sources":["../src/dataAttachment.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB;AAID,eAAO,MAAM,gBAAgB,GAAI,UAAU,OAAO,KAAG,cAAc,GAAG,IAMrE,CAAC;AAGF,eAAO,MAAM,aAAa,GAAI,UAAU,OAAO,KAAG,OAGjD,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.skipsIndexing = exports.dataAttachmentOf = void 0;
4
+ const schema_1 = require("./schema");
5
+ // The Data upload a knowledge item came from, read from its metadata, or
6
+ // null for any other item.
7
+ const dataAttachmentOf = (metadata) => {
8
+ if (!metadata || typeof metadata !== 'object')
9
+ return null;
10
+ const parsed = schema_1.Schema.DATA_ATTACHMENT_METADATA.safeParse(metadata.dataAttachment);
11
+ return parsed.success ? parsed.data : null;
12
+ };
13
+ exports.dataAttachmentOf = dataAttachmentOf;
14
+ // Uploads from Data are stored, not indexed, unless their column asks.
15
+ const skipsIndexing = (metadata) => {
16
+ const attachment = (0, exports.dataAttachmentOf)(metadata);
17
+ return attachment !== null && !attachment.index;
18
+ };
19
+ exports.skipsIndexing = skipsIndexing;
@@ -28,6 +28,8 @@ export declare const joinsSql: (joins: Map<string, SqlJoin>) => string;
28
28
  export declare const joinsParams: (joins: Map<string, SqlJoin>) => SqlValue[];
29
29
  export declare const relationJoin: (caller: DataCaller, target: DataTable, alias: string, on: string) => SqlJoin;
30
30
  export declare const isoSeconds: (date: Date) => string;
31
+ export declare const fileUriOf: (value: unknown, label: string) => string;
32
+ export declare const unknownFileUris: (uris: string[]) => DataError;
31
33
  export declare const toStored: (table: DataTable, column: ResolvableColumn, value: unknown, timeZone?: string) => SqlValue;
32
34
  export declare const zoneOffsetMinutes: (date: Date, timeZone?: string) => number;
33
35
  export declare const zoned: (iso: string, timeZone?: string) => string;
@@ -44,6 +46,7 @@ export interface CompileContext {
44
46
  table: DataTable;
45
47
  joins: Map<string, SqlJoin>;
46
48
  params: SqlValue[];
49
+ filtered?: Set<string>;
47
50
  }
48
51
  export declare const resolvePath: (ctx: CompileContext, path: unknown) => ResolvedPath;
49
52
  export declare const compileWhere: (ctx: CompileContext, where: unknown, indexed?: Set<string>) => string[];
@@ -1 +1 @@
1
- {"version":3,"file":"dataCompiler.d.ts","sourceRoot":"","sources":["../src/dataCompiler.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,U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;AAuDF,eAAO,MAAM,QAAQ,GAAI,MAAM,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAkC9D,CAAC;AAmCF,eAAO,MAAM,gBAAgB,GAC3B,SAAS,OAAO,EAChB,SAAS,UAAU,KAClB,OAmBF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSensitiveWrite = exports.tidyArgs = exports.chunkRows = exports.rowsPerInsert = exports.keysetCondition = exports.decodeCursor = exports.encodeCursor = exports.ftsMatch = exports.assertParamCount = exports.compileWhere = exports.resolvePath = exports.fromStored = exports.zoned = exports.zoneOffsetMinutes = exports.toStored = exports.isoSeconds = exports.relationJoin = exports.joinsParams = exports.joinsSql = exports.participantOf = exports.canRead = exports.isScoped = exports.tableFor = exports.visibleTables = exports.accessOf = exports.unknownColumn = exports.columnFor = exports.isSystemColumn = exports.FILTER_OPERATORS = void 0;
3
+ exports.isSensitiveWrite = exports.tidyArgs = exports.chunkRows = exports.rowsPerInsert = exports.keysetCondition = exports.decodeCursor = exports.encodeCursor = exports.ftsMatch = exports.assertParamCount = exports.compileWhere = exports.resolvePath = exports.fromStored = exports.zoned = exports.zoneOffsetMinutes = exports.toStored = exports.unknownFileUris = exports.fileUriOf = exports.isoSeconds = exports.relationJoin = exports.joinsParams = exports.joinsSql = exports.participantOf = exports.canRead = exports.isScoped = exports.tableFor = exports.visibleTables = exports.accessOf = exports.unknownColumn = exports.columnFor = exports.isSystemColumn = exports.FILTER_OPERATORS = void 0;
4
4
  // Turns the structured query and write arguments into SQL with bound values.
5
5
  // Identifiers are checked against the database's own schema and quoted;
6
6
  // every value a caller sends is a parameter. Pure: the engine runs the SQL.
@@ -162,6 +162,26 @@ const checkSize = (label, value) => {
162
162
  }
163
163
  return value;
164
164
  };
165
+ // A knowledge item's uri, given as the text or as { uri } (how reads return
166
+ // it). Any scheme: knowledge holds resource://, website and drive uris.
167
+ const fileUriOf = (value, label) => {
168
+ const raw = value !== null && typeof value === 'object' && !Array.isArray(value)
169
+ ? value.uri
170
+ : value;
171
+ const uri = typeof raw === 'string' ? raw.trim() : '';
172
+ if (!/^[a-z][a-z0-9+.-]*:\/\/\S+$/i.test(uri)) {
173
+ throw new dataTypes_1.DataError(`${label} takes a knowledge item's uri, e.g. resource://menu-photo.`);
174
+ }
175
+ if (uri.length > dataTypes_1.DATA_FILE_URI_MAX) {
176
+ throw new dataTypes_1.DataError(`${label}: a uri is at most ${dataTypes_1.DATA_FILE_URI_MAX} characters.`, 'too_large');
177
+ }
178
+ return uri;
179
+ };
180
+ exports.fileUriOf = fileUriOf;
181
+ // A write that links uris no item of the project has: the workers check,
182
+ // since the database object can't see knowledge.
183
+ const unknownFileUris = (uris) => new dataTypes_1.DataError(`No resource in this project has the uri ${uris.join(', ')}; link an existing resource by its uri.`, 'invalid', { uris });
184
+ exports.unknownFileUris = unknownFileUris;
165
185
  // Turns a value from a caller into what the column stores, or explains why
166
186
  // it can't. `timeZone` is the project's, for datetimes sent without an
167
187
  // offset.
@@ -230,6 +250,8 @@ const toStored = (table, column, value, timeZone) => {
230
250
  throw new dataTypes_1.DataError(`${label} must be a URL starting with http(s)://.`);
231
251
  }
232
252
  return checkSize(label, value.trim());
253
+ case 'file':
254
+ return (0, exports.fileUriOf)(value, label);
233
255
  case 'phone': {
234
256
  if (typeof value !== 'string' && typeof value !== 'number') {
235
257
  throw new dataTypes_1.DataError(`${label} must be a phone number.`);
@@ -392,6 +414,8 @@ const compileWhere = (ctx, where, indexed) => {
392
414
  continue;
393
415
  }
394
416
  const resolved = (0, exports.resolvePath)(ctx, key);
417
+ if (resolved.own)
418
+ ctx.filtered?.add(resolved.column.name);
395
419
  // { "customer": { "name": "Ana" } } reads as "customer.name": models
396
420
  // write relation filters this way unprompted.
397
421
  if (resolved.column.type === 'relation' &&
@@ -1 +1 @@
1
- {"version":3,"file":"dataDdl.d.ts","sourceRoot":"","sources":["../src/dataDdl.ts"],"names":[],"mapp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AG5D,CAAC;AAKJ,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,KAAG,MAAM,GAAG,IAQxD,CAAC;AAkGF,eAAO,MAAM,eAAe,GAAI,OAAO,SAAS,KAAG,cAAc,EAIhE,CAAC;AAOF,eAAO,MAAM,aAAa,GACxB,UAAU,cAAc,EACxB,IAAI,UAAU,EACd,KAAK,MAAM,KACV,MAgCF,CAAC;AAIF,eAAO,MAAM,yBAAyB,GACpC,IAAI,UAAU,EACd,KAAK,MAAM,EACX,WAAW,MAAM,KAChB,MA+BF,CAAC"}
package/dist/dataDdl.js CHANGED
@@ -6,6 +6,7 @@ exports.invalidAfterConversionSql = exports.conversionSql = exports.desiredTrigg
6
6
  // ours, and every owner-supplied value is a literal escaped by sqlLiteral.
7
7
  const dataTriggers_1 = require("./dataTriggers");
8
8
  const dataIdentifiers_1 = require("./dataIdentifiers");
9
+ const dataTypes_1 = require("./dataTypes");
9
10
  exports.DATA_NOW_SQL = "strftime('%Y-%m-%dT%H:%M:%SZ', 'now')";
10
11
  exports.TEXT_LIKE_TYPES = new Set([
11
12
  'text',
@@ -348,6 +349,10 @@ const invalidAfterConversionSql = (to, src, converted) => {
348
349
  if (to.type === 'url') {
349
350
  parts.push(`NOT ((${converted}) LIKE 'http://%' OR (${converted}) LIKE 'https://%')`);
350
351
  }
352
+ // A file column holds a knowledge item's uri: scheme://…, no spaces.
353
+ if (to.type === 'file') {
354
+ parts.push(`NOT ((${converted}) GLOB '[A-Za-z]*://?*' AND (${converted}) NOT GLOB '*[ ' || char(9) || char(10) || char(13) || ']*' AND length(${converted}) <= ${dataTypes_1.DATA_FILE_URI_MAX})`);
355
+ }
351
356
  if (to.type === 'relation' && to.table) {
352
357
  parts.push(`((${converted}) IS NOT NULL AND NOT EXISTS (SELECT 1 FROM ${(0, dataIdentifiers_1.quoteIdentifier)(to.table)} WHERE id = (${converted})))`);
353
358
  }
@@ -1,12 +1,15 @@
1
1
  import type { SqlValue } from './dataCompiler';
2
2
  import { toTableInput, DataError } from './dataTypes';
3
- import type { DataCaller, DataColumn, DataDefaultValue, DataDeleteImpact, DataSchema, DataTable, DataTableCopy } from './dataTypes';
3
+ import type { DataCaller, DataColumn, DataDefaultValue, DataDeleteImpact, DataFileLinks, DataFileLinksReplaced, DataQueryShape, DataSchema, DataTable, DataTableCopy, DataUsage, DataWriteShape } from './dataTypes';
4
4
  export type SqlRow = Record<string, SqlValue>;
5
5
  export interface SqlRunner {
6
6
  all(sql: string, params?: readonly SqlValue[]): SqlRow[];
7
7
  iterate(sql: string, params?: readonly SqlValue[]): Iterable<SqlRow>;
8
8
  transaction<T>(fn: () => T): T;
9
9
  databaseSize(): number;
10
+ usageSoFar?(): DataUsage;
11
+ noteQuery?(shape: DataQueryShape): void;
12
+ noteWrite?(shape: DataWriteShape): void;
10
13
  }
11
14
  export declare const INTERNAL_MIGRATIONS: readonly (readonly string[])[];
12
15
  export declare const INTERNAL_SCHEMA_VERSION: number;
@@ -45,7 +48,7 @@ export declare const describe: (runner: SqlRunner, schema: DataSchema, caller: D
45
48
  rowsAbout: number;
46
49
  onlyThisCustomersRows?: boolean | undefined;
47
50
  description: string | null;
48
- access: "none" | "read" | "add" | "full";
51
+ access: "none" | "add" | "read" | "full";
49
52
  label?: string | undefined;
50
53
  name: string;
51
54
  } | {
@@ -70,7 +73,7 @@ export declare const describe: (runner: SqlRunner, schema: DataSchema, caller: D
70
73
  rows: number;
71
74
  onlyThisCustomersRows?: boolean | undefined;
72
75
  description: string | null;
73
- access: "none" | "read" | "add" | "full";
76
+ access: "none" | "add" | "read" | "full";
74
77
  label?: string | undefined;
75
78
  name: string;
76
79
  })[];
@@ -83,6 +86,7 @@ export declare const query: (runner: SqlRunner, schema: DataSchema, caller: Data
83
86
  nextCursor?: string | undefined;
84
87
  includeTruncated?: string | undefined;
85
88
  rows: ShapedRow[];
89
+ fileFields?: string[][] | undefined;
86
90
  searchMatched?: "all words" | "any word" | undefined;
87
91
  total?: number | undefined;
88
92
  scope?: string | undefined;
@@ -108,6 +112,8 @@ export declare const write: (runner: SqlRunner, schema: DataSchema, caller: Data
108
112
  results: WriteResult[];
109
113
  };
110
114
  export declare const deleteImpact: (runner: SqlRunner, schema: DataSchema, caller: DataCaller, rawArgs: unknown) => DataDeleteImpact;
115
+ export declare const fileLinks: (runner: SqlRunner, schema: DataSchema, caller: DataCaller, rawArgs: unknown) => DataFileLinks;
116
+ export declare const replaceFileLinks: (runner: SqlRunner, schema: DataSchema, caller: DataCaller, rawArgs: unknown) => DataFileLinksReplaced;
111
117
  export declare const rowHistory: (runner: SqlRunner, schema: DataSchema, caller: DataCaller, args: {
112
118
  table: string;
113
119
  id: number;