-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2937: feat(lang-js, dal, sdf-server): Add ability to set documentation for a prop r=stack72 a=stack72 This means we can do things like: ``` const propName = new PropBuilder() .setName("name") .setKind("string") .setDocumentation("This is the documentation for the prop") .setWidget(new PropWidgetDefinitionBuilder().setKind("text").build()) .build(); ``` And that documentation is plumbed the whole way through the pkg layer, sdf and to the frontend where we can do with it as we wish Co-authored-by: stack72 <[email protected]>
- Loading branch information
Showing
34 changed files
with
901 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
lib/dal/src/migrations/U2404__add_documentation_to_props.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
-- Add the new columns to the props table. | ||
ALTER TABLE props ADD COLUMN documentation text; | ||
|
||
-- The new prop creation function automatically builds the path using the parent and sets the belongs to relationship. | ||
CREATE OR REPLACE FUNCTION prop_create_v2( | ||
this_tenancy jsonb, | ||
this_visibility jsonb, | ||
this_name text, | ||
this_kind text, | ||
this_widget_kind text, | ||
this_widget_options jsonb, | ||
this_schema_variant_id ident, | ||
this_parent_prop_id ident, | ||
this_documentation text, | ||
OUT object json) AS | ||
$$ | ||
DECLARE | ||
this_tenancy_record tenancy_record_v1; | ||
this_visibility_record visibility_record_v1; | ||
this_new_row props%ROWTYPE; | ||
this_path text; | ||
this_parent_kind text; | ||
BEGIN | ||
this_tenancy_record := tenancy_json_to_columns_v1(this_tenancy); | ||
this_visibility_record := visibility_json_to_columns_v1(this_visibility); | ||
|
||
-- Set the path according to the lineage. If there's no parent, then we know we are the root | ||
-- prop. We also need to ensure that the provided parent is either an object, a map or an | ||
-- array. | ||
IF this_parent_prop_id IS NULL | ||
THEN this_path = this_name; | ||
ELSE | ||
SELECT kind, path || E'\x0B' || this_name INTO STRICT this_parent_kind, this_path | ||
FROM props_v1(this_tenancy, this_visibility) AS props | ||
WHERE props.id = this_parent_prop_id; | ||
|
||
IF this_parent_kind != 'object' AND this_parent_kind != 'array' AND this_parent_kind != 'map' | ||
THEN RAISE EXCEPTION 'prop create: provided parent is not a valid kind: %', this_parent_kind; | ||
END IF; | ||
END IF; | ||
|
||
-- Create and populate the row. | ||
INSERT INTO props (tenancy_workspace_pk, | ||
visibility_change_set_pk, | ||
name, kind, widget_kind, widget_options, schema_variant_id, path, documentation) | ||
VALUES (this_tenancy_record.tenancy_workspace_pk, | ||
this_visibility_record.visibility_change_set_pk, | ||
this_name, this_kind, this_widget_kind, this_widget_options, this_schema_variant_id, this_path, this_documentation) | ||
RETURNING * INTO this_new_row; | ||
|
||
-- Now that we have the row, we can set the parent prop. | ||
IF this_parent_prop_id IS NOT NULL THEN | ||
PERFORM set_belongs_to_v1( | ||
'prop_belongs_to_prop', | ||
this_tenancy, | ||
this_visibility, | ||
this_new_row.id, | ||
this_parent_prop_id | ||
); | ||
END IF; | ||
|
||
object := row_to_json(this_new_row); | ||
END; | ||
$$ LANGUAGE PLPGSQL VOLATILE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.