@nodestackapp/server 2.5.0 → 2.7.0

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 (269) hide show
  1. package/README.md +42 -28
  2. package/dist/NodeStack.d.ts +5 -1
  3. package/dist/NodeStack.d.ts.map +1 -1
  4. package/dist/NodeStack.js +117 -18
  5. package/dist/NodeStack.js.map +1 -1
  6. package/dist/admin/AdminUIBundler.d.ts.map +1 -1
  7. package/dist/admin/AdminUIBundler.js +2 -0
  8. package/dist/admin/AdminUIBundler.js.map +1 -1
  9. package/dist/admin/ui/css/main.css +40 -3
  10. package/dist/admin/ui/css/webhooks.css +8 -0
  11. package/dist/admin/ui/index.html +21479 -17251
  12. package/dist/admin/ui/js/api-keys.js +1381 -0
  13. package/dist/admin/ui/js/api.js +8 -0
  14. package/dist/admin/ui/js/app.js +698 -641
  15. package/dist/admin/ui/js/apps.js +514 -489
  16. package/dist/admin/ui/js/collections.js +486 -484
  17. package/dist/admin/ui/js/command-palette.js +693 -673
  18. package/dist/admin/ui/js/cron.js +1706 -0
  19. package/dist/admin/ui/js/database.js +10 -0
  20. package/dist/admin/ui/js/flows-designer.js +1219 -1076
  21. package/dist/admin/ui/js/flows.js +947 -890
  22. package/dist/admin/ui/js/functions-tester.js +1 -1
  23. package/dist/admin/ui/js/functions-workbench.js +1162 -1101
  24. package/dist/admin/ui/js/functions.js +983 -979
  25. package/dist/admin/ui/js/rules.js +1080 -775
  26. package/dist/admin/ui/js/schema.js +346 -304
  27. package/dist/admin/ui/js/snapshots.js +338 -0
  28. package/dist/admin/ui/js/views.js +1 -1
  29. package/dist/apps/AppManager.d.ts +1 -1
  30. package/dist/apps/AppManager.d.ts.map +1 -1
  31. package/dist/apps/AppManager.js +11 -21
  32. package/dist/apps/AppManager.js.map +1 -1
  33. package/dist/apps/AppRegistry.d.ts +1 -0
  34. package/dist/apps/AppRegistry.d.ts.map +1 -1
  35. package/dist/apps/AppRegistry.js +78 -23
  36. package/dist/apps/AppRegistry.js.map +1 -1
  37. package/dist/apps/AppScope.d.ts +2 -1
  38. package/dist/apps/AppScope.d.ts.map +1 -1
  39. package/dist/apps/AppScope.js +27 -17
  40. package/dist/apps/AppScope.js.map +1 -1
  41. package/dist/auth/ApiKeyService.d.ts +63 -2
  42. package/dist/auth/ApiKeyService.d.ts.map +1 -1
  43. package/dist/auth/ApiKeyService.js +518 -8
  44. package/dist/auth/ApiKeyService.js.map +1 -1
  45. package/dist/auth/AuthService.d.ts +30 -1
  46. package/dist/auth/AuthService.d.ts.map +1 -1
  47. package/dist/auth/AuthService.js +468 -65
  48. package/dist/auth/AuthService.js.map +1 -1
  49. package/dist/auth/oauth/AppleProvider.d.ts +2 -0
  50. package/dist/auth/oauth/AppleProvider.d.ts.map +1 -1
  51. package/dist/auth/oauth/AppleProvider.js +40 -3
  52. package/dist/auth/oauth/AppleProvider.js.map +1 -1
  53. package/dist/auth/oauth/BaseOAuthProvider.d.ts +3 -2
  54. package/dist/auth/oauth/BaseOAuthProvider.d.ts.map +1 -1
  55. package/dist/auth/oauth/BaseOAuthProvider.js +29 -3
  56. package/dist/auth/oauth/BaseOAuthProvider.js.map +1 -1
  57. package/dist/auth/oauth/DiscordProvider.d.ts.map +1 -1
  58. package/dist/auth/oauth/DiscordProvider.js +4 -1
  59. package/dist/auth/oauth/DiscordProvider.js.map +1 -1
  60. package/dist/auth/oauth/GitHubProvider.d.ts.map +1 -1
  61. package/dist/auth/oauth/GitHubProvider.js +4 -1
  62. package/dist/auth/oauth/GitHubProvider.js.map +1 -1
  63. package/dist/auth/oauth/GoogleProvider.d.ts.map +1 -1
  64. package/dist/auth/oauth/GoogleProvider.js +4 -1
  65. package/dist/auth/oauth/GoogleProvider.js.map +1 -1
  66. package/dist/auth/oauth/MicrosoftProvider.d.ts.map +1 -1
  67. package/dist/auth/oauth/MicrosoftProvider.js +4 -1
  68. package/dist/auth/oauth/MicrosoftProvider.js.map +1 -1
  69. package/dist/auth/oauth/OAuthProviderRegistry.d.ts +6 -2
  70. package/dist/auth/oauth/OAuthProviderRegistry.d.ts.map +1 -1
  71. package/dist/auth/oauth/OAuthProviderRegistry.js +25 -10
  72. package/dist/auth/oauth/OAuthProviderRegistry.js.map +1 -1
  73. package/dist/auth/oauth/types.d.ts +4 -2
  74. package/dist/auth/oauth/types.d.ts.map +1 -1
  75. package/dist/cli/cli.d.ts.map +1 -1
  76. package/dist/cli/cli.js +228 -12
  77. package/dist/cli/cli.js.map +1 -1
  78. package/dist/core/config/ConfigService.d.ts.map +1 -1
  79. package/dist/core/config/ConfigService.js +5 -3
  80. package/dist/core/config/ConfigService.js.map +1 -1
  81. package/dist/core/config/EnvLoader.d.ts +14 -0
  82. package/dist/core/config/EnvLoader.d.ts.map +1 -1
  83. package/dist/core/config/EnvLoader.js +44 -0
  84. package/dist/core/config/EnvLoader.js.map +1 -1
  85. package/dist/core/container/Container.d.ts +14 -0
  86. package/dist/core/container/Container.d.ts.map +1 -1
  87. package/dist/core/container/Container.js +32 -0
  88. package/dist/core/container/Container.js.map +1 -1
  89. package/dist/core/container/Tokens.d.ts +2 -0
  90. package/dist/core/container/Tokens.d.ts.map +1 -1
  91. package/dist/core/container/Tokens.js +2 -0
  92. package/dist/core/container/Tokens.js.map +1 -1
  93. package/dist/core/errors/AppError.d.ts +7 -7
  94. package/dist/core/errors/AppError.d.ts.map +1 -1
  95. package/dist/core/errors/AppError.js +18 -14
  96. package/dist/core/errors/AppError.js.map +1 -1
  97. package/dist/core/events/EventBus.d.ts.map +1 -1
  98. package/dist/core/events/EventBus.js +36 -6
  99. package/dist/core/events/EventBus.js.map +1 -1
  100. package/dist/core/maintenance/MaintenanceGate.d.ts +47 -0
  101. package/dist/core/maintenance/MaintenanceGate.d.ts.map +1 -1
  102. package/dist/core/maintenance/MaintenanceGate.js +265 -7
  103. package/dist/core/maintenance/MaintenanceGate.js.map +1 -1
  104. package/dist/core/plugins/PluginManager.d.ts +20 -1
  105. package/dist/core/plugins/PluginManager.d.ts.map +1 -1
  106. package/dist/core/plugins/PluginManager.js +231 -146
  107. package/dist/core/plugins/PluginManager.js.map +1 -1
  108. package/dist/core/plugins/types.d.ts +48 -31
  109. package/dist/core/plugins/types.d.ts.map +1 -1
  110. package/dist/cron/CronParser.d.ts +83 -0
  111. package/dist/cron/CronParser.d.ts.map +1 -0
  112. package/dist/cron/CronParser.js +538 -0
  113. package/dist/cron/CronParser.js.map +1 -0
  114. package/dist/cron/CronService.d.ts +74 -0
  115. package/dist/cron/CronService.d.ts.map +1 -0
  116. package/dist/cron/CronService.js +1254 -0
  117. package/dist/cron/CronService.js.map +1 -0
  118. package/dist/cron/types.d.ts +98 -0
  119. package/dist/cron/types.d.ts.map +1 -0
  120. package/dist/cron/types.js +3 -0
  121. package/dist/cron/types.js.map +1 -0
  122. package/dist/database/DatabaseService.d.ts +4 -1
  123. package/dist/database/DatabaseService.d.ts.map +1 -1
  124. package/dist/database/DatabaseService.js +34 -9
  125. package/dist/database/DatabaseService.js.map +1 -1
  126. package/dist/database/config/DatabaseConfigService.d.ts +1 -0
  127. package/dist/database/config/DatabaseConfigService.d.ts.map +1 -1
  128. package/dist/database/config/DatabaseConfigService.js +4 -2
  129. package/dist/database/config/DatabaseConfigService.js.map +1 -1
  130. package/dist/database/drivers/DriverPackageLoader.d.ts +11 -0
  131. package/dist/database/drivers/DriverPackageLoader.d.ts.map +1 -0
  132. package/dist/database/drivers/DriverPackageLoader.js +112 -0
  133. package/dist/database/drivers/DriverPackageLoader.js.map +1 -0
  134. package/dist/database/drivers/DriverRegistry.d.ts +1 -0
  135. package/dist/database/drivers/DriverRegistry.d.ts.map +1 -1
  136. package/dist/database/drivers/DriverRegistry.js +29 -0
  137. package/dist/database/drivers/DriverRegistry.js.map +1 -1
  138. package/dist/database/drivers/IDatabaseDriver.d.ts +1 -0
  139. package/dist/database/drivers/IDatabaseDriver.d.ts.map +1 -1
  140. package/dist/database/drivers/MssqlDriver.d.ts.map +1 -1
  141. package/dist/database/drivers/MssqlDriver.js +10 -5
  142. package/dist/database/drivers/MssqlDriver.js.map +1 -1
  143. package/dist/database/drivers/NodeSqliteDriver.d.ts.map +1 -1
  144. package/dist/database/drivers/NodeSqliteDriver.js +15 -1
  145. package/dist/database/drivers/NodeSqliteDriver.js.map +1 -1
  146. package/dist/database/drivers/PostgresDriver.d.ts.map +1 -1
  147. package/dist/database/drivers/PostgresDriver.js +4 -5
  148. package/dist/database/drivers/PostgresDriver.js.map +1 -1
  149. package/dist/database/migration/DatabaseMigrationService.d.ts +1 -0
  150. package/dist/database/migration/DatabaseMigrationService.d.ts.map +1 -1
  151. package/dist/database/migration/DatabaseMigrationService.js +51 -0
  152. package/dist/database/migration/DatabaseMigrationService.js.map +1 -1
  153. package/dist/database/migrations/SystemMigrations.d.ts.map +1 -1
  154. package/dist/database/migrations/SystemMigrations.js +200 -5
  155. package/dist/database/migrations/SystemMigrations.js.map +1 -1
  156. package/dist/flows/FlowEngine.js.map +1 -1
  157. package/dist/flows/FlowService.d.ts +10 -1
  158. package/dist/flows/FlowService.d.ts.map +1 -1
  159. package/dist/flows/FlowService.js +227 -14
  160. package/dist/flows/FlowService.js.map +1 -1
  161. package/dist/flows/FlowValidator.d.ts +2 -1
  162. package/dist/flows/FlowValidator.d.ts.map +1 -1
  163. package/dist/flows/FlowValidator.js +89 -4
  164. package/dist/flows/FlowValidator.js.map +1 -1
  165. package/dist/flows/types.d.ts +20 -3
  166. package/dist/flows/types.d.ts.map +1 -1
  167. package/dist/functions/FunctionService.d.ts +10 -2
  168. package/dist/functions/FunctionService.d.ts.map +1 -1
  169. package/dist/functions/FunctionService.js +271 -37
  170. package/dist/functions/FunctionService.js.map +1 -1
  171. package/dist/functions/runtime/QuickJsWasmRuntime.d.ts.map +1 -1
  172. package/dist/functions/runtime/QuickJsWasmRuntime.js +189 -177
  173. package/dist/functions/runtime/QuickJsWasmRuntime.js.map +1 -1
  174. package/dist/functions/types.d.ts +31 -2
  175. package/dist/functions/types.d.ts.map +1 -1
  176. package/dist/http/HttpServer.d.ts +7 -1
  177. package/dist/http/HttpServer.d.ts.map +1 -1
  178. package/dist/http/HttpServer.js +187 -8
  179. package/dist/http/HttpServer.js.map +1 -1
  180. package/dist/http/controllers/ApiKeyController.d.ts +1 -0
  181. package/dist/http/controllers/ApiKeyController.d.ts.map +1 -1
  182. package/dist/http/controllers/ApiKeyController.js +47 -1
  183. package/dist/http/controllers/ApiKeyController.js.map +1 -1
  184. package/dist/http/controllers/AuthController.d.ts +12 -0
  185. package/dist/http/controllers/AuthController.d.ts.map +1 -1
  186. package/dist/http/controllers/AuthController.js +40 -2
  187. package/dist/http/controllers/AuthController.js.map +1 -1
  188. package/dist/http/controllers/CronController.d.ts +63 -0
  189. package/dist/http/controllers/CronController.d.ts.map +1 -0
  190. package/dist/http/controllers/CronController.js +92 -0
  191. package/dist/http/controllers/CronController.js.map +1 -0
  192. package/dist/http/controllers/DatabaseController.d.ts.map +1 -1
  193. package/dist/http/controllers/DatabaseController.js +53 -0
  194. package/dist/http/controllers/DatabaseController.js.map +1 -1
  195. package/dist/http/controllers/FlowController.d.ts.map +1 -1
  196. package/dist/http/controllers/FlowController.js +45 -4
  197. package/dist/http/controllers/FlowController.js.map +1 -1
  198. package/dist/http/controllers/FunctionController.d.ts.map +1 -1
  199. package/dist/http/controllers/FunctionController.js +16 -2
  200. package/dist/http/controllers/FunctionController.js.map +1 -1
  201. package/dist/http/controllers/HealthController.js +2 -2
  202. package/dist/http/middleware/AppResolutionMiddleware.d.ts +1 -1
  203. package/dist/http/middleware/AppResolutionMiddleware.d.ts.map +1 -1
  204. package/dist/http/middleware/AppResolutionMiddleware.js +2 -3
  205. package/dist/http/middleware/AppResolutionMiddleware.js.map +1 -1
  206. package/dist/http/middleware/AuthMiddleware.d.ts.map +1 -1
  207. package/dist/http/middleware/AuthMiddleware.js +6 -3
  208. package/dist/http/middleware/AuthMiddleware.js.map +1 -1
  209. package/dist/http/middleware/ChaosMiddleware.js +6 -6
  210. package/dist/http/middleware/ChaosMiddleware.js.map +1 -1
  211. package/dist/index.d.ts +2 -2
  212. package/dist/index.d.ts.map +1 -1
  213. package/dist/index.js +6 -2
  214. package/dist/index.js.map +1 -1
  215. package/dist/queue/QueueService.d.ts +9 -0
  216. package/dist/queue/QueueService.d.ts.map +1 -1
  217. package/dist/queue/QueueService.js +143 -60
  218. package/dist/queue/QueueService.js.map +1 -1
  219. package/dist/queue/drivers/SqliteQueueDriver.d.ts +3 -0
  220. package/dist/queue/drivers/SqliteQueueDriver.d.ts.map +1 -1
  221. package/dist/queue/drivers/SqliteQueueDriver.js +315 -255
  222. package/dist/queue/drivers/SqliteQueueDriver.js.map +1 -1
  223. package/dist/records/FtsService.d.ts +7 -3
  224. package/dist/records/FtsService.d.ts.map +1 -1
  225. package/dist/records/FtsService.js +69 -5
  226. package/dist/records/FtsService.js.map +1 -1
  227. package/dist/records/QueryFilterParser.d.ts.map +1 -1
  228. package/dist/records/QueryFilterParser.js +58 -20
  229. package/dist/records/QueryFilterParser.js.map +1 -1
  230. package/dist/records/RecordSanitizer.d.ts.map +1 -1
  231. package/dist/records/RecordSanitizer.js +32 -4
  232. package/dist/records/RecordSanitizer.js.map +1 -1
  233. package/dist/records/RecordService.d.ts +6 -0
  234. package/dist/records/RecordService.d.ts.map +1 -1
  235. package/dist/records/RecordService.js +95 -14
  236. package/dist/records/RecordService.js.map +1 -1
  237. package/dist/records/RecordValidator.d.ts +10 -0
  238. package/dist/records/RecordValidator.d.ts.map +1 -1
  239. package/dist/records/RecordValidator.js +110 -2
  240. package/dist/records/RecordValidator.js.map +1 -1
  241. package/dist/records/fts/IFtsDriver.d.ts +7 -6
  242. package/dist/records/fts/IFtsDriver.d.ts.map +1 -1
  243. package/dist/records/fts/MssqlFtsDriver.d.ts +5 -1
  244. package/dist/records/fts/MssqlFtsDriver.d.ts.map +1 -1
  245. package/dist/records/fts/MssqlFtsDriver.js +35 -3
  246. package/dist/records/fts/MssqlFtsDriver.js.map +1 -1
  247. package/dist/records/fts/PostgresFtsDriver.d.ts +9 -2
  248. package/dist/records/fts/PostgresFtsDriver.d.ts.map +1 -1
  249. package/dist/records/fts/PostgresFtsDriver.js +116 -11
  250. package/dist/records/fts/PostgresFtsDriver.js.map +1 -1
  251. package/dist/records/fts/SqliteFts5Driver.d.ts +7 -1
  252. package/dist/records/fts/SqliteFts5Driver.d.ts.map +1 -1
  253. package/dist/records/fts/SqliteFts5Driver.js +66 -6
  254. package/dist/records/fts/SqliteFts5Driver.js.map +1 -1
  255. package/dist/schema/OpenApiGenerator.d.ts.map +1 -1
  256. package/dist/schema/OpenApiGenerator.js +103 -3
  257. package/dist/schema/OpenApiGenerator.js.map +1 -1
  258. package/dist/schema/models/Field.d.ts +1 -0
  259. package/dist/schema/models/Field.d.ts.map +1 -1
  260. package/dist/snapshots/SnapshotService.d.ts.map +1 -1
  261. package/dist/snapshots/SnapshotService.js +21 -9
  262. package/dist/snapshots/SnapshotService.js.map +1 -1
  263. package/dist/snapshots/drivers/LogicalSnapshotDriver.d.ts.map +1 -1
  264. package/dist/snapshots/drivers/LogicalSnapshotDriver.js +2 -0
  265. package/dist/snapshots/drivers/LogicalSnapshotDriver.js.map +1 -1
  266. package/dist/templates/definitions/ecommerce.js +6 -6
  267. package/dist/templates/definitions/ecommerce.js.map +1 -1
  268. package/dist/webhooks/WebhookService.js +1 -1
  269. package/package.json +5 -3
