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.
@@ -2734,6 +2734,131 @@ var WorkspaceService = class {
2734
2734
  });
2735
2735
  }
2736
2736
  /**
2737
+ * get who may connect to a data table as which role
2738
+ * @param data The data for the request.
2739
+ * @param data.workspace
2740
+ * @param data.datatableName
2741
+ * @returns DatatablePermissions the data table's roles and their tenants
2742
+ * @throws ApiError
2743
+ */
2744
+ static getDatatablePermissions(data) {
2745
+ return request(OpenAPI, {
2746
+ method: "GET",
2747
+ url: "/w/{workspace}/workspaces/datatable_permissions/{datatable_name}",
2748
+ path: {
2749
+ workspace: data.workspace,
2750
+ datatable_name: data.datatableName
2751
+ }
2752
+ });
2753
+ }
2754
+ /**
2755
+ * set who may connect to a data table as which role
2756
+ * @param data The data for the request.
2757
+ * @param data.workspace
2758
+ * @param data.datatableName
2759
+ * @param data.requestBody
2760
+ * @returns string status
2761
+ * @throws ApiError
2762
+ */
2763
+ static setDatatablePermissions(data) {
2764
+ return request(OpenAPI, {
2765
+ method: "POST",
2766
+ url: "/w/{workspace}/workspaces/datatable_permissions/{datatable_name}",
2767
+ path: {
2768
+ workspace: data.workspace,
2769
+ datatable_name: data.datatableName
2770
+ },
2771
+ body: data.requestBody,
2772
+ mediaType: "application/json"
2773
+ });
2774
+ }
2775
+ /**
2776
+ * read the owner and grants of an instance data table's database, schema or table
2777
+ * @param data The data for the request.
2778
+ * @param data.workspace
2779
+ * @param data.datatableName
2780
+ * @param data.kind
2781
+ * @param data.schema
2782
+ * @param data.table
2783
+ * @returns DatatableAclInfo owner and grants
2784
+ * @throws ApiError
2785
+ */
2786
+ static getDatatableAcl(data) {
2787
+ return request(OpenAPI, {
2788
+ method: "GET",
2789
+ url: "/w/{workspace}/workspaces/datatable_acl/{datatable_name}",
2790
+ path: {
2791
+ workspace: data.workspace,
2792
+ datatable_name: data.datatableName
2793
+ },
2794
+ query: {
2795
+ kind: data.kind,
2796
+ schema: data.schema,
2797
+ table: data.table
2798
+ }
2799
+ });
2800
+ }
2801
+ /**
2802
+ * preview the SQL an ownership or grant change would run (data table administrators only)
2803
+ * @param data The data for the request.
2804
+ * @param data.workspace
2805
+ * @param data.datatableName
2806
+ * @param data.requestBody
2807
+ * @returns AclPlan statements that would run, in a single transaction
2808
+ * @throws ApiError
2809
+ */
2810
+ static planDatatableAcl(data) {
2811
+ return request(OpenAPI, {
2812
+ method: "POST",
2813
+ url: "/w/{workspace}/workspaces/datatable_acl/{datatable_name}/plan",
2814
+ path: {
2815
+ workspace: data.workspace,
2816
+ datatable_name: data.datatableName
2817
+ },
2818
+ body: data.requestBody,
2819
+ mediaType: "application/json"
2820
+ });
2821
+ }
2822
+ /**
2823
+ * run an ownership or grant change exactly as planned (data table administrators only)
2824
+ * @param data The data for the request.
2825
+ * @param data.workspace
2826
+ * @param data.datatableName
2827
+ * @param data.requestBody
2828
+ * @returns string change applied
2829
+ * @throws ApiError
2830
+ */
2831
+ static applyDatatableAcl(data) {
2832
+ return request(OpenAPI, {
2833
+ method: "POST",
2834
+ url: "/w/{workspace}/workspaces/datatable_acl/{datatable_name}/apply",
2835
+ path: {
2836
+ workspace: data.workspace,
2837
+ datatable_name: data.datatableName
2838
+ },
2839
+ body: data.requestBody,
2840
+ mediaType: "application/json"
2841
+ });
2842
+ }
2843
+ /**
2844
+ * list the data table roles the caller may connect as
2845
+ * @param data The data for the request.
2846
+ * @param data.workspace
2847
+ * @param data.datatableName
2848
+ * @returns unknown usable roles
2849
+ * @throws ApiError
2850
+ */
2851
+ static listUsableDatatableRoles(data) {
2852
+ return request(OpenAPI, {
2853
+ method: "GET",
2854
+ url: "/w/{workspace}/workspaces/datatable_usable_roles/{datatable_name}",
2855
+ path: {
2856
+ workspace: data.workspace,
2857
+ datatable_name: data.datatableName
2858
+ }
2859
+ });
2860
+ }
2861
+ /**
2737
2862
  * list schemas of all connected Datatables
2738
2863
  * @param data The data for the request.
2739
2864
  * @param data.workspace
@@ -2769,6 +2894,9 @@ var WorkspaceService = class {
2769
2894
  * list tables of all connected Datatables
2770
2895
  * @param data The data for the request.
2771
2896
  * @param data.workspace
2897
+ * @param data.datatableName list only this data table; each listed data table opens a connection to its database
2898
+ * @param data.roleFor the data table `role` applies to; every other one is listed as its default role
2899
+ * @param data.role the role to list `role_for` as; refused, in that entry's `error`, if the caller may not use it
2772
2900
  * @returns DataTableTables table metadata of all datatables
2773
2901
  * @throws ApiError
2774
2902
  */
