Skip to content

Commit

Permalink
fix(backend): apps backend v0 (#888)
Browse files Browse the repository at this point in the history
* progress

* post merge

* progress

* fix

* fix

* fix

* fix

* v1

* fix openapi
  • Loading branch information
rubenfiszel committed Nov 12, 2022
1 parent df11f50 commit 2d9e990
Show file tree
Hide file tree
Showing 9 changed files with 857 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions backend/migrations/20221024225533_apps.down.sql
@@ -0,0 +1,4 @@
-- Add down migration script here
DROP TABLE app;
DROP TABLE app_version;
DROP TYPE EXECUTION_MODE;
25 changes: 25 additions & 0 deletions backend/migrations/20221024225533_apps.up.sql
@@ -0,0 +1,25 @@
-- Add up migration script here
CREATE TABLE app (
id BIGSERIAL PRIMARY KEY,
workspace_id VARCHAR(50) NOT NULL REFERENCES workspace(id),
path varchar(255) NOT NULL,
summary VARCHAR(1000) NOT NULL DEFAULT '',
policy JSONB NOT NULL,
versions BIGINT[] NOT NULL,
extra_perms JSONB NOT NULL DEFAULT '{}'
);

CREATE TABLE app_version(
id BIGSERIAL PRIMARY KEY,
flow_id BIGINT NOT NULL,
value JSONB NOT NULL,
created_by VARCHAR(50) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
FOREIGN KEY (flow_id) REFERENCES app(id) ON DELETE CASCADE
);

CREATE POLICY see_own ON app FOR ALL
USING (SPLIT_PART(app.path, '/', 1) = 'u' AND SPLIT_PART(app.path, '/', 2) = current_setting('session.user'));

CREATE POLICY see_member ON app FOR ALL
USING (SPLIT_PART(app.path, '/', 1) = 'g' AND SPLIT_PART(app.path, '/', 2) = any(regexp_split_to_array(current_setting('session.groups'), ',')::text[]));
1 change: 1 addition & 0 deletions backend/windmill-api/Cargo.toml
Expand Up @@ -64,3 +64,4 @@ tokio-util.workspace = true
tokio-tar.workspace = true
hmac.workspace = true
cookie.workspace = true
sha2.workspace = true
263 changes: 263 additions & 0 deletions backend/windmill-api/openapi.yaml
Expand Up @@ -2301,6 +2301,203 @@ paths:
schema:
type: string

/w/{workspace}/apps/list:
get:
summary: list all available apps
operationId: listApps
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/Page"
- $ref: "#/components/parameters/PerPage"
- $ref: "#/components/parameters/OrderDesc"
- $ref: "#/components/parameters/CreatedBy"
- name: path_start
description: mask to filter matching starting path
in: query
schema:
type: string
- name: path_exact
description: mask to filter exact matching path
in: query
schema:
type: string
responses:
"200":
description: All available apps
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/ListableApp"

/w/{workspace}/apps/get/p/{path}:
get:
summary: get app by path
operationId: getAppByPath
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/ScriptPath"
responses:
"200":
description: app details
content:
application/json:
schema:
$ref: "#/components/schemas/AppWithLastVersion"

/w/{workspace}/apps/get/v/{id}:
get:
summary: get app by version
operationId: getAppByVersion
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/PathId"
responses:
"200":
description: app details
content:
application/json:
schema:
$ref: "#/components/schemas/AppWithLastVersion"

/w/{workspace}/apps/create:
post:
summary: create app
operationId: createApp
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
requestBody:
description: new app
required: true
content:
application/json:
schema:
type: object
properties:
path:
type: string
value: {}
summary:
type: string
policy:
$ref: "#/components/schemas/Policy"
required:
- path
- value
- summary
- policy
responses:
"201":
description: app created
content:
text/plain:
schema:
type: string

/w/{workspace}/apps/delete/{path}:
delete:
summary: delete app
operationId: deleteApp
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/Path"
responses:
"200":
description: app deleted
content:
text/plain:
schema:
type: string

/w/{workspace}/apps/update/{path}:
post:
summary: update app
operationId: updateApp
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/ScriptPath"
requestBody:
description: update app
required: true
content:
application/json:
schema:
type: object
properties:
path:
type: string
summary:
type: string
value: {}
policy:
$ref: "#/components/schemas/Policy"
responses:
"200":
description: app updated
content:
text/plain:
schema:
type: string

/w/{workspace}/apps/execute_component/{path}:
post:
summary: executeComponent
operationId: executeComponent
tags:
- app
parameters:
- $ref: "#/components/parameters/WorkspaceId"
- $ref: "#/components/parameters/ScriptPath"
requestBody:
description: update app
required: true
content:
application/json:
schema:
type: object
properties:
#script: script/<path>
#flow: flow/<path>
path:
type: string
args: {}
raw_code:
type: object
properties:
content:
type: string
language:
type: string
path:
type: string
required:
- content
- language
required:
- args

responses:
"200":
description: job uuid
content:
text/plain:
schema:
type: string


/w/{workspace}/jobs/run/f/{path}:
post:
summary: run flow by path
Expand Down Expand Up @@ -4496,6 +4693,72 @@ components:
- content
- args

Policy:
type: object
properties:
triggerables:
type: object
additionalProperties:
type: object
execution_mode:
type: string
enum: [viewer, publisher, anonymous]
on_behalf_of:
type: string


ListableApp:
type: object
properties:
id:
type: integer
workspace_id:
type: string
path:
type: string
summary:
type: string
version:
type: integer
extra_perms:
type: object
additionalProperties:
type: boolean
execution_mode:
type: string
enum: [viewer, publisher, anonymous]

AppWithLastVersion:
type: object
properties:
id:
type: integer
workspace_id:
type: string
path:
type: string
summary:
type: string
versions:
type: array
items:
type: integer
created_by:
type: string
created_at:
type: string
format: date-time
value: {}
policy:
$ref: "#/components/schemas/Policy"
execution_mode:
type: string
enum: [viewer, publisher, anonymous]
extra_perms:
type: object
additionalProperties:
type: boolean

SlackToken:
type: object
properties:
Expand Down

0 comments on commit 2d9e990

Please sign in to comment.