windmill-client 1.814.0 → 1.816.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.
@@ -29,7 +29,7 @@ const OpenAPI = {
29
29
  PASSWORD: void 0,
30
30
  TOKEN: getEnv("WM_TOKEN"),
31
31
  USERNAME: void 0,
32
- VERSION: "1.814.0",
32
+ VERSION: "1.816.0",
33
33
  WITH_CREDENTIALS: !getEnv("WM_RAW_APP"),
34
34
  interceptors: {
35
35
  request: new Interceptors(),
package/dist/index.js CHANGED
@@ -126,7 +126,7 @@ const OpenAPI = {
126
126
  PASSWORD: void 0,
127
127
  TOKEN: getEnv$1("WM_TOKEN"),
128
128
  USERNAME: void 0,
129
- VERSION: "1.814.0",
129
+ VERSION: "1.816.0",
130
130
  WITH_CREDENTIALS: !getEnv$1("WM_RAW_APP"),
131
131
  interceptors: {
132
132
  request: new Interceptors(),
@@ -3102,6 +3102,131 @@ var WorkspaceService = class {
3102
3102
  });
3103
3103
  }
3104
3104
  /**
3105
+ * get who may connect to a data table as which role
3106
+ * @param data The data for the request.
3107
+ * @param data.workspace
3108
+ * @param data.datatableName
3109
+ * @returns DatatablePermissions the data table's roles and their tenants
3110
+ * @throws ApiError
3111
+ */
3112
+ static getDatatablePermissions(data) {
3113
+ return request(OpenAPI, {
3114
+ method: "GET",
3115
+ url: "/w/{workspace}/workspaces/datatable_permissions/{datatable_name}",
3116
+ path: {
3117
+ workspace: data.workspace,
3118
+ datatable_name: data.datatableName
3119
+ }
3120
+ });
3121
+ }
3122
+ /**
3123
+ * set who may connect to a data table as which role
3124
+ * @param data The data for the request.
3125
+ * @param data.workspace
3126
+ * @param data.datatableName
3127
+ * @param data.requestBody
3128
+ * @returns string status
3129
+ * @throws ApiError
3130
+ */
3131
+ static setDatatablePermissions(data) {
3132
+ return request(OpenAPI, {
3133
+ method: "POST",
3134
+ url: "/w/{workspace}/workspaces/datatable_permissions/{datatable_name}",
3135
+ path: {
3136
+ workspace: data.workspace,
3137
+ datatable_name: data.datatableName
3138
+ },
3139
+ body: data.requestBody,
3140
+ mediaType: "application/json"
3141
+ });
3142
+ }
3143
+ /**
3144
+ * read the owner and grants of an instance data table's database, schema or table
3145
+ * @param data The data for the request.
3146
+ * @param data.workspace
3147
+ * @param data.datatableName
3148
+ * @param data.kind
3149
+ * @param data.schema
3150
+ * @param data.table
3151
+ * @returns DatatableAclInfo owner and grants
3152
+ * @throws ApiError
3153
+ */
3154
+ static getDatatableAcl(data) {
3155
+ return request(OpenAPI, {
3156
+ method: "GET",
3157
+ url: "/w/{workspace}/workspaces/datatable_acl/{datatable_name}",
3158
+ path: {
3159
+ workspace: data.workspace,
3160
+ datatable_name: data.datatableName
3161
+ },
3162
+ query: {
3163
+ kind: data.kind,
3164
+ schema: data.schema,
3165
+ table: data.table
3166
+ }
3167
+ });
3168
+ }
3169
+ /**
3170
+ * preview the SQL an ownership or grant change would run (data table administrators only)
3171
+ * @param data The data for the request.
3172
+ * @param data.workspace
3173
+ * @param data.datatableName
3174
+ * @param data.requestBody
3175
+ * @returns AclPlan statements that would run, in a single transaction
3176
+ * @throws ApiError
3177
+ */
3178
+ static planDatatableAcl(data) {
3179
+ return request(OpenAPI, {
3180
+ method: "POST",
3181
+ url: "/w/{workspace}/workspaces/datatable_acl/{datatable_name}/plan",
3182
+ path: {
3183
+ workspace: data.workspace,
3184
+ datatable_name: data.datatableName
3185
+ },
3186
+ body: data.requestBody,
3187
+ mediaType: "application/json"
3188
+ });
3189
+ }
3190
+ /**
3191
+ * run an ownership or grant change exactly as planned (data table administrators only)
3192
+ * @param data The data for the request.
3193
+ * @param data.workspace
3194
+ * @param data.datatableName
3195
+ * @param data.requestBody
3196
+ * @returns string change applied
3197
+ * @throws ApiError
3198
+ */
3199
+ static applyDatatableAcl(data) {
3200
+ return request(OpenAPI, {
3201
+ method: "POST",
3202
+ url: "/w/{workspace}/workspaces/datatable_acl/{datatable_name}/apply",
3203
+ path: {
3204
+ workspace: data.workspace,
3205
+ datatable_name: data.datatableName
3206
+ },
3207
+ body: data.requestBody,
3208
+ mediaType: "application/json"
3209
+ });
3210
+ }
3211
+ /**
3212
+ * list the data table roles the caller may connect as
3213
+ * @param data The data for the request.
3214
+ * @param data.workspace
3215
+ * @param data.datatableName
3216
+ * @returns unknown usable roles
3217
+ * @throws ApiError
3218
+ */
3219
+ static listUsableDatatableRoles(data) {
3220
+ return request(OpenAPI, {
3221
+ method: "GET",
3222
+ url: "/w/{workspace}/workspaces/datatable_usable_roles/{datatable_name}",
3223
+ path: {
3224
+ workspace: data.workspace,
3225
+ datatable_name: data.datatableName
3226
+ }
3227
+ });
3228
+ }
3229
+ /**
3105
3230
  * list schemas of all connected Datatables
3106
3231
  * @param data The data for the request.
3107
3232
  * @param data.workspace
@@ -3137,6 +3262,9 @@ var WorkspaceService = class {
3137
3262
  * list tables of all connected Datatables
3138
3263
  * @param data The data for the request.
3139
3264
  * @param data.workspace
3265
+ * @param data.datatableName list only this data table; each listed data table opens a connection to its database
3266
+ * @param data.roleFor the data table `role` applies to; every other one is listed as its default role
3267
+ * @param data.role the role to list `role_for` as; refused, in that entry's `error`, if the caller may not use it
3140
3268
  * @returns DataTableTables table metadata of all datatables
3141
3269
  * @throws ApiError
3142
3270
  */
@@ -3144,7 +3272,12 @@ var WorkspaceService = class {
3144
3272
  return request(OpenAPI, {
3145
3273
  method: "GET",
3146
3274
  url: "/w/{workspace}/workspaces/list_datatable_tables",
3147
- path: { workspace: data.workspace }
3275
+ path: { workspace: data.workspace },
3276
+ query: {
3277
+ datatable_name: data.datatableName,
3278
+ role_for: data.roleFor,
3279
+ role: data.role
3280
+ }
3148
3281
  });
3149
3282
  }
3150
3283
  /**
@@ -3154,6 +3287,7 @@ var WorkspaceService = class {
3154
3287
  * @param data.datatableName
3155
3288
  * @param data.schemaName
3156
3289
  * @param data.tableName
3290
+ * @param data.role the data table role to read the table as; defaults to the data table's default role
3157
3291
  * @returns DataTableTableSchema schema of one datatable table
3158
3292
  * @throws ApiError
3159
3293
  */
@@ -3165,7 +3299,8 @@ var WorkspaceService = class {
3165
3299
  query: {
3166
3300
  datatable_name: data.datatableName,
3167
3301
  schema_name: data.schemaName,
3168
- table_name: data.tableName
3302
+ table_name: data.tableName,
3303
+ role: data.role
3169
3304
  }
3170
3305
  });
3171
3306
  }
