notte-sdk 1.10.2 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = true ? "1.10.2" : "dev";
2
+ var SDK_VERSION = true ? "1.10.3" : "dev";
3
3
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
4
4
 
5
5
  // src/version-check.ts
@@ -1171,6 +1171,39 @@ var functionScheduleSet = (options) => (options.client ?? client).post({
1171
1171
  ...options.headers
1172
1172
  }
1173
1173
  });
1174
+ var functionSchedulesList = (options) => (options.client ?? client).get({
1175
+ security: [{ scheme: "bearer", type: "http" }],
1176
+ url: "/functions/{function_id}/schedules",
1177
+ ...options
1178
+ });
1179
+ var functionSchedulesAdd = (options) => (options.client ?? client).post({
1180
+ security: [{ scheme: "bearer", type: "http" }],
1181
+ url: "/functions/{function_id}/schedules",
1182
+ ...options,
1183
+ headers: {
1184
+ "Content-Type": "application/json",
1185
+ ...options.headers
1186
+ }
1187
+ });
1188
+ var functionSchedulesResume = (options) => (options.client ?? client).post({
1189
+ security: [{ scheme: "bearer", type: "http" }],
1190
+ url: "/functions/{function_id}/schedules/resume",
1191
+ ...options
1192
+ });
1193
+ var functionSchedulesRemove = (options) => (options.client ?? client).delete({
1194
+ security: [{ scheme: "bearer", type: "http" }],
1195
+ url: "/functions/{function_id}/schedules/{schedule_id}",
1196
+ ...options
1197
+ });
1198
+ var functionSchedulesUpdate = (options) => (options.client ?? client).patch({
1199
+ security: [{ scheme: "bearer", type: "http" }],
1200
+ url: "/functions/{function_id}/schedules/{schedule_id}",
1201
+ ...options,
1202
+ headers: {
1203
+ "Content-Type": "application/json",
1204
+ ...options.headers
1205
+ }
1206
+ });
1174
1207
  var functionRunStart = (options) => (options.client ?? client).post({
1175
1208
  security: [{ scheme: "bearer", type: "http" }],
1176
1209
  url: "/functions/{function_id}/runs/start",
@@ -2231,6 +2264,11 @@ function createResources(client2, getApiKey) {
2231
2264
  }
2232
2265
  },
2233
2266
  functions: {
2267
+ /** functionSchedulesAdd: /functions/{function_id}/schedules. Returns the API response body. */
2268
+ addSchedule: async (functionId, body, requestOptions = {}) => {
2269
+ const response = await functionSchedulesAdd({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body });
2270
+ return response.data;
2271
+ },
2234
2272
  /** functionCreate: /functions. Returns the API response body. */
2235
2273
  create: async (body, query = void 0, requestOptions = {}) => {
2236
2274
  const response = await functionCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body, query });
@@ -2271,6 +2309,11 @@ function createResources(client2, getApiKey) {
2271
2309
  const response = await listFunctionRunsByFunctionId({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, query });
2272
2310
  return response.data;
2273
2311
  },
2312
+ /** functionSchedulesList: /functions/{function_id}/schedules. Returns the API response body. */
2313
+ listSchedules: async (functionId, requestOptions = {}) => {
2314
+ const response = await functionSchedulesList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId } });
2315
+ return response.data;
2316
+ },
2274
2317
  /** functionMetadataUpdate: /functions/{function_id}. Returns the API response body. */
2275
2318
  metadataUpdate: async (functionId, body, requestOptions = {}) => {
2276
2319
  const response = await functionMetadataUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body });
@@ -2281,6 +2324,16 @@ function createResources(client2, getApiKey) {
2281
2324
  const response = await prepareRunPayloadUpload({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId, "run_id": runId, "field": field }, body });
2282
2325
  return response.data;
2283
2326
  },
2327
+ /** functionSchedulesRemove: /functions/{function_id}/schedules/{schedule_id}. Returns the API response body. */
2328
+ removeSchedule: async (functionId, scheduleId, requestOptions = {}) => {
2329
+ const response = await functionSchedulesRemove({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId, "schedule_id": scheduleId } });
2330
+ return response.data;
2331
+ },
2332
+ /** functionSchedulesResume: /functions/{function_id}/schedules/resume. Returns the API response body. */
2333
+ resumeSchedules: async (functionId, requestOptions = {}) => {
2334
+ const response = await functionSchedulesResume({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId } });
2335
+ return response.data;
2336
+ },
2284
2337
  /** functionRollback: /functions/{function_id}/rollback. Returns the API response body. */
2285
2338
  rollback: async (functionId, body, query = void 0, requestOptions = {}) => {
2286
2339
  const response = await functionRollback({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body, query });
@@ -2320,6 +2373,11 @@ function createResources(client2, getApiKey) {
2320
2373
  update: async (functionId, body, query = void 0, requestOptions = {}) => {
2321
2374
  const response = await functionUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId }, body, query });
2322
2375
  return response.data;