@@ -2776,7 +2904,12 @@ var WorkspaceService = class {
2776
2904
  return request(OpenAPI, {
2777
2905
  method: "GET",
2778
2906
  url: "/w/{workspace}/workspaces/list_datatable_tables",
2779
- path: { workspace: data.workspace }
2907
+ path: { workspace: data.workspace },
2908
+ query: {
2909
+ datatable_name: data.datatableName,
2910
+ role_for: data.roleFor,
2911
+ role: data.role
2912
+ }
2780
2913
  });
2781
2914
  }
2782
2915
  /**
@@ -2786,6 +2919,7 @@ var WorkspaceService = class {
2786
2919
  * @param data.datatableName
2787
2920
  * @param data.schemaName
2788
2921
  * @param data.tableName
2922
+ * @param data.role the data table role to read the table as; defaults to the data table's default role
2789
2923
  * @returns DataTableTableSchema schema of one datatable table
2790
2924
  * @throws ApiError
2791
2925
  */
@@ -2797,7 +2931,8 @@ var WorkspaceService = class {
2797
2931
  query: {
2798
2932
  datatable_name: data.datatableName,
2799
2933
  schema_name: data.schemaName,
2800
- table_name: data.tableName
2934
+ table_name: data.tableName,
2935
+ role: data.role
2801
2936
  }
2802
2937
  });
2803
2938
  }
@@ -3260,6 +3395,24 @@ var WorkspaceService = class {
3260
3395
  });
3261
3396
  }