@@ -3628,6 +3763,24 @@ var WorkspaceService = class {
3628
3763
  });
3629
3764
  }
3630
3765
  /**
3766
+ * choose whether new forks of this workspace start with its admins and developers
3767
+ * When on, every fork created from this workspace gets the workspace's admins and developers as members, with the role they hold here; operators, disabled users and service accounts are left out. The setting is copied into each fork, so forks of a fork follow it too. Off by default. Workspace-admin gated.
3768
+ * @param data The data for the request.
3769
+ * @param data.workspace
3770
+ * @param data.requestBody Whether new forks start with this workspace's admins and developers
3771
+ * @returns string status
3772
+ * @throws ApiError
3773
+ */
3774
+ static editAddAdminsAndDevelopersToForks(data) {
3775
+ return request(OpenAPI, {
3776
+ method: "POST",
3777
+ url: "/w/{workspace}/workspaces/edit_add_admins_and_developers_to_forks",
3778
+ path: { workspace: data.workspace },
3779
+ body: data.requestBody,
3780
+ mediaType: "application/json"
3781
+ });
3782
+ }
3783
+ /**
3631
3784
  * set the key guest JWTs are verified against for this workspace
3632
3785
  * A guest JWT (`jwt_guest_`) is minted by the embedding customer's own backend and verified against this key: a PEM public key (RS/ES family, HS* refused) or a JWKS URL, at most one. Both empty clears the workspace key; off cloud, verification then falls back to the instance issuer (`JWT_EXT_JWKS_URL`) if one is set, else no guest JWT is accepted (`guest_access_enabled` is the on/off switch). Workspace-admin gated. The key is validated before it is stored. Setting a key is refused with a 400 where guests are unavailable (the shared cloud); clearing one always works.
3633
3786
  * @param data The data for the request.
@@ -4146,6 +4299,63 @@ var SettingService = class {
4146
4299
  });
4147
4300
  }
4148
4301
  /**
4302
+ * list the instance's data table roles
4303
+ * @returns InstanceDatatableRole the instance role catalog
4304
+ * @throws ApiError
4305
+ */
4306
+ static listInstanceDatatableRoles() {
4307
+ return request(OpenAPI, {
4308
+ method: "GET",
4309
+ url: "/settings/datatable_roles"
4310
+ });
4311
+ }
4312
+ /**
4313
+ * create a data table role on the instance's Postgres cluster
4314
+ * @param data The data for the request.
4315
+ * @param data.requestBody
4316
+ * @returns InstanceDatatableRole the created role
4317
+ * @throws ApiError
4318
+ */
4319
+ static createInstanceDatatableRole(data) {
4320
+ return request(OpenAPI, {
4321
+ method: "POST",
4322
+ url: "/settings/datatable_roles",
4323
+ body: data.requestBody,
4324
+ mediaType: "application/json"
4325
+ });
4326
+ }
4327
+ /**
4328
+ * rename a data table role or turn its login on and off
4329
+ * @param data The data for the request.
4330
+ * @param data.id
4331
+ * @param data.requestBody
4332
+ * @returns InstanceDatatableRole the updated role
4333
+ * @throws ApiError
4334
+ */
4335
+ static updateInstanceDatatableRole(data) {
4336
+ return request(OpenAPI, {
4337
+ method: "POST",
4338
+ url: "/settings/datatable_roles/{id}",
4339
+ path: { id: data.id },
4340
+ body: data.requestBody,
4341
+ mediaType: "application/json"
4342
+ });
4343
+ }
4344
+ /**
4345
+ * drop a data table role from the cluster and from every workspace that named it
4346
+ * @param data The data for the request.
4347
+ * @param data.id
4348
+ * @returns unknown deleted
4349
+ * @throws ApiError
4350
+ */
4351
+ static deleteInstanceDatatableRole(data) {
4352
+ return request(OpenAPI, {
4353
+ method: "DELETE",
4354
+ url: "/settings/datatable_roles/{id}",
4355
+ path: { id: data.id }
4356
+ });
4357
+ }
4358
+ /**
4149
4359
  * Runs CREATE DATABASE on the Windmill Postgres and grants access to the custom_instance_user
4150
4360
  * @param data The data for the request.
4151
4361
  * @param data.name The name of the database to create
@@ -6251,6 +6461,8 @@ var FlowService = class {
6251
6461
  * @param data The data for the request.
6252
6462
  * @param data.workspace
6253
6463
  * @param data.path
6464
+ * @param data.page which page to return (start at 1, default 1)
6465
+ * @param data.perPage number of items to return for a given page (default 30, max 100)
6254
6466
  * @returns FlowVersion Flow history
6255
6467
  * @throws ApiError
6256
6468
  */