2376
+ },
2377
+ /** functionSchedulesUpdate: /functions/{function_id}/schedules/{schedule_id}. Returns the API response body. */
2378
+ updateSchedule: async (functionId, scheduleId, body, requestOptions = {}) => {
2379
+ const response = await functionSchedulesUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "function_id": functionId, "schedule_id": scheduleId }, body });
2380
+ return response.data;
2323
2381
  }
2324
2382
  },
2325
2383
  personas: {
@@ -4962,19 +5020,22 @@ var NotteFunction = class {
4962
5020
  * before execution, then pass it to `run(variables, { functionRunId })`.
4963
5021
  * `run()` otherwise creates a new run on its own.
4964
5022
  *
4965
- * @param options - Run-record settings; `local` defaults to false. Node execution remains cloud-only.
5023
+ * @param options - Run-record settings; `local` defaults to false. Node execution remains cloud-only. `version` pins a saved version; omitted means the latest.
4966
5024
  * @returns A created run record and its ID. No function code has executed yet.
4967
5025
  * @throws NotteAPIError if run creation is rejected.
4968
5026
  * @example
4969
5027
  * const created = await fn.createRun();
4970
5028
  * const result = await fn.run({ url: 'https://example.com' }, { functionRunId: created.function_run_id });
5029
+ *
5030
+ * const { versions } = await fn.get();
5031
+ * const pinned = await fn.createRun({ version: versions[0] });
4971
5032
  */
4972
5033
  async createRun(options = {}) {
4973
5034
  const functionId = await this.ensureInitialized();
4974
5035
  return this.postRunEndpoint({
4975
5036
  url: FUNCTION_RUN_ENDPOINTS.create,
4976
5037
  path: { function_id: functionId },
4977
- body: { local: options.local ?? false }
5038
+ body: { local: options.local ?? false, ...options.version !== void 0 ? { version: options.version } : {} }
4978
5039
  });
4979
5040
  }
4980
5041
  /**
@@ -5007,12 +5068,13 @@ var NotteFunction = class {
5007
5068
  * Pass `{ stream: false }` to receive the backend's JSON response without
5008
5069
  * live logs; execution still blocks until completion. Pass `functionRunId`
5009
5070
  * to execute a record returned by `createRun()`; otherwise a new run record
5010
- * is created first, exactly like Python. A failed execution throws
5071
+ * is created first, exactly like Python. Pass `version` to run a saved
5072
+ * version instead of the latest one. A failed execution throws
5011
5073
  * `FailedToRunCloudFunctionError` unless `raiseOnFailure` is false, and the
5012
5074
  * wait is aborted with `NotteTimeoutError` after `timeoutMs`.
5013
5075
  *
5014
5076
  * @param variables - JSON-serializable keyword arguments passed to the Python function's `run` entry point.
5015
- * @param options - Log streaming, failure handling, runtime, run ID, and timeout settings.
5077
+ * @param options - Log streaming, failure handling, runtime, run ID, version, and timeout settings.
5016
5078
  * @returns The completed execution response. The function's return value is in `result`. Disabling streaming still waits for completion.
5017
5079
  * @throws FailedToRunCloudFunctionError if execution fails and `raiseOnFailure` is true.
5018
5080
  * @throws NotteTimeoutError if the execution request exceeds `timeoutMs`.
@@ -5021,6 +5083,9 @@ var NotteFunction = class {
5021
5083
  * const result = await fn.run({ url: 'https://example.com' });
5022
5084
  * console.log(result.result);
5023
5085
  *
5086
+ * const { versions } = await fn.get();
5087
+ * await fn.run({ url: 'https://example.com' }, { version: versions[0] });
5088
+ *
5024
5089
  * await fn.run({ url: 'https://example.com' }, { runtime: 'extended', onLog: line => logger.info(line) });
5025
5090
  */
5026
5091
  async run(variables = {}, options = {}) {
@@ -5029,8 +5094,11 @@ var NotteFunction = class {
5029
5094
  if (!(timeoutMs > 0)) {
5030
5095
  throw new InvalidRequestError("timeoutMs must be a positive number");
5031
5096
  }
5097
+ if (options.version !== void 0 && options.functionRunId !== void 0) {
5098
+ throw new InvalidRequestError("Pass version to createRun({ version }) instead; a run's version is set when it is created");
5099
+ }
5032
5100
  const functionId = await this.ensureInitialized();
5033
- const functionRunId = options.functionRunId ?? (await this.createRun()).function_run_id;
5101
+ const functionRunId = options.functionRunId ?? (await this.createRun({ version: options.version })).function_run_id;
5034
5102
  const body = {
5035
5103
  workflow_id: functionId,
5036
5104
  variables,
@@ -6392,6 +6460,11 @@ export {
6392
6460
  functionRuntimeHealth,
6393
6461
  functionScheduleDelete,
6394
6462
  functionScheduleSet,
6463
+ functionSchedulesAdd,
6464
+ functionSchedulesList,
6465
+ functionSchedulesRemove,
6466
+ functionSchedulesResume,
6467
+ functionSchedulesUpdate,
6395
6468
  functionUpdate,
6396
6469
  getPayment,
6397
6470
  getPolicy,