3262
3397
  /**
3398
+ * choose whether new forks of this workspace start with its admins and developers
3399
+ * 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.
3400
+ * @param data The data for the request.
3401
+ * @param data.workspace
3402
+ * @param data.requestBody Whether new forks start with this workspace's admins and developers
3403
+ * @returns string status
3404
+ * @throws ApiError
3405
+ */
3406
+ static editAddAdminsAndDevelopersToForks(data) {
3407
+ return request(OpenAPI, {
3408
+ method: "POST",
3409
+ url: "/w/{workspace}/workspaces/edit_add_admins_and_developers_to_forks",
3410
+ path: { workspace: data.workspace },
3411
+ body: data.requestBody,
3412
+ mediaType: "application/json"
3413
+ });
3414
+ }
3415
+ /**
3263
3416
  * set the key guest JWTs are verified against for this workspace
3264
3417
  * 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.
3265
3418
  * @param data The data for the request.
@@ -3778,6 +3931,63 @@ var SettingService = class {
3778
3931
  });
3779
3932
  }
3780
3933
  /**
3934
+ * list the instance's data table roles
3935
+ * @returns InstanceDatatableRole the instance role catalog
3936
+ * @throws ApiError
3937
+ */
3938
+ static listInstanceDatatableRoles() {
3939
+ return request(OpenAPI, {
3940
+ method: "GET",
3941
+ url: "/settings/datatable_roles"
3942
+ });
3943
+ }
3944
+ /**
3945
+ * create a data table role on the instance's Postgres cluster
3946
+ * @param data The data for the request.
3947
+ * @param data.requestBody
3948
+ * @returns InstanceDatatableRole the created role
3949
+ * @throws ApiError
3950
+ */
3951
+ static createInstanceDatatableRole(data) {
3952
+ return request(OpenAPI, {
3953
+ method: "POST",
3954
+ url: "/settings/datatable_roles",
3955
+ body: data.requestBody,
3956
+ mediaType: "application/json"
3957
+ });
3958
+ }
3959
+ /**
3960
+ * rename a data table role or turn its login on and off
3961
+ * @param data The data for the request.
3962
+ * @param data.id
3963
+ * @param data.requestBody
3964
+ * @returns InstanceDatatableRole the updated role
3965
+ * @throws ApiError
3966
+ */
3967
+ static updateInstanceDatatableRole(data) {
3968
+ return request(OpenAPI, {
3969
+ method: "POST",
3970
+ url: "/settings/datatable_roles/{id}",
3971
+ path: { id: data.id },
3972
+ body: data.requestBody,
3973
+ mediaType: "application/json"
3974
+ });
3975
+ }
3976
+ /**
3977
+ * drop a data table role from the cluster and from every workspace that named it
3978
+ * @param data The data for the request.
3979
+ * @param data.id
3980
+ * @returns unknown deleted
3981
+ * @throws ApiError
3982
+ */
3983
+ static deleteInstanceDatatableRole(data) {
3984
+ return request(OpenAPI, {
3985
+ method: "DELETE",
3986
+ url: "/settings/datatable_roles/{id}",
3987
+ path: { id: data.id }
3988
+ });
3989
+ }
3990
+ /**
3781
3991
  * Runs CREATE DATABASE on the Windmill Postgres and grants access to the custom_instance_user
3782
3992
  * @param data The data for the request.
3783
3993
  * @param data.name The name of the database to create
@@ -5883,6 +6093,8 @@ var FlowService = class {
5883
6093
  * @param data The data for the request.
5884
6094
  * @param data.workspace
5885
6095
  * @param data.path
6096
+ * @param data.page which page to return (start at 1, default 1)
6097
+ * @param data.perPage number of items to return for a given page (default 30, max 100)
5886
6098
  * @returns FlowVersion Flow history
5887
6099
  * @throws ApiError
5888
6100
  */
@@ -5893,6 +6105,10 @@ var FlowService = class {
5893
6105
  path: {
5894
6106
  workspace: data.workspace,
5895
6107
  path: data.path
6108
+ },
6109
+ query: {
6110
+ page: data.page,
6111
+ per_page: data.perPage
5896
6112
  }
5897
6113
  });
5898
6114
  }
@@ -6492,6 +6708,8 @@ var AppService = class {
6492
6708
  * @param data The data for the request.
6493
6709
  * @param data.workspace
6494
6710
  * @param data.path
6711
+ * @param data.page which page to return (start at 1, default 1)
6712
+ * @param data.perPage number of items to return for a given page (default 30, max 100)
6495
6713
  * @returns AppHistory app history
6496
6714
  * @throws ApiError
6497
6715
  */
@@ -6502,6 +6720,10 @@ var AppService = class {
6502
6720
  path: {
6503
6721
  workspace: data.workspace,
6504
6722
  path: data.path
6723
+ },
6724
+ query: {
6725
+ page: data.page,
6726
+ per_page: data.perPage
6505
6727
  }
6506
6728
  });
6507
6729
  }
