@spotify/backstage-plugin-pulse-common 0.6.0 → 0.6.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @spotify/backstage-plugin-pulse-common
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Upgraded to Backstage `v1.14.0`
8
+ - Updated dependency `json-schema-to-typescript` to `13.0.1`.
9
+
10
+ ## 0.6.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Fixed an issue where the backend failed to start up while trying to read a non-existent survey templates directory.
15
+
3
16
  ## 0.6.0
4
17
 
5
18
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("@backstage/plugin-permission-common"),n=require("ajv"),a=require("ajv-formats");function t(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var d=t(n),p=t(a);const c="survey-instance",i=o.createPermission({name:"survey.instance.administer",attributes:{action:"create"}}),u=[i];var l="http://json-schema.org/draft-07/schema",m="Survey Template",y="object",h={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${p:<name>} construct (same as parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},questions:{type:"array",description:"The questions in the section (all in one page)",items:{$ref:"#/$defs/question"}},pages:{type:"array",description:"The questions in the section, split into pages",items:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1}}},additionalProperties:!1,required:["id","name"],oneOf:[{required:["questions"]},{required:["pages"]}]}}},f=!1,g=["template","parameters","sections"],q={question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},text_html:{type:"string",description:"The question description, in HTML"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},display_logic_in_page:{type:"string",description:"Similar to display_logic, but enables the question to appear on the same page as the depending question"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"}},additionalProperties:!1,allOf:[{oneOf:[{required:["text"]},{required:["text_html"]}]},{oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],anyOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},_={$schema:l,title:m,type:y,properties:h,additionalProperties:f,required:g,$defs:q};const r=new d.default({allowUnionTypes:!0});p.default(r);const s=r.compile(_),v=e=>{if(!s(e))throw new Error(`Invalid template: ${e.template.id}. Reason: ${s.errors}`)},b="pulse_default_alpha",$={allPermissions:u,SURVEY_RESOURCE_TYPE:c,surveyAdministerPermission:i};exports.DEFAULT_TEMPLATE_ID=b,exports.permissions=$,exports.validateTemplate=v;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("@backstage/plugin-permission-common"),n=require("ajv"),a=require("ajv-formats");function t(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var d=t(n),p=t(a);const c="survey-instance",i=o.createPermission({name:"survey.instance.administer",attributes:{action:"create"}}),u=[i];var l="http://json-schema.org/draft-07/schema",m="Survey Template",y="object",h={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${p:<name>} construct (same as parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},questions:{type:"array",description:"The questions in the section (all in one page)",items:{$ref:"#/$defs/question"}},pages:{type:"array",description:"The questions in the section, split into pages",items:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1}}},additionalProperties:!1,required:["id","name"],oneOf:[{required:["questions"]},{required:["pages"]}]}}},f=!1,g=["template","parameters","sections"],q={question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},text_html:{type:"string",description:"The question description, in HTML"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},display_logic_in_page:{type:"string",description:"Similar to display_logic, but enables the question to appear on the same page as the depending question"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"}},additionalProperties:!1,allOf:[{oneOf:[{required:["text"]},{required:["text_html"]}]},{oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],anyOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},_={$schema:l,title:m,type:y,properties:h,additionalProperties:f,required:g,$defs:q};const r=new d.default({allowUnionTypes:!0});p.default(r);const s=r.compile(_),v=e=>{if(!s(e))throw new Error(`Invalid template: ${e.template.id}. Reason: ${JSON.stringify(s.errors,null,4)}`)},b="pulse_default_alpha",$={allPermissions:u,SURVEY_RESOURCE_TYPE:c,surveyAdministerPermission:i};exports.DEFAULT_TEMPLATE_ID=b,exports.permissions=$,exports.validateTemplate=v;
2
2
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createPermission as s}from"@backstage/plugin-permission-common";import o from"ajv";import n from"ajv-formats";const a="survey-instance",t=s({name:"survey.instance.administer",attributes:{action:"create"}}),p=[t];var d="http://json-schema.org/draft-07/schema",c="Survey Template",u="object",m={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${p:<name>} construct (same as parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},questions:{type:"array",description:"The questions in the section (all in one page)",items:{$ref:"#/$defs/question"}},pages:{type:"array",description:"The questions in the section, split into pages",items:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1}}},additionalProperties:!1,required:["id","name"],oneOf:[{required:["questions"]},{required:["pages"]}]}}},l=!1,y=["template","parameters","sections"],h={question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},text_html:{type:"string",description:"The question description, in HTML"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},display_logic_in_page:{type:"string",description:"Similar to display_logic, but enables the question to appear on the same page as the depending question"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"}},additionalProperties:!1,allOf:[{oneOf:[{required:["text"]},{required:["text_html"]}]},{oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],anyOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},f={$schema:d,title:c,type:u,properties:m,additionalProperties:l,required:y,$defs:h};const i=new o({allowUnionTypes:!0});n(i);const r=i.compile(f),g=e=>{if(!r(e))throw new Error(`Invalid template: ${e.template.id}. Reason: ${r.errors}`)},q="pulse_default_alpha",_={allPermissions:p,SURVEY_RESOURCE_TYPE:a,surveyAdministerPermission:t};export{q as DEFAULT_TEMPLATE_ID,_ as permissions,g as validateTemplate};
1
+ import{createPermission as s}from"@backstage/plugin-permission-common";import o from"ajv";import n from"ajv-formats";const a="survey-instance",t=s({name:"survey.instance.administer",attributes:{action:"create"}}),p=[t];var d="http://json-schema.org/draft-07/schema",c="Survey Template",u="object",l={template:{type:"object",description:"Meta data about the survey template",properties:{id:{type:"string",description:"An id of the survey template. If there are multiple templates with the same id, they must have different versions.",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$",minLength:1},version:{type:"string",format:"regex",pattern:"^[0-9]+(\\.[0-9]+)?$",description:"A version of template"},name:{type:"string",description:"The display name of the survey template",minLength:1},description:{type:"string",description:"A longer description of the survey template"},owner:{type:"string",description:"The owner of the survey template",minLength:1}},required:["id","version","name","owner"],additionalProperties:!1},parameters:{type:"array",description:"Template parameters that can or must be set when creating a survey from this template. Parameters are referred to elsewhere in the survey using the ${p:<id>} construct and will get lazily in-place replaced.",items:{type:"object",properties:{id:{type:"string",description:"The id of the parameter",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},description:{type:"string",description:"The description of the parameter"},format:{type:"string",enum:["string","number","boolean"],description:"The format of the parameter. Should only be set if a default value is not provided."},default:{type:["string","number","boolean"],description:"An optional default value of this parameter. If this is omitted, the parameter must be provided when creating a survey from the template."}},required:["id","description"],oneOf:[{required:["format"]},{required:["default"]}],additionalProperties:!1}},macros:{type:"object",description:"Expression shortcuts. Macros are referred to elsewhere in the survey using the ${p:<name>} construct (same as parameters) and will get lazily in-place replaced. Macros can be recursive and contain references to parameters or answers in the survey.",additionalProperties:{type:"string"}},sections:{type:"array",description:"The survey sections, in the order they will appear in the survey",items:{type:"object",description:"A survey section.",properties:{id:{type:"string",description:"The id of this section",format:"regex",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9]$"},name:{type:"string",description:"The name of this section"},display_logic:{type:"string",description:"An optional boolean expression that decides if the surveyee should see the questions in this section."},questions:{type:"array",description:"The questions in the section (all in one page)",items:{$ref:"#/$defs/question"}},pages:{type:"array",description:"The questions in the section, split into pages",items:{type:"object",properties:{questions:{type:"array",description:"The questions on the page",items:{$ref:"#/$defs/question"}}},required:["questions"],additionalProperties:!1}}},additionalProperties:!1,required:["id","name"],oneOf:[{required:["questions"]},{required:["pages"]}]}}},m=!1,y=["template","parameters","sections"],h={question:{type:"object",properties:{id:{type:"string",description:"The unique ID of the question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$"},text:{type:"string",description:"The question description, in markdown"},text_html:{type:"string",description:"The question description, in HTML"},type:{type:"string",enum:["mc-single","mc-multi","matrix-single","matrix-multi","text-single","text-multi","description"],description:"The type of question"},layout:{type:"string",enum:["vertical","horizontal"],description:"Determines the visual layout of the options in multiple choice questions"},display_logic:{type:"string",description:"A boolean expression with logic if this question should be displayed or not"},display_logic_in_page:{type:"string",description:"Similar to display_logic, but enables the question to appear on the same page as the depending question"},required:{type:"string",enum:["required","optional","request"],description:"If the question is required to answer; request means you will get a warning if you skip it but you can."},validation:{type:"object",description:"Validation constraints on the question. Only applied if the user has answered the question, so typically used in combination with required",properties:{min_choices:{type:"integer",description:"The minimum number of choices to user can pick (multiple choice questions only)"},max_choices:{type:"integer",description:"The maximum number of choices to user can pick (multiple choice questions only)"}},additionalProperties:!1},statements:{type:"array",items:{$ref:"#/$defs/statement"}},dynamic_statements:{type:"string",description:"Carry forward statements from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},statement_groups:{type:"array",items:{type:"object",properties:{statements:{type:"array",items:{$ref:"#/$defs/statement"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["statements","display"],additionalProperties:!1}},choices:{type:"array",items:{$ref:"#/$defs/choice"}},dynamic_choices:{type:"string",description:"Carry forward choices from a previous question",pattern:"^[a-zA-Z][a-zA-Z0-9_]*/(all|selected|all_entered_text|selected_entered_text|not_selected|displayed|not_displayed|for_matrix_choice\\([\\-a-zA-Z0-9_]+\\)|unselected_for_matrix_choice\\([\\-a-zA-Z0-9_]+\\))$"},choice_groups:{type:"array",items:{type:"object",properties:{choices:{type:"array",items:{$ref:"#/$defs/choice"}},id:{type:"string",description:"The id of the group. Need only be set if referenced to in constrained randomization."},display:{type:"string",description:"The display name of the group"},display_logic:{type:"string",description:"A boolean expression determining if the group should be displayed"},randomization:{$ref:"#/$defs/randomization"}},required:["choices","display"],additionalProperties:!1}},randomization:{$ref:"#/$defs/randomization"}},additionalProperties:!1,allOf:[{oneOf:[{required:["text"]},{required:["text_html"]}]},{oneOf:[{$ref:"#/$defs/question-mc-horizontal"},{$ref:"#/$defs/question-mc-vertical"},{$ref:"#/$defs/question-matrix"},{$ref:"#/$defs/question-text"},{$ref:"#/$defs/question-description"}]}]},"question-mc-horizontal":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"horizontal"}},required:["id","type","position","choices"],not:{anyOf:[{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]}},"question-mc-vertical":{type:"object",properties:{type:{enum:["mc-single","mc-multi"]},position:{const:"vertical"}},required:["id","type"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]},{required:["statement_groups"]}]},oneOf:[{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}],not:{required:["choice_groups"]}},{required:["choice_groups"],not:{anyOf:[{required:["choices"]},{required:["dynamic_choices"]}]}}]},"question-matrix":{type:"object",properties:{type:{enum:["matrix-single","matrix-multi"]}},required:["id","type","choices"],not:{anyOf:[{required:["dynamic_choices"]},{required:["choice_groups"]}]},oneOf:[{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}],not:{required:["statement_groups"]}},{required:["statement_groups"],not:{anyOf:[{required:["statements"]},{required:["dynamic_statements"]}]}}]},"question-text":{type:"object",properties:{type:{enum:["text-single","text-multi"]}},required:["id","type"],not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},"question-description":{type:"object",properties:{type:{const:"description"}},not:{anyOf:[{required:["choices"]},{required:["choice_groups"]},{required:["dynamic_choices"]},{required:["statements"]},{required:["statement_groups"]},{required:["dynamic_statements"]},{required:["randomization"]}]}},statement:{type:"object",properties:{id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the statement"},display:{type:"string",description:"The statement name, as shown to the surveyee"},display_logic:{type:"string",description:"A boolean expression determining if the statement should be displayed"}},required:["id","display"],additionalProperties:!1},choice:{type:"object",properties:{display:{type:"string",description:"The choice name, as shown to the surveyee"},id:{type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_]*$",description:"The id of the choice"},value:{type:"integer",description:"The value the choice"},display_logic:{type:"string",description:"A boolean expression determining if the choice should be displayed"},text:{type:"string",enum:["no","optional","forced"],description:"If a textbox should appear next to the choice, and if it should be mandatory to fill it in if the choice is selected"},exclusive_answer:{type:"boolean",description:"If true, this choice can't be combined with other choices in this question"}},required:["display"],anyOf:[{required:["value"]},{required:["id"]}],additionalProperties:!1},randomization:{type:"object",description:"Configuration of the display order randomization of choices, statements or groups.",properties:{type:{type:"string",description:"The type of randomization: randomize all items, a subset of them, or using constrained randomization",enum:["all","subset","constrained"]},total:{type:"integer",description:"Maximum number of items to show"},order:{type:"string",description:"A space separated string containing the order of the items; each 'word' is either an id of some item or the wildcard $ representing the remaining items"}},required:["type"],oneOf:[{properties:{type:{const:"all"}},not:{required:["total","order"]}},{properties:{type:{const:"subset"}},required:["total"],not:{required:["order"]}},{properties:{type:{const:"constrained"}},required:["order"]}],additionalProperties:!1}},f={$schema:d,title:c,type:u,properties:l,additionalProperties:m,required:y,$defs:h};const i=new o({allowUnionTypes:!0});n(i);const r=i.compile(f),g=e=>{if(!r(e))throw new Error(`Invalid template: ${e.template.id}. Reason: ${JSON.stringify(r.errors,null,4)}`)},q="pulse_default_alpha",_={allPermissions:p,SURVEY_RESOURCE_TYPE:a,surveyAdministerPermission:t};export{q as DEFAULT_TEMPLATE_ID,_ as permissions,g as validateTemplate};
2
2
  //# sourceMappingURL=index.esm.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spotify/backstage-plugin-pulse-common",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "homepage": "https://backstage.spotify.com/",
6
6
  "main": "dist/index.cjs.js",
@@ -29,15 +29,15 @@
29
29
  "graphql": "^16.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@backstage/cli": "^0.22.6",
32
+ "@backstage/cli": "^0.22.7",
33
33
  "js-yaml": "^4.1.0",
34
- "json-schema-to-typescript": "12.0.0",
34
+ "json-schema-to-typescript": "13.0.1",
35
35
  "process": "^0.11.10"
36
36
  },
37
37
  "files": [
38
38
  "dist",
39
39
  "!dist/**/*.map",
40
- "src/templates/surveys"
40
+ "src/templates/surveys/*"
41
41
  ],
42
42
  "module": "dist/index.esm.js"
43
43
  }
@@ -0,0 +1,170 @@
1
+ template:
2
+ id: pulse_default_alpha
3
+ name: Default
4
+ description: Engineering Satisfaction survey
5
+ owner: Spotify
6
+ version: '0.1'
7
+
8
+ parameters: []
9
+
10
+ sections:
11
+ - id: welcome
12
+ name: Welcome
13
+ questions:
14
+ - text: |
15
+ This survey checks the Pulse of your engineering organization.
16
+ All submissions are anonymized and aggregated before results are shared. The results will be available on the Pulse results page after the survey results have been published.
17
+ Please consider your last three months at the organization when responding to the survey.
18
+
19
+ - id: productivity
20
+ name: Productivity
21
+ questions:
22
+ - id: work_productivity
23
+ text: In general, how would you describe your ability to be productive at work?
24
+ type: mc-single
25
+ layout: horizontal
26
+ required: optional
27
+ choices:
28
+ - display: I feel very unproductive
29
+ value: -2
30
+ - display: I feel somewhat unproductive
31
+ value: -1
32
+ - display: Neutral
33
+ value: 0
34
+ - display: I feel somewhat productive
35
+ value: 1
36
+ - display: I feel very productive
37
+ value: 2
38
+
39
+ - id: satisfaction
40
+ name: Satisfaction
41
+ questions:
42
+ - id: task_satisfaction
43
+ text: In general, how satisfied are you with the tasks you do at work?
44
+ type: mc-single
45
+ layout: horizontal
46
+ required: optional
47
+ choices:
48
+ - display: Very dissatisfied
49
+ value: -2
50
+ - display: Somewhat dissatisfied
51
+ value: -1
52
+ - display: Neutral
53
+ value: 0
54
+ - display: Somewhat satisfied
55
+ value: 1
56
+ - display: Very satisfied
57
+ value: 2
58
+ - id: tool_satisfaction
59
+ text: How satisfied are you with the tools that are available for you to do your work?
60
+ type: mc-single
61
+ layout: horizontal
62
+ required: optional
63
+ choices:
64
+ - display: Very dissatisfied
65
+ value: -2
66
+ - display: Somewhat dissatisfied
67
+ value: -1
68
+ - display: Neutral
69
+ value: 0
70
+ - display: Somewhat satisfied
71
+ value: 1
72
+ - display: Very satisfied
73
+ value: 2
74
+
75
+ - id: achieving_flow
76
+ name: Achieving flow
77
+ questions:
78
+ - id: steady_flow
79
+ text: How often are you able to make steady progress on your tasks without interruptions?
80
+ type: mc-single
81
+ layout: horizontal
82
+ required: optional
83
+ choices:
84
+ - display: Rarely or never
85
+ value: -2
86
+ - display: Sometimes
87
+ value: -1
88
+ - display: About half the time
89
+ value: 0
90
+ - display: Most of the time
91
+ value: 1
92
+ - display: All or almost all the time
93
+ value: 2
94
+
95
+ - id: sense_of_accomplishment
96
+ name: Sense of accomplishment
97
+ questions:
98
+ - id: task_impact
99
+ text: In general, how would you describe the overall impact of your accomplished tasks?
100
+ type: mc-single
101
+ layout: horizontal
102
+ choices:
103
+ - display: Not at all impactful
104
+ value: -2
105
+ - display: Slightly impactful
106
+ value: -1
107
+ - display: Moderately impactful
108
+ value: 0
109
+ - display: Very impactful
110
+ value: 1
111
+ - display: Extremely impactful
112
+ value: 2
113
+ - id: meaning_in_work
114
+ text: In general, how meaningful do you find your work?
115
+ type: mc-single
116
+ layout: horizontal
117
+ required: optional
118
+ choices:
119
+ - display: Not at all meaningful
120
+ value: -2
121
+ - display: Slightly meaningful
122
+ value: -1
123
+ - display: Moderately meaningful
124
+ value: 0
125
+ - display: Very meaningful
126
+ value: 1
127
+ - display: Extremely meaningful
128
+ value: 2
129
+
130
+ - id: personal_judgment
131
+ name: Personal judgment
132
+ questions:
133
+ - id: welcomed_judgement
134
+ text: In general, how often is your expertise welcomed in decision-making in your organization?
135
+ type: mc-single
136
+ layout: horizontal
137
+ required: optional
138
+ choices:
139
+ - display: Rarely or never
140
+ value: -2
141
+ - display: Sometimes
142
+ value: -1
143
+ - display: About half the time
144
+ value: 0
145
+ - display: Most of the time
146
+ value: 1
147
+ - display: All or almost all the time
148
+ value: 2
149
+ - id: autonomy_satisfaction
150
+ text: In general, how satisfied are you with your level of autonomy when carrying out your tasks?
151
+ type: mc-single
152
+ layout: horizontal
153
+ required: optional
154
+ choices:
155
+ - display: Very dissatisfied
156
+ value: -2
157
+ - display: Somewhat dissatisfied
158
+ value: -1
159
+ - display: Neutral
160
+ value: 0
161
+ - display: Somewhat satisfied
162
+ value: 1
163
+ - display: Very satisfied
164
+ value: 2
165
+
166
+ - id: wrap_up
167
+ name: Wrap Up
168
+ questions:
169
+ - text: |
170
+ We appreciate your time in completing the Pulse survey. Your involvement is important and will help the organization in improving the engineering experience.