@@ -36,11 +36,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.FunctionService = exports.FunctionConcurrencyLimitError = exports.ALLOWED_AUTH_POLICIES = void 0;
37
37
  const crypto = __importStar(require("crypto"));
38
38
  const node_async_hooks_1 = require("node:async_hooks");
39
+ const RuleEngine_1 = require("../rules/RuleEngine");
39
40
  const SandboxedRunner_1 = require("./runtime/SandboxedRunner");
40
41
  const SsrfGuard_1 = require("./security/SsrfGuard");
41
- exports.ALLOWED_AUTH_POLICIES = ['public', 'auth', 'admin', 'apiKey'];
42
+ exports.ALLOWED_AUTH_POLICIES = ['public', 'auth', 'admin', 'apiKey', 'custom'];
42
43
  const AppError_1 = require("../core/errors/AppError");
43
44
  const FlowValidator_1 = require("../flows/FlowValidator");
45
+ const CronParser_1 = require("../cron/CronParser");
44
46
  const ApiKeyService_1 = require("../auth/ApiKeyService");
45
47
  class FunctionConcurrencyLimitError extends AppError_1.AppError {
46
48
  constructor(message = 'Serverless function concurrency limit reached. Please retry shortly.') {
@@ -64,6 +66,7 @@ class FunctionService {
64
66
  queueService;
65
67
  authService;
66
68
  apiKeyService;
69
+ cronService;
67
70
  constructor(db, schemaService, recordService, ruleEngine, eventBus, appScope = { id: 'default', slug: 'default' }, options = {}) {
68
71
  this.db = db;
69
72
  this.schemaService = schemaService;
@@ -78,8 +81,12 @@ class FunctionService {
78
81
  this.queueService = options.queueService;
79
82
  this.authService = options.authService;
80
83
  this.apiKeyService = options.apiKeyService;
84
+ this.cronService = options.cronService;
81
85
  this.initTables();
82
86
  }
87
+ setCronService(cronService) {
88
+ this.cronService = cronService;
89
+ }
83
90
  getActiveExecutions() {
84
91
  return this.activeExecutions;
85
92
  }
@@ -92,6 +99,12 @@ class FunctionService {
92
99
  getMaxRecursionDepth() {
93
100
  return this.maxRecursionDepth;
94
101
  }
102
+ getRuleEngine() {
103
+ if (!this.ruleEngine) {
104
+ this.ruleEngine = new RuleEngine_1.RuleEngine();
105
+ }
106
+ return this.ruleEngine;
107
+ }
95
108
  getRunner() {
96
109
  return this.runner;
97
110
  }
@@ -108,6 +121,7 @@ class FunctionService {
108
121
  code ${textType} NOT NULL,
109
122
  enabled INTEGER NOT NULL DEFAULT 1,
110
123
  authPolicy VARCHAR(50) NOT NULL DEFAULT 'public',
124
+ invokeRule ${textType},
111
125
  methods VARCHAR(100) NOT NULL DEFAULT 'GET,POST',
112
126
  eventTrigger VARCHAR(255),
113
127
  timeoutMs INTEGER NOT NULL DEFAULT 1000,
@@ -118,7 +132,44 @@ class FunctionService {
118
132
  created VARCHAR(50) NOT NULL,
119
133
  updated VARCHAR(50) NOT NULL
120
134
  `);
121
- void this.db.exec(ddlFunctions).catch(() => { });
135
+ const ddlResult = this.db.exec(ddlFunctions);
136
+ const ensureInvokeRuleColumn = () => {
137
+ try {
138
+ const colSql = this.db.dialect.name === 'postgres'
139
+ ? `ALTER TABLE "_functions" ADD COLUMN IF NOT EXISTS "invokeRule" ${textType}`
140
+ : this.db.dialect.addColumnSql('_functions', `invokeRule ${textType}`);
141
+ const colRes = this.db.exec(colSql);
142
+ if (colRes && typeof colRes.then === 'function') {
143
+ void colRes.catch(() => { });
144
+ }
145
+ }
146
+ catch { }
147
+ try {
148
+ const cols = [
149
+ `cronSchedule ${this.db.dialect.name === 'sqlite' ? 'TEXT' : 'VARCHAR(255)'}`,
150
+ `cronTimezone ${this.db.dialect.name === 'sqlite' ? 'TEXT' : 'VARCHAR(100)'}`,
151
+ `cronMissedPolicy ${this.db.dialect.name === 'sqlite' ? 'TEXT' : 'VARCHAR(50)'}`,
152
+ `cronPayload ${textType}`,
153
+ ];
154
+ for (const col of cols) {
155
+ const cName = col.split(' ')[0];
156
+ const sql = this.db.dialect.name === 'postgres'
157
+ ? `ALTER TABLE "_functions" ADD COLUMN IF NOT EXISTS "${cName}" ${col.substring(cName.length + 1)}`
158
+ : this.db.dialect.addColumnSql('_functions', col);
159
+ const r = this.db.exec(sql);
160
+ if (r && typeof r.then === 'function') {
161
+ void r.catch(() => { });
162
+ }
163
+ }
164
+ }
165
+ catch { }
166
+ };
167
+ if (ddlResult && typeof ddlResult.then === 'function') {
168
+ void ddlResult.then(ensureInvokeRuleColumn).catch(() => { });
169
+ }
170
+ else {
171
+ ensureInvokeRuleColumn();
172
+ }
122
173
  const ddlLogs = this.db.dialect.createTableIfNotExists('_function_logs', `
123
174
  id VARCHAR(255) PRIMARY KEY,
124
175
  functionId VARCHAR(255) NOT NULL,
@@ -185,6 +236,16 @@ class FunctionService {
185
236
  throw new AppError_1.ValidationError(`Invalid auth policy '${dto.authPolicy}'. Allowed policies are: ${exports.ALLOWED_AUTH_POLICIES.join(', ')}`);
186
237
  }
187
238
  }
239
+ if (dto.cronSchedule !== undefined && dto.cronSchedule !== null && String(dto.cronSchedule).trim() !== '') {
240
+ const tz = dto.cronTimezone?.trim() || 'UTC';
241
+ const validation = CronParser_1.CronParser.validate(dto.cronSchedule.trim(), tz);
242
+ if (!validation.valid) {
243
+ throw new AppError_1.ValidationError(validation.error || 'Invalid cron expression');
244
+ }
245
+ if (dto.cronMissedPolicy !== undefined && dto.cronMissedPolicy !== null && !['skip', 'catch_up_once', 'catch_up_all'].includes(dto.cronMissedPolicy)) {
246
+ throw new AppError_1.ValidationError(`Invalid missedRunPolicy '${dto.cronMissedPolicy}'`);
247
+ }
248
+ }
188
249
  const cleanName = dto.name.trim().toLowerCase().replace(/[^a-z0-9_-]/g, '-');
189
250
  const existing = this.getFunctionByName(cleanName);
190
251
  if (existing instanceof Promise) {
@@ -205,20 +266,47 @@ class FunctionService {
205
266
  const methods = Array.isArray(dto.methods) && dto.methods.length > 0 ? dto.methods.join(',') : 'GET,POST';
206
267
  const allowedDomains = JSON.stringify(dto.allowedDomains || []);
207
268
  const env = JSON.stringify(dto.env || {});
269
+ const invokeRule = dto.invokeRule !== undefined ? dto.invokeRule : null;
270
+ const cronSchedule = dto.cronSchedule || null;
271
+ const cronTimezone = dto.cronTimezone || 'UTC';
272
+ const cronMissedPolicy = dto.cronMissedPolicy || 'skip';
273
+ let cronPayloadStr = null;
274
+ if (dto.cronPayload !== undefined && dto.cronPayload !== null) {
275
+ cronPayloadStr = typeof dto.cronPayload === 'string' ? dto.cronPayload : JSON.stringify(dto.cronPayload);
276
+ }
208
277
  const res = this.db.run(`
209
278
  INSERT INTO _functions (
210
- id, name, description, code, enabled, authPolicy, methods,
211
- eventTrigger, timeoutMs, memoryLimitMb, allowedDomains,
279
+ id, name, description, code, enabled, authPolicy, invokeRule, methods,
280
+ eventTrigger, cronSchedule, cronTimezone, cronMissedPolicy, cronPayload,
281
+ timeoutMs, memoryLimitMb, allowedDomains,
212
282
  elevated, env, created, updated
213
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
214
- `, id, cleanName, dto.description || '', dto.code || 'export default async function(core, context) {\n return { status: 200, body: { message: "Hello from " + context.app.slug } };\n}', dto.enabled === false ? 0 : 1, dto.authPolicy || 'public', methods, dto.eventTrigger || null, dto.timeoutMs || 1000, dto.memoryLimitMb || 32, allowedDomains, dto.elevated ? 1 : 0, env, now, now);
283
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
284
+ `, id, cleanName, dto.description || '', dto.code || 'export default async function(core, context) {\n return { status: 200, body: { message: "Hello from " + context.app.slug } };\n}', dto.enabled === false ? 0 : 1, dto.authPolicy || 'public', invokeRule, methods, dto.eventTrigger || null, cronSchedule, cronTimezone, cronMissedPolicy, cronPayloadStr, dto.timeoutMs || 1000, dto.memoryLimitMb || 32, allowedDomains, dto.elevated ? 1 : 0, env, now, now);
215
285
  if (res instanceof Promise) {
216
286
  return res.then(async () => {
217
287
  const created = await this.getFunctionById(id);
288
+ if (this.cronService && created) {
289
+ await this.cronService.syncFunctionSchedule(created);
290
+ }
218
291
  return created;
219
292
  });
220
293
  }
221
294
  const created = this.getFunctionById(id);
295
+ if (this.cronService && created) {
296
+ if (created instanceof Promise) {
297
+ return created.then(async (c) => {
298
+ if (c)
299
+ await this.cronService.syncFunctionSchedule(c);
300
+ return c;
301
+ });
302
+ }
303
+ const syncRes = this.cronService.syncFunctionSchedule(created);
304
+ if (syncRes instanceof Promise) {
305
+ void syncRes.catch((err) => {
306
+ console.warn(`[FunctionService] Failed to sync cron schedule for function '${created.name}':`, err);
307
+ });
308
+ }
309
+ }
222
310
  return created;
223
311
  }
224
312
  updateFunction(id, dto, actor) {
@@ -227,6 +315,16 @@ class FunctionService {
227
315
  throw new AppError_1.ValidationError(`Invalid auth policy '${dto.authPolicy}'. Allowed policies are: ${exports.ALLOWED_AUTH_POLICIES.join(', ')}`);
228
316
  }
229
317
  }
318
+ if (dto.cronSchedule !== undefined && dto.cronSchedule !== null && String(dto.cronSchedule).trim() !== '') {
319
+ const tz = dto.cronTimezone?.trim() || 'UTC';
320
+ const validation = CronParser_1.CronParser.validate(dto.cronSchedule.trim(), tz);
321
+ if (!validation.valid) {
322
+ throw new AppError_1.ValidationError(validation.error || 'Invalid cron expression');
323
+ }
324
+ if (dto.cronMissedPolicy !== undefined && dto.cronMissedPolicy !== null && !['skip', 'catch_up_once', 'catch_up_all'].includes(dto.cronMissedPolicy)) {
325
+ throw new AppError_1.ValidationError(`Invalid missedRunPolicy '${dto.cronMissedPolicy}'`);
326
+ }
327
+ }
230
328
  const current = this.getFunctionById(id);
231
329
  if (current instanceof Promise) {
232
330
  return current.then((curr) => {
@@ -264,8 +362,29 @@ class FunctionService {
264
362
  const code = dto.code !== undefined ? dto.code : current.code;
265
363
  const enabled = dto.enabled !== undefined ? (dto.enabled ? 1 : 0) : (current.enabled ? 1 : 0);
266
364
  const authPolicy = dto.authPolicy || current.authPolicy;
365
+ const invokeRule = dto.invokeRule !== undefined ? dto.invokeRule : (current.invokeRule ?? null);
267
366
  const methods = dto.methods ? dto.methods.join(',') : current.methods.join(',');
268
367
  const eventTrigger = dto.eventTrigger !== undefined ? dto.eventTrigger : current.eventTrigger;
368
+ const cronSchedule = dto.cronSchedule !== undefined ? dto.cronSchedule : (current.cronSchedule ?? null);
369
+ const cronTimezone = dto.cronTimezone !== undefined ? dto.cronTimezone : (current.cronTimezone ?? 'UTC');
370
+ const cronMissedPolicy = dto.cronMissedPolicy !== undefined ? dto.cronMissedPolicy : (current.cronMissedPolicy ?? 'skip');
371
+ if (cronSchedule && cronSchedule.trim() !== '') {
372
+ const tz = (cronTimezone || 'UTC').trim();
373
+ const validation = CronParser_1.CronParser.validate(cronSchedule.trim(), tz);
374
+ if (!validation.valid) {
375
+ throw new AppError_1.ValidationError(validation.error || 'Invalid cron expression');
376
+ }
377
+ }
378
+ if (cronMissedPolicy && !['skip', 'catch_up_once', 'catch_up_all'].includes(cronMissedPolicy)) {
379
+ throw new AppError_1.ValidationError(`Invalid missedRunPolicy '${cronMissedPolicy}'`);
380
+ }
381
+ let cronPayloadStr = null;
382
+ if (dto.cronPayload !== undefined) {
383
+ cronPayloadStr = dto.cronPayload !== null ? (typeof dto.cronPayload === 'string' ? dto.cronPayload : JSON.stringify(dto.cronPayload)) : null;
384
+ }
385
+ else if (current.cronPayload !== undefined && current.cronPayload !== null) {
386
+ cronPayloadStr = typeof current.cronPayload === 'string' ? current.cronPayload : JSON.stringify(current.cronPayload);
387
+ }
269
388
  const timeoutMs = dto.timeoutMs !== undefined ? dto.timeoutMs : current.timeoutMs;
270
389
  const memoryLimitMb = dto.memoryLimitMb !== undefined ? dto.memoryLimitMb : current.memoryLimitMb;
271
390
  const allowedDomains = dto.allowedDomains ? JSON.stringify(dto.allowedDomains) : JSON.stringify(current.allowedDomains);
@@ -274,19 +393,37 @@ class FunctionService {
274
393
  const now = new Date().toISOString();
275
394
  const res = this.db.run(`
276
395
  UPDATE _functions SET
277
- name = ?, description = ?, code = ?, enabled = ?, authPolicy = ?,
278
- methods = ?, eventTrigger = ?, timeoutMs = ?, memoryLimitMb = ?,
279
- allowedDomains = ?, elevated = ?, env = ?, updated = ?
396
+ name = ?, description = ?, code = ?, enabled = ?, authPolicy = ?, invokeRule = ?,
397
+ methods = ?, eventTrigger = ?, cronSchedule = ?, cronTimezone = ?, cronMissedPolicy = ?, cronPayload = ?,
398
+ timeoutMs = ?, memoryLimitMb = ?, allowedDomains = ?, elevated = ?, env = ?, updated = ?
280
399
  WHERE id = ?
281
- `, name, description, code, enabled, authPolicy, methods, eventTrigger, timeoutMs, memoryLimitMb, allowedDomains, elevated, env, now, id);
400
+ `, name, description, code, enabled, authPolicy, invokeRule, methods, eventTrigger, cronSchedule, cronTimezone, cronMissedPolicy, cronPayloadStr, timeoutMs, memoryLimitMb, allowedDomains, elevated, env, now, id);
282
401
  const cascadeRes = this.cascadeRenames(current.name, name, now);
283
402
  if (res instanceof Promise || cascadeRes instanceof Promise) {
284
403
  return Promise.all([res, cascadeRes]).then(async () => {
285
404
  const updated = await this.getFunctionById(id);
405
+ if (this.cronService && updated) {
406
+ await this.cronService.syncFunctionSchedule(updated);
407
+ }
286
408
  return updated;
287
409
  });
288
410
  }
289
411
  const updated = this.getFunctionById(id);
412
+ if (this.cronService && updated) {
413
+ if (updated instanceof Promise) {
414
+ return updated.then(async (u) => {
415
+ if (u)
416
+ await this.cronService.syncFunctionSchedule(u);
417
+ return u;
418
+ });
419
+ }
420
+ const syncRes = this.cronService.syncFunctionSchedule(updated);
421
+ if (syncRes instanceof Promise) {
422
+ void syncRes.catch((err) => {
423
+ console.warn(`[FunctionService] Failed to sync cron schedule for function '${updated.name}':`, err);
424
+ });
425
+ }
426
+ }
290
427
  return updated;
291
428
  }
292
429
  cascadeRenames(currentName, newName, now) {
@@ -430,6 +567,9 @@ class FunctionService {
430
567
  }
431
568
  finishDeleteFunction(current, actor, options) {
432
569
  const doDelete = () => {
570
+ if (this.cronService) {
571
+ void Promise.resolve(this.cronService.removeTargetSchedules('function', current.id)).catch(() => { });
572
+ }
433
573
  const del1 = this.db.run('DELETE FROM _function_logs WHERE functionId = ?', current.id);
434
574
  const del2 = this.db.run('DELETE FROM _functions WHERE id = ?', current.id);
435
575
  if (del1 instanceof Promise || del2 instanceof Promise) {
@@ -468,7 +608,7 @@ class FunctionService {
468
608
  // ==========================================
469
609
  // Execution & Testing
470
610
  // ==========================================
471
- verifyAuthPolicy(fn, auth) {
611
+ verifyAuthPolicy(fn, auth, requestCtx) {
472
612
  switch (fn.authPolicy) {
473
613
  case 'admin':
474
614
  if (!auth?.isAdmin) {
@@ -476,33 +616,39 @@ class FunctionService {
476
616
  }
477
617
  break;
478
618
  case 'auth':
479
- if (!auth || (!auth.id && !auth.isAdmin)) {
619
+ if (auth?.isAdmin) {
620
+ break;
621
+ }
622
+ if (!auth || !auth.id) {
480
623
  throw new AppError_1.UnauthorizedError(`Authentication token required to invoke function '${fn.name}'`);
481
624
  }
625
+ if (auth.isApiKey && !(0, ApiKeyService_1.hasFunctionScope)(auth, fn.name)) {
626
+ throw new AppError_1.ForbiddenError(`API Key missing required scope for function invocation (e.g. 'functions:invoke', 'functions:execute', or 'functions:${fn.name}')`);
627
+ }
482
628
  break;
483
629
  case 'apiKey':
484
630
  if (!auth?.isApiKey && !auth?.isAdmin) {
485
631
  throw new AppError_1.UnauthorizedError(`Valid API Key required to invoke function '${fn.name}'`);
486
632
  }
487
- if (!auth?.isAdmin) {
488
- const hasFnScope = (0, ApiKeyService_1.hasScope)(auth, 'functions', 'execute') ||
489
- (0, ApiKeyService_1.hasScope)(auth, 'functions', 'invoke') ||
490
- (0, ApiKeyService_1.hasScope)(auth, 'functions', fn.name) ||
491
- (0, ApiKeyService_1.hasScope)(auth, fn.name, 'invoke') ||
492
- (0, ApiKeyService_1.hasScope)(auth, fn.name, 'execute') ||
493
- (0, ApiKeyService_1.hasScope)(auth, 'functions', '*') ||
494
- (Array.isArray(auth.scopes) && (auth.scopes.includes('*') ||
495
- auth.scopes.includes('admin:*') ||
496
- auth.scopes.includes('functions') ||
497
- auth.scopes.includes('functions:*') ||
498
- auth.scopes.includes('functions:invoke') ||
499
- auth.scopes.includes('functions:execute') ||
500
- auth.scopes.includes(`functions:${fn.name}`) ||
501
- auth.scopes.includes(`${fn.name}:invoke`) ||
502
- auth.scopes.includes(`${fn.name}:execute`)));
503
- if (!hasFnScope) {
504
- throw new AppError_1.ForbiddenError(`API Key missing required scope for function invocation (e.g. 'functions:invoke', 'functions:execute', or 'functions:*')`);
633
+ if (!auth?.isAdmin && !(0, ApiKeyService_1.hasFunctionScope)(auth, fn.name)) {
634
+ throw new AppError_1.ForbiddenError(`API Key missing required scope for function invocation (e.g. 'functions:invoke', 'functions:execute', or 'functions:*')`);
635
+ }
636
+ break;
637
+ case 'custom':
638
+ if (auth?.isAdmin) {
639
+ break;
640
+ }
641
+ if (auth?.isApiKey) {
642
+ if ((0, ApiKeyService_1.hasFunctionScope)(auth, fn.name)) {
643
+ break;
505
644
  }
645
+ throw new AppError_1.ForbiddenError(`API Key missing required scope for function invocation (e.g. 'functions:invoke', 'functions:execute', or 'functions:${fn.name}')`);
646
+ }
647
+ if (!fn.invokeRule || !fn.invokeRule.trim()) {
648
+ throw new AppError_1.ForbiddenError(`Function '${fn.name}' requires a valid custom invokeRule`);
649
+ }
650
+ if (!this.getRuleEngine().evaluate(fn.invokeRule, { auth, query: requestCtx?.query, data: requestCtx?.data })) {
651
+ throw new AppError_1.ForbiddenError(`You do not satisfy the access rule to invoke function '${fn.name}'`);
506
652
  }
507
653
  break;
508
654
  case 'public':
@@ -583,6 +729,9 @@ class FunctionService {
583
729
  if (fn.authPolicy === 'admin' && !fn.elevated && !actor?.isAdmin) {
584
730
  throw new AppError_1.ForbiddenError(`Superuser authorization required to execute targetFunction '${fn.name}' for queue '${message.queue}'`);
585
731
  }
732
+ if (fn.authPolicy === 'custom' && !fn.elevated && !actor?.isAdmin) {
733
+ this.verifyAuthPolicy(fn, actor, { data: message.payload });
734
+ }
586
735
  if (this.activeExecutions >= this.maxConcurrent) {
587
736
  throw new FunctionConcurrencyLimitError();
588
737
  }
@@ -642,6 +791,63 @@ class FunctionService {
642
791
  this.queueService?.wakeAllWorkers();
643
792
  }
644
793
  }
794
+ async executeScheduledFunction(functionIdOrName, cronCtx, payload) {
795
+ const fn = (await this.getFunctionById(functionIdOrName)) || (await this.getFunctionByName(functionIdOrName));
796
+ if (!fn) {
797
+ throw new AppError_1.NotFoundError(`Function '${functionIdOrName}' not found`);
798
+ }
799
+ if (!fn.enabled) {
800
+ throw new AppError_1.AppError(`Function '${fn.name}' is currently disabled`, 403);
801
+ }
802
+ if (this.activeExecutions >= this.maxConcurrent) {
803
+ throw new FunctionConcurrencyLimitError();
804
+ }
805
+ const parentStore = this.executionStorage.getStore();
806
+ const currentDepth = (parentStore?.depth || 0) + 1;
807
+ const activeFns = parentStore?.activeFns ? new Set(parentStore.activeFns) : new Set();
808
+ if (currentDepth > this.maxRecursionDepth || activeFns.has(fn.id)) {
809
+ const errorMsg = activeFns.has(fn.id)
810
+ ? `Circular recursion detected: function '${fn.name}' already active in call stack`
811
+ : `Maximum function recursion depth of ${this.maxRecursionDepth} exceeded`;
812
+ throw new AppError_1.AppError(errorMsg, 508);
813
+ }
814
+ this.activeExecutions++;
815
+ const nextActiveFns = new Set(activeFns);
816
+ nextActiveFns.add(fn.id);
817
+ const requestCtx = {
818
+ method: 'POST',
819
+ path: `/api/cron/${cronCtx.scheduleId}`,
820
+ query: {},
821
+ headers: { 'x-nodestack-trigger': 'cron' },
822
+ body: payload,
823
+ auth: { id: `cron:${cronCtx.scheduleId}`, role: 'admin', isAdmin: true },
824
+ };
825
+ try {
826
+ const context = this.buildFunctionContext(fn, requestCtx, undefined, { id: `cron:${cronCtx.scheduleId}`, isAdmin: true }, cronCtx);
827
+ const result = await this.executionStorage.run({ depth: currentDepth, activeFns: nextActiveFns }, () => this.runner.execute(fn.code, context, {
828
+ timeoutMs: fn.timeoutMs,
829
+ memoryLimitMb: fn.memoryLimitMb,
830
+ }));
831
+ this.recordLog({
832
+ functionId: fn.id,
833
+ functionName: fn.name,
834
+ trigger: 'cron',
835
+ status: result.status,
836
+ statusCode: result.statusCode,
837
+ durationMs: result.durationMs,
838
+ requestPayload: payload !== undefined ? JSON.stringify(payload) : undefined,
839
+ responsePayload: JSON.stringify(result.body ?? null),
840
+ logs: result.logs.join('\n'),
841
+ error: result.error,
842
+ actorId: `cron:${cronCtx.scheduleId}`,
843
+ });
844
+ return result;
845
+ }
846
+ finally {
847
+ this.activeExecutions = Math.max(0, this.activeExecutions - 1);
848
+ this.queueService?.wakeAllWorkers();
849
+ }
850
+ }
645
851
  setAuthServices(authService, apiKeyService) {
646
852
  if (authService)
647
853
  this.authService = authService;
@@ -759,7 +965,18 @@ class FunctionService {
759
965
  effectiveActor = mockRequest.auth;
760
966
  }
761
967
  else {
762
- effectiveAuth = actor ? { id: actor.id, role: actor.isAdmin ? 'admin' : (actor.isApiKey ? 'apiKey' : 'user'), email: actor.email } : null;
968
+ if (actor) {
969
+ const { tokenKey: _tk, ...actorRest } = actor;
970
+ effectiveAuth = {
971
+ ...actorRest,
972
+ id: actor.id,
973
+ email: actor.email,
974
+ role: actor.isAdmin ? 'admin' : (actor.isApiKey ? 'apiKey' : (actor.role || 'user')),
975
+ };
976
+ }
977
+ else {
978
+ effectiveAuth = null;
979
+ }
763
980
  effectiveActor = actor;
764
981
  }
765
982
  const requestCtx = {
@@ -773,7 +990,7 @@ class FunctionService {
773
990
  };
774
991
  if (fn.authPolicy && fn.authPolicy !== 'public') {
775
992
  try {
776
- this.verifyAuthPolicy(fn, effectiveActor);
993
+ this.verifyAuthPolicy(fn, effectiveActor, { query: requestCtx.query, data: requestCtx.body });
777
994
  }
778
995
  catch (err) {
779
996
  return {
@@ -1016,7 +1233,7 @@ class FunctionService {
1016
1233
  // ==========================================
1017
1234
  // Context Builder & Helpers
1018
1235
  // ==========================================
1019
- buildFunctionContext(fn, requestCtx, eventCtx, actor) {
1236
+ buildFunctionContext(fn, requestCtx, eventCtx, actor, cronCtx) {
1020
1237
  // If elevated is true, run as service-role (bypassing user rules)
1021
1238
  const effectiveAuth = fn.elevated
1022
1239
  ? { isAdmin: true, id: 'service-role' }
@@ -1106,10 +1323,7 @@ class FunctionService {
1106
1323
  throw new Error('Cannot enqueue messages into reserved _system:* queues from user functions');
1107
1324
  }
1108
1325
  if (effectiveAuth?.isApiKey && !effectiveAuth?.isAdmin) {
1109
- const canSend = (0, ApiKeyService_1.hasScope)(effectiveAuth, 'queues', 'send') ||
1110
- (0, ApiKeyService_1.hasScope)(effectiveAuth, 'queues', 'write') ||
1111
- (0, ApiKeyService_1.hasScope)(effectiveAuth, 'queues', '*');
1112
- if (!canSend) {
1326
+ if (!(0, ApiKeyService_1.hasQueueScope)(effectiveAuth, queueName, 'send')) {
1113
1327
  throw new AppError_1.ForbiddenError(`API Key missing required scope to enqueue messages to '${queueName}'`);
1114
1328
  }
1115
1329
  }
@@ -1125,6 +1339,11 @@ class FunctionService {
1125
1339
  if (queueName.trim().startsWith('_system:')) {
1126
1340
  throw new Error('Cannot claim messages from reserved _system:* queues from user functions');
1127
1341
  }
1342
+ if (effectiveAuth?.isApiKey && !effectiveAuth?.isAdmin) {
1343
+ if (!(0, ApiKeyService_1.hasQueueScope)(effectiveAuth, queueName, 'read')) {
1344
+ throw new AppError_1.ForbiddenError(`API Key missing required scope to claim messages from '${queueName}'`);
1345
+ }
1346
+ }
1128
1347
  const visibility = options?.visibilityTimeoutSeconds ?? 30;
1129
1348
  const limit = Math.max(1, Math.min(options?.limit ?? 1, 50));
1130
1349
  return await this.queueService.claim(queueName.trim(), visibility, limit, `fn_worker_${fn.id}`);
@@ -1207,6 +1426,7 @@ class FunctionService {
1207
1426
  app: this.appScope,
1208
1427
  request: requestCtx,
1209
1428
  event: eventCtx,
1429
+ cron: cronCtx,
1210
1430
  env: fn.env || {},
1211
1431
  auth: (requestCtx && requestCtx.auth !== undefined) ? requestCtx.auth : (effectiveAuth || null),
1212
1432
  },
@@ -1238,6 +1458,15 @@ class FunctionService {
1238
1458
  env = row.env ? JSON.parse(row.env) : {};
1239
1459
  }
1240
1460
  catch { }
1461
+ let cronPayload = undefined;
1462
+ if (row.cronPayload !== null && row.cronPayload !== undefined) {
1463
+ try {
1464
+ cronPayload = typeof row.cronPayload === 'string' ? JSON.parse(row.cronPayload) : row.cronPayload;
1465
+ }
1466
+ catch {
1467
+ cronPayload = row.cronPayload;
1468
+ }
1469
+ }
1241
1470
  return {
1242
1471
  id: row.id,
1243
1472
  name: row.name,
@@ -1245,8 +1474,13 @@ class FunctionService {
1245
1474
  code: row.code,
1246
1475
  enabled: Boolean(row.enabled),
1247
1476
  authPolicy: row.authPolicy || 'public',
1477
+ invokeRule: row.invokeRule ?? null,
1248
1478
  methods: row.methods ? row.methods.split(',').map((m) => m.trim()) : ['GET', 'POST'],
1249
1479
  eventTrigger: row.eventTrigger || null,
1480
+ cronSchedule: row.cronSchedule ?? null,
1481
+ cronTimezone: row.cronTimezone ?? null,
1482
+ cronMissedPolicy: row.cronMissedPolicy ?? null,
1483
+ cronPayload,
1250
1484
  timeoutMs: row.timeoutMs || 1000,
1251
1485
  memoryLimitMb: row.memoryLimitMb || 32,
1252
1486
  allowedDomains,