@@ -6720,7 +6942,7 @@ var AppService = class {
6720
6942
  * @param data.workspace
6721
6943
  * @param data.path
6722
6944
  * @param data.requestBody update app
6723
- * @returns string app updated
6945
+ * @returns AppDeployed app updated
6724
6946
  * @throws ApiError
6725
6947
  */
6726
6948
  static updateApp(data) {
@@ -6758,7 +6980,7 @@ var AppService = class {
6758
6980
  * @param data.workspace
6759
6981
  * @param data.path
6760
6982
  * @param data.requestBody raw app sources to bundle and deploy
6761
- * @returns string app updated
6983
+ * @returns AppDeployed app updated
6762
6984
  * @throws ApiError
6763
6985
  */
6764
6986
  static updateAppRawSource(data) {
@@ -6779,7 +7001,7 @@ var AppService = class {
6779
7001
  * @param data.workspace
6780
7002
  * @param data.path
6781
7003
  * @param data.formData update app
6782
- * @returns string app updated
7004
+ * @returns AppDeployed app updated
6783
7005
  * @throws ApiError
6784
7006
  */
6785
7007
  static updateAppRaw(data) {
@@ -7539,6 +7761,8 @@ var ScriptService = class {
7539
7761
  * @param data The data for the request.
7540
7762
  * @param data.workspace
7541
7763
  * @param data.path
7764
+ * @param data.page which page to return (start at 1, default 1)
7765
+ * @param data.perPage number of items to return for a given page (default 30, max 100)
7542
7766
  * @returns ScriptHistory script history
7543
7767
  * @throws ApiError
7544
7768
  */
@@ -7549,6 +7773,10 @@ var ScriptService = class {
7549
7773
  path: {
7550
7774
  workspace: data.workspace,
7551
7775
  path: data.path
7776
+ },
7777
+ query: {
7778
+ page: data.page,
7779
+ per_page: data.perPage
7552
7780
  }
7553
7781
  });
7554
7782
  }
@@ -7985,6 +8213,30 @@ var DraftService = class {
7985
8213
  });
7986
8214
  }
7987
8215
  /**
8216
+ * move the current user's draft-only item to another path
8217
+ * 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.
8218
+ * @param data The data for the request.
8219
+ * @param data.workspace
8220
+ * @param data.kind script, flow, app or raw_app only.
8221
+ * @param data.path
8222
+ * @param data.requestBody
8223
+ * @returns string move result
8224
+ * @throws ApiError
8225
+ */
8226
+ static moveDraft(data) {
8227
+ return request(OpenAPI, {
8228
+ method: "POST",
8229
+ url: "/w/{workspace}/drafts/move/{kind}/{path}",
8230
+ path: {
8231
+ workspace: data.workspace,
8232
+ kind: data.kind,
8233
+ path: data.path
8234
+ },
8235
+ body: data.requestBody,
8236
+ mediaType: "application/json"
8237
+ });
8238
+ }
8239
+ /**
7988
8240
  * resolve a legacy (workspace-level) draft (admin only)
7989
8241
  * Delete a legacy draft (email NULL) or assign it to the authed admin as a per-user draft. Workspace admins / superadmins only.
7990
8242
  * @param data The data for the request.
@@ -55,9 +55,15 @@ export interface SqlTemplateFunction {
55
55
  export interface DatatableSqlTemplateFunction extends SqlTemplateFunction {
56
56
  query<T = any>(sql: string, ...params: any[]): SqlStatement<T>;
57
57
  }
58
+ export interface DatatableOptions {
59
+ /** The data table role to connect as. Omit to get the data table's default role. */
60
+ role?: string;
61
+ }
58
62
  /**
59
63
  * Create a SQL template function for PostgreSQL/datatable queries
60
64
  * @param name - Database/datatable name (default: "main")
65
+ * @param opts.role - Connect as this data table role instead of the data table's default one.
66
+ * Only meaningful on a data table under roles, and only for a role you are a tenant of.
61
67
  * @returns SQL template function for building parameterized queries
62
68
  * @example
63
69
  * let sql = wmill.datatable()
@@ -67,8 +73,11 @@ export interface DatatableSqlTemplateFunction extends SqlTemplateFunction {
67
73
  * SELECT * FROM friends
68
74
  * WHERE name = ${name} AND age = ${age}::int
69
75
  * `.fetch()
76
+ * @example
77
+ * // Read through a restricted role
78
+ * let sql = wmill.datatable("main", { role: "analytics" })
70
79
  */
71
- export declare function datatable(name?: string): DatatableSqlTemplateFunction;
80
+ export declare function datatable(name?: string, opts?: DatatableOptions): DatatableSqlTemplateFunction;
72
81
  /**
73
82
  * Create a SQL template function for DuckDB/ducklake queries
74
83
  * @param name - DuckDB database name, optionally with a schema as `name:schema` (default: "main")
package/dist/sqlUtils.mjs CHANGED
@@ -13,11 +13,14 @@ var RawSql = class {
13
13
  this.value = value;
14
14
  }
15
15
  };
16
- function datatableProvider(name, schema) {
16
+ const ROLE_NAME_RE = /^[A-Za-z0-9_-]{1,63}$/;
17
+ function datatableProvider(name, schema, role) {
18
+ if (role !== void 0 && !ROLE_NAME_RE.test(role)) throw new Error(`Invalid data table role '${role}': only letters, digits, '_' and '-' are allowed`);
17
19
  return {
18
20
  providerName: "datatable",
19
21
  language: "postgresql",
20
22
  extraArgs: { database: `datatable://${name}` },
23
+ annotations: () => role !== void 0 ? `-- role ${role}\n` : "",
21
24
  formatArgDecl: (argNum) => `-- $${argNum} arg${argNum}`,
22
25
  formatArgUsage: (argNum, explicitType, inferredType) => explicitType !== void 0 ? `$${argNum}` : `$${argNum}::${inferredType}`,
23
26
  preamble: () => schema ? `SET search_path TO "${schema}";\n` : ""
@@ -28,6 +31,7 @@ function ducklakeProvider(name, schema) {
28
31
  providerName: "ducklake",
29
32
  language: "duckdb",
30
33
  extraArgs: {},
34
+ annotations: () => "",
31
35
  formatArgDecl: (argNum, argType) => `-- $arg${argNum} (${argType})`,
32
36
  formatArgUsage: (argNum) => `$arg${argNum}`,
33
37
  preamble: () => `ATTACH 'ducklake://${name}' AS dl;USE dl${schema ? `."${schema}"` : ""};\n`
@@ -115,7 +119,8 @@ function buildSqlTemplateFunction(provider) {
115
119
  let argType = parseTypeAnnotation(strings[info.originalIndex], strings[info.originalIndex + 1]) || inferSqlType(info.value);
116
120
  return provider.formatArgDecl(info.argNum, argType);
117
121
  });
118
- let content = argDecls.length ? argDecls.join("\n") + "\n" : "";
122
+ let content = provider.annotations();
123
+ content += argDecls.length ? argDecls.join("\n") + "\n" : "";
119
124
  content += provider.preamble();
120
125
  let contentBody = "";
121
126
  for (let i = 0; i < strings.length; i++) {
@@ -143,6 +148,8 @@ function buildSqlTemplateFunction(provider) {
143
148
  /**
144
149
  * Create a SQL template function for PostgreSQL/datatable queries
145
150
  * @param name - Database/datatable name (default: "main")
151
+ * @param opts.role - Connect as this data table role instead of the data table's default one.
152
+ * Only meaningful on a data table under roles, and only for a role you are a tenant of.
146
153
  * @returns SQL template function for building parameterized queries
147
154
  * @example
148
155
  * let sql = wmill.datatable()
@@ -152,15 +159,18 @@ function buildSqlTemplateFunction(provider) {
152
159
  * SELECT * FROM friends
153
160
  * WHERE name = ${name} AND age = ${age}::int
154
161
  * `.fetch()
162
+ * @example
163
+ * // Read through a restricted role
164
+ * let sql = wmill.datatable("main", { role: "analytics" })
155
165
  */
156
- function datatable(name = "main") {
166
+ function datatable(name = "main", opts) {
157
167
  let { name: n, schema } = parseName(name);
158
- let provider = datatableProvider(n, schema);
168
+ let provider = datatableProvider(n, schema, opts?.role);
159
169
  let sqlFn = buildSqlTemplateFunction(provider);
160
170
  sqlFn.query = (sqlString, ...params) => {
161
171
  let argDecls = params.map((v, i) => `-- $${i + 1} arg${i + 1} (${inferSqlType(v)})`).join("\n");
162
172
  let contentBody = sqlString;
163
- let content = (argDecls ? argDecls + "\n" : "") + provider.preamble() + sqlString;
173
+ let content = provider.annotations() + (argDecls ? argDecls + "\n" : "") + provider.preamble() + sqlString;
164
174
  let args = {
165
175
  ...Object.fromEntries(params.map((v, i) => [`arg${i + 1}`, serializeArgValue(v)])),
166
176
  ...provider.extraArgs