@ganju/utils 0.0.16 → 0.0.18

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 (68) hide show
  1. package/dist/constants.d.ts +9 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +26 -2
  4. package/dist/customCodeToken.d.ts +15 -0
  5. package/dist/customCodeToken.d.ts.map +1 -1
  6. package/dist/customCodeToken.js +49 -1
  7. package/dist/data.d.ts +6 -0
  8. package/dist/data.d.ts.map +1 -1
  9. package/dist/data.js +53 -1
  10. package/dist/dataApi.d.ts +200 -1
  11. package/dist/dataApi.d.ts.map +1 -1
  12. package/dist/dataApi.js +106 -1
  13. package/dist/dataCompiler.d.ts.map +1 -1
  14. package/dist/dataCompiler.js +5 -1
  15. package/dist/dataCsv.d.ts +20 -0
  16. package/dist/dataCsv.d.ts.map +1 -0
  17. package/dist/dataCsv.js +102 -0
  18. package/dist/dataDdl.d.ts.map +1 -1
  19. package/dist/dataDdl.js +3 -1
  20. package/dist/dataEngine.d.ts.map +1 -1
  21. package/dist/dataEngine.js +86 -4
  22. package/dist/dataImport.d.ts +2 -0
  23. package/dist/dataImport.d.ts.map +1 -1
  24. package/dist/dataImport.js +4 -1
  25. package/dist/dataQueries.d.ts +73 -0
  26. package/dist/dataQueries.d.ts.map +1 -0
  27. package/dist/dataQueries.js +513 -0
  28. package/dist/dataRpc.d.ts +44 -0
  29. package/dist/dataRpc.d.ts.map +1 -1
  30. package/dist/dataTools.d.ts +40 -0
  31. package/dist/dataTools.d.ts.map +1 -0
  32. package/dist/dataTools.js +280 -0
  33. package/dist/dataTriggers.d.ts +203 -0
  34. package/dist/dataTriggers.d.ts.map +1 -0
  35. package/dist/dataTriggers.js +760 -0
  36. package/dist/dataTypes.d.ts +3 -0
  37. package/dist/dataTypes.d.ts.map +1 -1
  38. package/dist/index.d.ts +201 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +4 -0
  41. package/dist/localizeDataError.d.ts +18 -0
  42. package/dist/localizeDataError.d.ts.map +1 -0
  43. package/dist/localizeDataError.js +359 -0
  44. package/dist/schema.d.ts +201 -0
  45. package/dist/schema.d.ts.map +1 -1
  46. package/dist/schema.js +149 -1
  47. package/dist/sdkConstants.d.ts +3 -0
  48. package/dist/sdkConstants.d.ts.map +1 -1
  49. package/dist/sdkConstants.js +4 -1
  50. package/package.json +1 -1
  51. package/src/constants.ts +30 -2
  52. package/src/customCodeToken.ts +87 -0
  53. package/src/data.ts +74 -0
  54. package/src/dataApi.ts +129 -2
  55. package/src/dataCompiler.ts +5 -1
  56. package/src/dataCsv.ts +99 -0
  57. package/src/dataDdl.ts +3 -1
  58. package/src/dataEngine.ts +94 -4
  59. package/src/dataImport.ts +3 -0
  60. package/src/dataQueries.ts +730 -0
  61. package/src/dataRpc.ts +26 -0
  62. package/src/dataTools.ts +338 -0
  63. package/src/dataTriggers.ts +1134 -0
  64. package/src/dataTypes.ts +9 -0
  65. package/src/index.ts +11 -1
  66. package/src/localizeDataError.ts +593 -0
  67. package/src/schema.ts +158 -1
  68. package/src/sdkConstants.ts +3 -0
package/src/dataTypes.ts CHANGED
@@ -104,6 +104,9 @@ export interface DataTable {
104
104
 
105
105
  export interface DataSchema {
106
106
  tables: DataTable[];
107
+ // The zone the owner set for the database: datetimes come back in it for
108
+ // callers that send none. Null when unset (UTC).
109
+ timeZone?: string | null;
107
110
  }
108
111
 
109
112
  // Who is calling and under which rules. `actor` is recorded on every row a
@@ -116,8 +119,14 @@ export interface DataCaller {
116
119
  restricted?: boolean;
117
120
  // Customer-scoped tables: fill and filter `participant_id` with this.
118
121
  participantId?: string;
122
+ // Only these tables exist for the caller (a function's `data.tables`):
123
+ // every other one is hidden, through relations and filters too.
124
+ tables?: string[];
119
125
  // Datetimes come back in this zone, with the offset.
120
126
  timeZone?: string;
127
+ // A function a trigger ran: how deep in a chain of triggers its writes
128
+ // are (its actor is `trigger:<id>`).
129
+ triggerDepth?: number;
121
130
  limits?: DataCallerLimits;
122
131
  }
123
132
 
package/src/index.ts CHANGED
@@ -109,12 +109,17 @@ import {
109
109
  import {
110
110
  mintCustomCodeToken,
111
111
  verifyCustomCodeToken,
112
+ mintCustomCodeCallToken,
113
+ verifyCustomCodeCallToken,
112
114
  customCodeScriptName,
113
115
  customCodePreviewScriptName,
114
116
  customCodeUploadName,
115
117
  customCodePreviewUploadName
116
118
  } from './customCodeToken';
117
- import type { CustomCodeTokenPayload } from './customCodeToken';
119
+ import type {
120
+ CustomCodeCallPayload,
121
+ CustomCodeTokenPayload
122
+ } from './customCodeToken';
118
123
  import {
119
124
  mintContainmentToken,
120
125
  verifyContainmentToken
@@ -160,6 +165,7 @@ import { formatRelative } from './formatRelative';
160
165
  import { formatRelativeTime } from './formatRelativeTime';
161
166
  import { languageCookieDomain } from './languageCookieDomain';
162
167
  import { localizeZodIssue, languageFromHeader } from './localizeZodIssue';
168
+ import { localizeDataError } from './localizeDataError';
163
169
  import { slugifyTitle } from './slugifyTitle';
164
170
  import { resourceUriFromTitle } from './resourceUri';
165
171
  import {
@@ -411,6 +417,8 @@ export const utils = {
411
417
  listResourcesPage,
412
418
  mintCustomCodeToken,
413
419
  verifyCustomCodeToken,
420
+ mintCustomCodeCallToken,
421
+ verifyCustomCodeCallToken,
414
422
  customCodeScriptName,
415
423
  customCodePreviewScriptName,
416
424
  customCodeUploadName,
@@ -444,6 +452,7 @@ export const utils = {
444
452
  languageCookieDomain,
445
453
  localizeZodIssue,
446
454
  languageFromHeader,
455
+ localizeDataError,
447
456
  slugifyTitle,
448
457
  resourceUriFromTitle,
449
458
  accessTokenHint,
@@ -657,6 +666,7 @@ export type {
657
666
  CustomCodeManifest,
658
667
  CustomCodeSendFile,
659
668
  CustomCodeCreateResource,
669
+ CustomCodeCallPayload,
660
670
  CustomCodeTokenPayload,
661
671
  ContainmentTokenPayload,
662
672
  OAuthProviderConfig,