@@ -6261,6 +6473,10 @@ var FlowService = class {
6261
6473
  path: {
6262
6474
  workspace: data.workspace,
6263
6475
  path: data.path
6476
+ },
6477
+ query: {
6478
+ page: data.page,
6479
+ per_page: data.perPage
6264
6480
  }
6265
6481
  });
6266
6482
  }
@@ -6860,6 +7076,8 @@ var AppService = class {
6860
7076
  * @param data The data for the request.
6861
7077
  * @param data.workspace
6862
7078
  * @param data.path
7079
+ * @param data.page which page to return (start at 1, default 1)
7080
+ * @param data.perPage number of items to return for a given page (default 30, max 100)
6863
7081
  * @returns AppHistory app history
6864
7082
  * @throws ApiError
6865
7083
  */
@@ -6870,6 +7088,10 @@ var AppService = class {
6870
7088
  path: {
6871
7089
  workspace: data.workspace,
6872
7090
  path: data.path
7091
+ },
7092
+ query: {
7093
+ page: data.page,
7094
+ per_page: data.perPage
6873
7095
  }
6874
7096
  });
6875
7097
  }
@@ -7088,7 +7310,7 @@ var AppService = class {
7088
7310
  * @param data.workspace
7089
7311
  * @param data.path
7090
7312
  * @param data.requestBody update app
7091
- * @returns string app updated
7313
+ * @returns AppDeployed app updated
7092
7314
  * @throws ApiError
7093
7315
  */
7094
7316
  static updateApp(data) {
@@ -7126,7 +7348,7 @@ var AppService = class {
7126
7348
  * @param data.workspace
7127
7349
  * @param data.path
7128
7350
  * @param data.requestBody raw app sources to bundle and deploy
7129
- * @returns string app updated
7351
+ * @returns AppDeployed app updated
7130
7352
  * @throws ApiError
7131
7353
  */
7132
7354
  static updateAppRawSource(data) {
@@ -7147,7 +7369,7 @@ var AppService = class {
7147
7369
  * @param data.workspace
7148
7370
  * @param data.path
7149
7371
  * @param data.formData update app
7150
- * @returns string app updated
7372
+ * @returns AppDeployed app updated
7151
7373
  * @throws ApiError
7152
7374
  */
7153
7375
  static updateAppRaw(data) {
@@ -7907,6 +8129,8 @@ var ScriptService = class {
7907
8129
  * @param data The data for the request.
7908
8130
  * @param data.workspace
7909
8131
  * @param data.path
8132
+ * @param data.page which page to return (start at 1, default 1)
8133
+ * @param data.perPage number of items to return for a given page (default 30, max 100)
7910
8134
  * @returns ScriptHistory script history
7911
8135
  * @throws ApiError
7912
8136
  */
@@ -7917,6 +8141,10 @@ var ScriptService = class {
7917
8141
  path: {
7918
8142
  workspace: data.workspace,
7919
8143
  path: data.path
8144
+ },
8145
+ query: {
8146
+ page: data.page,
8147
+ per_page: data.perPage
7920
8148
  }
7921
8149
  });
7922
8150
  }
@@ -8353,6 +8581,30 @@ var DraftService = class {
8353
8581
  });
8354
8582
  }
8355
8583
  /**
8584
+ * move the current user's draft-only item to another path
8585
+ * Relocates the authed user's own draft row, along with both path keys inside its value (the typed path and the mirror the editors keep beside it). Only for draft-only items — a deployed item must be moved through its own deploy endpoint, which carries every draft with it. Restricted to script, flow, app and raw_app; any other kind is rejected with 400, because only these keep their deploy target where this endpoint rewrites it.
8586
+ * @param data The data for the request.
8587
+ * @param data.workspace
8588
+ * @param data.kind script, flow, app or raw_app only.
8589
+ * @param data.path
8590
+ * @param data.requestBody
8591
+ * @returns string move result
8592
+ * @throws ApiError
8593
+ */
8594
+ static moveDraft(data) {
8595
+ return request(OpenAPI, {
8596
+ method: "POST",
8597
+ url: "/w/{workspace}/drafts/move/{kind}/{path}",
8598
+ path: {
8599
+ workspace: data.workspace,
8600
+ kind: data.kind,
8601
+ path: data.path
8602
+ },
8603
+ body: data.requestBody,
8604
+ mediaType: "application/json"
8605
+ });
8606
+ }
8607
+ /**
8356
8608
  * resolve a legacy (workspace-level) draft (admin only)
8357
8609
  * Delete a legacy draft (email NULL) or assign it to the authed admin as a per-user draft. Workspace admins / superadmins only.
8358
8610
  * @param data The data for the request.
@@ -18216,11 +18468,14 @@ var RawSql = class {
18216
18468
  this.value = value;
18217
18469
  }
18218
18470
  };
18219
- function datatableProvider(name, schema) {
18471
+ const ROLE_NAME_RE = /^[A-Za-z0-9_-]{1,63}$/;
18472
+ function datatableProvider(name, schema, role) {
18473
+ if (role !== void 0 && !ROLE_NAME_RE.test(role)) throw new Error(`Invalid data table role '${role}': only letters, digits, '_' and '-' are allowed`);
18220
18474
  return {
18221
18475
  providerName: "datatable",
18222
18476
  language: "postgresql",
18223
18477
  extraArgs: { database: `datatable://${name}` },
18478
+ annotations: () => role !== void 0 ? `-- role ${role}\n` : "",
18224
18479
  formatArgDecl: (argNum) => `-- $${argNum} arg${argNum}`,
18225
18480
  formatArgUsage: (argNum, explicitType, inferredType) => explicitType !== void 0 ? `$${argNum}` : `$${argNum}::${inferredType}`,
18226
18481
  preamble: () => schema ? `SET search_path TO "${schema}";\n` : ""
@@ -18231,6 +18486,7 @@ function ducklakeProvider(name, schema) {
18231
18486
  providerName: "ducklake",
18232
18487
  language: "duckdb",
18233
18488
  extraArgs: {},
18489
+ annotations: () => "",
18234
18490
  formatArgDecl: (argNum, argType) => `-- $arg${argNum} (${argType})`,
18235
18491
  formatArgUsage: (argNum) => `$arg${argNum}`,
18236
18492
  preamble: () => `ATTACH 'ducklake://${name}' AS dl;USE dl${schema ? `."${schema}"` : ""};\n`
@@ -18318,7 +18574,8 @@ function buildSqlTemplateFunction(provider) {
18318
18574
  let argType = parseTypeAnnotation(strings[info.originalIndex], strings[info.originalIndex + 1]) || inferSqlType(info.value);
18319
18575
  return provider.formatArgDecl(info.argNum, argType);
18320
18576
  });
18321
- let content = argDecls.length ? argDecls.join("\n") + "\n" : "";
18577
+ let content = provider.annotations();
18578
+ content += argDecls.length ? argDecls.join("\n") + "\n" : "";
18322
18579
  content += provider.preamble();
18323
18580
  let contentBody = "";
18324
18581
  for (let i = 0; i < strings.length; i++) {
@@ -18346,6 +18603,8 @@ function buildSqlTemplateFunction(provider) {
18346
18603
  /**
18347
18604
  * Create a SQL template function for PostgreSQL/datatable queries
18348
18605
  * @param name - Database/datatable name (default: "main")
18606
+ * @param opts.role - Connect as this data table role instead of the data table's default one.
18607
+ * Only meaningful on a data table under roles, and only for a role you are a tenant of.
18349
18608
  * @returns SQL template function for building parameterized queries
18350
18609
  * @example
18351
18610
  * let sql = wmill.datatable()
@@ -18355,15 +18614,18 @@ function buildSqlTemplateFunction(provider) {
18355
18614
  * SELECT * FROM friends
18356
18615
  * WHERE name = ${name} AND age = ${age}::int
18357
18616
  * `.fetch()
18617
+ * @example
18618
+ * // Read through a restricted role
18619
+ * let sql = wmill.datatable("main", { role: "analytics" })
18358
18620
  */
18359
- function datatable(name = "main") {
18621
+ function datatable(name = "main", opts) {
18360
18622
  let { name: n, schema } = parseName(name);
18361
- let provider = datatableProvider(n, schema);
18623
+ let provider = datatableProvider(n, schema, opts?.role);
18362
18624
  let sqlFn = buildSqlTemplateFunction(provider);
18363
18625
  sqlFn.query = (sqlString, ...params) => {
18364
18626
  let argDecls = params.map((v, i) => `-- $${i + 1} arg${i + 1} (${inferSqlType(v)})`).join("\n");
18365
18627
  let contentBody = sqlString;
18366
- let content = (argDecls ? argDecls + "\n" : "") + provider.preamble() + sqlString;
18628
+ let content = provider.annotations() + (argDecls ? argDecls + "\n" : "") + provider.preamble() + sqlString;
18367
18629
  let args = {
18368
18630
  ...Object.fromEntries(params.map((v, i) => [`arg${i + 1}`, serializeArgValue(v)])),
18369
18631
  ...provider.extraArgs