@perses-dev/plugin-system 0.44.0-rc1 → 0.44.0-rc2

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.
@@ -33,25 +33,25 @@ const _validation = require("../../validation");
33
33
  /**
34
34
  * This preprocessing ensures that we always have a defined object for the `display` property
35
35
  * @param datasource
36
- */ function getInitialState(name, spec) {
37
- var _spec_display, _spec_display1;
38
- var _spec_display_name, _spec_display_description;
36
+ */ function getInitialState(datasourceDefinition) {
37
+ var _datasourceDefinition_spec_display, _datasourceDefinition_spec_display1;
38
+ var _datasourceDefinition_spec_display_name, _datasourceDefinition_spec_display_description;
39
39
  const patchedDisplay = {
40
- name: (_spec_display_name = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.name) !== null && _spec_display_name !== void 0 ? _spec_display_name : '',
41
- description: (_spec_display_description = (_spec_display1 = spec.display) === null || _spec_display1 === void 0 ? void 0 : _spec_display1.description) !== null && _spec_display_description !== void 0 ? _spec_display_description : ''
40
+ name: (_datasourceDefinition_spec_display_name = (_datasourceDefinition_spec_display = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display === void 0 ? void 0 : _datasourceDefinition_spec_display.name) !== null && _datasourceDefinition_spec_display_name !== void 0 ? _datasourceDefinition_spec_display_name : '',
41
+ description: (_datasourceDefinition_spec_display_description = (_datasourceDefinition_spec_display1 = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display1 === void 0 ? void 0 : _datasourceDefinition_spec_display1.description) !== null && _datasourceDefinition_spec_display_description !== void 0 ? _datasourceDefinition_spec_display_description : ''
42
42
  };
43
43
  return {
44
- name: name,
44
+ name: datasourceDefinition.name,
45
45
  spec: {
46
- ...spec,
46
+ ...datasourceDefinition.spec,
47
47
  display: patchedDisplay
48
48
  }
49
49
  };
50
50
  }
51
51
  function DatasourceEditorForm(props) {
52
52
  var _state_spec_display, _state_spec_display1;
53
- const { initialName, initialSpec, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
54
- const initialState = getInitialState(initialName, initialSpec);
53
+ const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
54
+ const initialState = getInitialState(initialDatasourceDefinition);
55
55
  const [state, setState] = (0, _useimmer.useImmer)(initialState);
56
56
  const [isDiscardDialogOpened, setDiscardDialogOpened] = (0, _react.useState)(false);
57
57
  const [action, setAction] = (0, _react.useState)(initialAction);
@@ -0,0 +1,25 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "durationValidationSchema", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return durationValidationSchema;
21
+ }
22
+ });
23
+ const _core = require("@perses-dev/core");
24
+ const _zod = require("zod");
25
+ const durationValidationSchema = _zod.z.string().nonempty('Required').regex(_core.DURATION_REGEX, 'Must be a valid duration string');
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./datasource"), exports);
18
+ _export_star(require("./duration"), exports);
18
19
  _export_star(require("./resource"), exports);
19
20
  _export_star(require("./secret"), exports);
20
21
  _export_star(require("./variable"), exports);
@@ -46,6 +46,7 @@ const permissionValidationSchema = _zod.z.object({
46
46
  '*',
47
47
  'Dashboard',
48
48
  'Datasource',
49
+ 'EphemeralDashboard',
49
50
  'Folder',
50
51
  'GlobalDatasource',
51
52
  'GlobalRole',
@@ -1,8 +1,7 @@
1
- import { Action, DatasourceSpec } from '@perses-dev/core';
1
+ import { Action, DatasourceDefinition, DatasourceSpec } from '@perses-dev/core';
2
2
  import { DispatchWithoutAction } from 'react';
3
3
  interface DatasourceEditorFormProps {
4
- initialName: string;
5
- initialSpec: DatasourceSpec;
4
+ initialDatasourceDefinition: DatasourceDefinition;
6
5
  initialAction: Action;
7
6
  isDraft: boolean;
8
7
  isReadonly?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAyB,MAAM,OAAO,CAAC;AA2BrE,UAAU,yBAAyB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,cAAc,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CAwOpE"}
1
+ {"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAyB,MAAM,OAAO,CAAC;AA2BrE,UAAU,yBAAyB;IACjC,2BAA2B,EAAE,oBAAoB,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CAwOpE"}
@@ -23,25 +23,25 @@ import { datasourceEditValidationSchema } from '../../validation';
23
23
  /**
24
24
  * This preprocessing ensures that we always have a defined object for the `display` property
25
25
  * @param datasource
26
- */ function getInitialState(name, spec) {
27
- var _spec_display, _spec_display1;
28
- var _spec_display_name, _spec_display_description;
26
+ */ function getInitialState(datasourceDefinition) {
27
+ var _datasourceDefinition_spec_display, _datasourceDefinition_spec_display1;
28
+ var _datasourceDefinition_spec_display_name, _datasourceDefinition_spec_display_description;
29
29
  const patchedDisplay = {
30
- name: (_spec_display_name = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.name) !== null && _spec_display_name !== void 0 ? _spec_display_name : '',
31
- description: (_spec_display_description = (_spec_display1 = spec.display) === null || _spec_display1 === void 0 ? void 0 : _spec_display1.description) !== null && _spec_display_description !== void 0 ? _spec_display_description : ''
30
+ name: (_datasourceDefinition_spec_display_name = (_datasourceDefinition_spec_display = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display === void 0 ? void 0 : _datasourceDefinition_spec_display.name) !== null && _datasourceDefinition_spec_display_name !== void 0 ? _datasourceDefinition_spec_display_name : '',
31
+ description: (_datasourceDefinition_spec_display_description = (_datasourceDefinition_spec_display1 = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display1 === void 0 ? void 0 : _datasourceDefinition_spec_display1.description) !== null && _datasourceDefinition_spec_display_description !== void 0 ? _datasourceDefinition_spec_display_description : ''
32
32
  };
33
33
  return {
34
- name: name,
34
+ name: datasourceDefinition.name,
35
35
  spec: {
36
- ...spec,
36
+ ...datasourceDefinition.spec,
37
37
  display: patchedDisplay
38
38
  }
39
39
  };
40
40
  }
41
41
  export function DatasourceEditorForm(props) {
42
42
  var _state_spec_display, _state_spec_display1;
43
- const { initialName, initialSpec, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
44
- const initialState = getInitialState(initialName, initialSpec);
43
+ const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
44
+ const initialState = getInitialState(initialDatasourceDefinition);
45
45
  const [state, setState] = useImmer(initialState);
46
46
  const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
47
47
  const [action, setAction] = useState(initialAction);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useImmer } from 'use-immer';\nimport { Action, DatasourceSpec } from '@perses-dev/core';\nimport { Box, Button, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DispatchWithoutAction, useCallback, useState } from 'react';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { PluginEditor } from '../PluginEditor';\nimport { getSubmitText, getTitleAction } from '../../utils';\nimport { datasourceEditValidationSchema, DatasourceEditValidationType } from '../../validation';\n\n/**\n * This preprocessing ensures that we always have a defined object for the `display` property\n * @param datasource\n */\nfunction getInitialState(name: string, spec: DatasourceSpec) {\n const patchedDisplay = {\n name: spec.display?.name ?? '',\n description: spec.display?.description ?? '',\n };\n\n return {\n name: name,\n spec: {\n ...spec,\n display: patchedDisplay,\n },\n };\n}\n\ninterface DatasourceEditorFormProps {\n initialName: string;\n initialSpec: DatasourceSpec;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (name: string, spec: DatasourceSpec) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps) {\n const { initialName, initialSpec, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialName, initialSpec);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [action, setAction] = useState(initialAction);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<DatasourceEditValidationType>({\n resolver: zodResolver(datasourceEditValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: state.name,\n title: state.spec.display?.name,\n description: state.spec.display?.description,\n default: state.spec.default,\n },\n });\n\n const processForm: SubmitHandler<DatasourceEditValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(state.name, {\n ...state.spec,\n display: {\n name: state.spec.display?.name === '' ? undefined : state.spec.display?.name,\n description: state.spec.display?.description === '' ? undefined : state.spec.display?.description,\n },\n });\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [state, initialState, setDiscardDialogOpened, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n setState((draft) => {\n field.onChange(event);\n if (draft.spec.display) {\n draft.spec.display.name = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (draft.spec.display) {\n draft.spec.display.description = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n name=\"default\"\n render={({ field }) => (\n <FormControlLabel\n {...field}\n control={\n <Switch\n checked={state.spec.default}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.spec.default = event.target.checked;\n });\n }}\n />\n }\n label=\"Set as default\"\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {state.spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <PluginEditor\n width=\"100%\"\n pluginType=\"Datasource\"\n pluginKindLabel=\"Source\"\n value={state.spec.plugin}\n isReadonly={action === 'read'}\n onChange={(v) => {\n setState((draft) => {\n draft.spec.plugin = v;\n });\n }}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["useImmer","Box","Button","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","useCallback","useState","DiscardChangesConfirmationDialog","Controller","FormProvider","useForm","zodResolver","PluginEditor","getSubmitText","getTitleAction","datasourceEditValidationSchema","getInitialState","name","spec","patchedDisplay","display","description","DatasourceEditorForm","props","state","initialName","initialSpec","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","setState","isDiscardDialogOpened","setDiscardDialogOpened","action","setAction","titleAction","submitText","form","resolver","mode","defaultValues","title","default","processForm","undefined","handleCancel","JSON","stringify","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","onChange","event","draft","target","value","paddingTop","control","checked","plugin","kind","py","width","pluginType","pluginKindLabel","v","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,QAAQ,QAAQ,YAAY;AAErC,SAASC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AACnH,SAAgCC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AACrE,SAASC,gCAAgC,QAAQ,yBAAyB;AAC1E,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,aAAa,EAAEC,cAAc,QAAQ,cAAc;AAC5D,SAASC,8BAA8B,QAAsC,mBAAmB;AAEhG;;;CAGC,GACD,SAASC,gBAAgBC,IAAY,EAAEC,IAAoB;QAEjDA,eACOA;QADPA,oBACOA;IAFf,MAAMC,iBAAiB;QACrBF,MAAMC,C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M,CAACC,KAAK;oDACrD;gDACF;4CACF;;;;;0CAKR,KAAChG;gCAAK6E,IAAI;gCAACC,IAAI;gCAAG1B,IAAI;oCAAE6C,YAAY;gCAAiB;0CACnD,cAAA,MAAChG;;sDACC,KAACO;4CACCS,MAAK;4CACL8D,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAACjF;oDACE,GAAGiF,KAAK;oDACTkB,uBACE,KAAChG;wDACCiG,SAAS3E,MAAMN,IAAI,CAAC4B,OAAO;wDAC3B0C,UAAUnD,WAAW;wDACrBuD,UAAU,CAACC;4DACT,IAAIxD,WAAW,QAAQ,QAAQ,oDAAoD;4DACnF2C,MAAMY,QAAQ,CAACC;4DACf3D,SAAS,CAAC4D;gEACRA,MAAM5E,IAAI,CAAC4B,OAAO,GAAG+C,MAAME,MAAM,CAACI,OAAO;4DAC3C;wDACF;;oDAGJf,OAAM;;;sDAIZ,MAAChF;4CAAWwD,SAAQ;;gDAAU;gDACmBpC,MAAMN,IAAI,CAACkF,MAAM,CAACC,IAAI;gDAAC;;;;;;;;kCAK9E,KAACvG;kCACD,KAACM;wBAAWkG,IAAI;wBAAG1C,SAAQ;kCAAK;;kCAGhC,KAAChD;wBACC2F,OAAM;wBACNC,YAAW;wBACXC,iBAAgB;wBAChBT,OAAOxE,MAAMN,IAAI,CAACkF,MAAM;wBACxBvE,YAAYQ,WAAW;wBACvBuD,UAAU,CAACc;4BACTxE,SAAS,CAAC4D;gCACRA,MAAM5E,IAAI,CAACkF,MAAM,GAAGM;4BACtB;wBACF;;;;0BAGJ,KAACnG;gBACCc,aAAY;gBACZsF,QAAQxE;gBACRyE,UAAU,IAAMxE,uBAAuB;gBACvCyE,kBAAkB;oBAChBzE,uBAAuB;oBACvBL;gBACF;;;;AAIR"}
1
+ {"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useImmer } from 'use-immer';\nimport { Action, DatasourceDefinition, DatasourceSpec } from '@perses-dev/core';\nimport { Box, Button, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DispatchWithoutAction, useCallback, useState } from 'react';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { PluginEditor } from '../PluginEditor';\nimport { getSubmitText, getTitleAction } from '../../utils';\nimport { datasourceEditValidationSchema, DatasourceEditValidationType } from '../../validation';\n\n/**\n * This preprocessing ensures that we always have a defined object for the `display` property\n * @param datasource\n */\nfunction getInitialState(datasourceDefinition: DatasourceDefinition) {\n const patchedDisplay = {\n name: datasourceDefinition.spec.display?.name ?? '',\n description: datasourceDefinition.spec.display?.description ?? '',\n };\n\n return {\n name: datasourceDefinition.name,\n spec: {\n ...datasourceDefinition.spec,\n display: patchedDisplay,\n },\n };\n}\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n initialAction: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onSave: (name: string, spec: DatasourceSpec) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps) {\n const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;\n\n const initialState = getInitialState(initialDatasourceDefinition);\n const [state, setState] = useImmer(initialState);\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const [action, setAction] = useState(initialAction);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const form = useForm<DatasourceEditValidationType>({\n resolver: zodResolver(datasourceEditValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: state.name,\n title: state.spec.display?.name,\n description: state.spec.display?.description,\n default: state.spec.default,\n },\n });\n\n const processForm: SubmitHandler<DatasourceEditValidationType> = () => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(state.name, {\n ...state.spec,\n display: {\n name: state.spec.display?.name === '' ? undefined : state.spec.display?.name,\n description: state.spec.display?.description === '' ? undefined : state.spec.display?.description,\n },\n });\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n const handleCancel = useCallback(() => {\n if (JSON.stringify(initialState) !== JSON.stringify(state)) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }, [state, initialState, setDiscardDialogOpened, onClose]);\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {action === 'read' ? (\n <>\n <Button disabled={isReadonly} variant=\"contained\" onClick={() => setAction('update')}>\n Edit\n </Button>\n <Button color=\"error\" disabled={isReadonly} variant=\"outlined\" onClick={onDelete}>\n Delete\n </Button>\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n '&.MuiDivider-root': {\n marginLeft: 2,\n marginRight: 1,\n },\n })}\n />\n <Button color=\"secondary\" variant=\"outlined\" onClick={onClose}>\n Close\n </Button>\n </>\n ) : (\n <>\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </>\n )}\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n draft.name = event.target.value;\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"title\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n setState((draft) => {\n field.onChange(event);\n if (draft.spec.display) {\n draft.spec.display.name = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setState((draft) => {\n if (draft.spec.display) {\n draft.spec.display.description = event.target.value;\n }\n });\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n name=\"default\"\n render={({ field }) => (\n <FormControlLabel\n {...field}\n control={\n <Switch\n checked={state.spec.default}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n setState((draft) => {\n draft.spec.default = event.target.checked;\n });\n }}\n />\n }\n label=\"Set as default\"\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {state.spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <PluginEditor\n width=\"100%\"\n pluginType=\"Datasource\"\n pluginKindLabel=\"Source\"\n value={state.spec.plugin}\n isReadonly={action === 'read'}\n onChange={(v) => {\n setState((draft) => {\n draft.spec.plugin = v;\n });\n }}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["useImmer","Box","Button","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","useCallback","useState","DiscardChangesConfirmationDialog","Controller","FormProvider","useForm","zodResolver","PluginEditor","getSubmitText","getTitleAction","datasourceEditValidationSchema","getInitialState","datasourceDefinition","patchedDisplay","name","spec","display","description","DatasourceEditorForm","props","state","initialDatasourceDefinition","initialAction","isDraft","isReadonly","onSave","onClose","onDelete","initialState","setState","isDiscardDialogOpened","setDiscardDialogOpened","action","setAction","titleAction","submitText","form","resolver","mode","defaultValues","title","default","processForm","undefined","handleCancel","JSON","stringify","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","orientation","flexItem","borderColor","grey","marginRight","formState","isValid","handleSubmit","overflowY","container","mb","item","xs","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","readOnly","error","helperText","message","onChange","event","draft","target","value","paddingTop","control","checked","plugin","kind","py","width","pluginType","pluginKindLabel","v","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC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MAAM1E,IAAI,CAAC0B,OAAO,GAAG+C,MAAME,MAAM,CAACI,OAAO;4DAC3C;wDACF;;oDAGJf,OAAM;;;sDAIZ,MAAChF;4CAAWwD,SAAQ;;gDAAU;gDACmBnC,MAAML,IAAI,CAACgF,MAAM,CAACC,IAAI;gDAAC;;;;;;;;kCAK9E,KAACvG;kCACD,KAACM;wBAAWkG,IAAI;wBAAG1C,SAAQ;kCAAK;;kCAGhC,KAAChD;wBACC2F,OAAM;wBACNC,YAAW;wBACXC,iBAAgB;wBAChBT,OAAOvE,MAAML,IAAI,CAACgF,MAAM;wBACxBvE,YAAYQ,WAAW;wBACvBuD,UAAU,CAACc;4BACTxE,SAAS,CAAC4D;gCACRA,MAAM1E,IAAI,CAACgF,MAAM,GAAGM;4BACtB;wBACF;;;;0BAGJ,KAACnG;gBACCe,aAAY;gBACZqF,QAAQxE;gBACRyE,UAAU,IAAMxE,uBAAuB;gBACvCyE,kBAAkB;oBAChBzE,uBAAuB;oBACvBL;gBACF;;;;AAIR"}
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { PluginLoader, DefaultPluginKinds } from '../../model';
3
3
  export interface PluginRegistryProps {
4
4
  pluginLoader: PluginLoader;
5
- defaultPluginKinds: DefaultPluginKinds;
6
- children?: React.ReactNode;
5
+ defaultPluginKinds?: DefaultPluginKinds;
6
+ children?: ReactNode;
7
7
  }
8
8
  /**
9
9
  * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":";AAeA,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CAoExD"}
1
+ {"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAgC,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CAoExD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useRef, useCallback, useMemo } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds: DefaultPluginKinds;\n children?: React.ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps) {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>> => {\n // Get the indexes of the installed plugins\n const pluginIndexes = await getPluginIndexes();\n\n // Figure out what module the plugin is in by looking in the index\n const typeAndKindKey = getTypeAndKindKey(pluginType, kind);\n const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);\n if (resource === undefined) {\n throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);\n }\n\n // Treat the plugin module as a bunch of named exports that have plugins\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n\n // We currently assume that plugin modules will have named exports that match the kinds they handle\n const plugin = pluginModule[kind];\n if (plugin === undefined) {\n throw new Error(\n `The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`\n );\n }\n\n return plugin as PluginImplementation<T>;\n },\n [getPluginIndexes, loadPluginModule]\n );\n\n const listPluginMetadata = useCallback(\n async (pluginType: PluginType) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginIndexes.pluginMetadataByType.get(pluginType) ?? [];\n },\n [getPluginIndexes]\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds]\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useEvent","useRef","useCallback","useMemo","PluginRegistryContext","usePluginIndexes","getTypeAndKindKey","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","pluginType","kind","pluginIndexes","typeAndKindKey","pluginResourcesByTypeAndKind","Error","pluginModule","plugin","metadata","name","listPluginMetadata","pluginMetadataByType","context","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAsBA,QAAQ,QAAQ,mBAAmB;AACzD,SAASC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AASrD,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,mBAAmB;AAQvE;;;CAGC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,cAAc,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAE,EACzDC,QAAQ,EACRC,kBAAkB,EACnB,GAAGL;IAEJ,MAAMM,mBAAmBT,iBAAiBK;IAE1C,yCAAyC;IACzC,MAAMK,cAAcd,OAAO,IAAIe;IAE/B,gHAAgH;IAChH,iBAAiB;IACjB,MAAMC,mBAAmBjB,SAAS,CAACkB;QACjC,IAAIC,UAAUJ,YAAYK,OAAO,CAACC,GAAG,CAACH;QACtC,IAAIC,YAAYG,WAAW;YACzBH,UAAUR,mBAAmBO;YAC7BH,YAAYK,OAAO,CAACG,GAAG,CAACL,UAAUC;YAElC,2EAA2E;YAC3EA,QAAQK,KAAK,CAAC,IAAMT,YAAYK,OAAO,CAACK,MAAM,CAACP;QACjD;QACA,OAAOC;IACT;IAEA,MAAMO,YAAYxB,YAChB,OAA6ByB,YAAeC;QAC1C,2CAA2C;QAC3C,MAAMC,gBAAgB,MAAMf;QAE5B,kEAAkE;QAClE,MAAMgB,iBAAiBxB,kBAAkBqB,YAAYC;QACrD,MAAMV,WAAWW,cAAcE,4BAA4B,CAACV,GAAG,CAACS;QAChE,IAAIZ,aAAaI,WAAW;YAC1B,MAAM,IAAIU,MAAM,CAAC,EAAE,EAAEL,WAAW,kBAAkB,EAAEC,KAAK,kBAAkB,CAAC;QAC9E;QAEA,wEAAwE;QACxE,MAAMK,eAAgB,MAAMhB,iBAAiBC;QAE7C,mGAAmG;QACnG,MAAMgB,SAASD,YAAY,CAACL,KAAK;QACjC,IAAIM,WAAWZ,WAAW;YACxB,MAAM,IAAIU,MACR,CAAC,IAAI,EAAEL,WAAW,kBAAkB,EAAEC,KAAK,sBAAsB,EAAEV,SAASiB,QAAQ,CAACC,IAAI,CAAC,cAAc,CAAC;QAE7G;QAEA,OAAOF;IACT,GACA;QAACpB;QAAkBG;KAAiB;IAGtC,MAAMoB,qBAAqBnC,YACzB,OAAOyB;QACL,MAAME,gBAAgB,MAAMf;YACrBe;QAAP,OAAOA,CAAAA,0CAAAA,cAAcS,oBAAoB,CAACjB,GAAG,CAACM,yBAAvCE,qDAAAA,0CAAsD,EAAE;IACjE,GACA;QAACf;KAAiB;IAGpB,iDAAiD;IACjD,MAAMyB,UAAUpC,QACd,IAAO,CAAA;YAAEuB;YAAWW;YAAoBxB;QAAmB,CAAA,GAC3D;QAACa;QAAWW;QAAoBxB;KAAmB;IAErD,qBAAO,KAACT,sBAAsBoC,QAAQ;QAACC,OAAOF;kBAAU3B;;AAC1D"}
1
+ {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useRef, useCallback, useMemo, ReactNode } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds?: DefaultPluginKinds;\n children?: ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps) {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>> => {\n // Get the indexes of the installed plugins\n const pluginIndexes = await getPluginIndexes();\n\n // Figure out what module the plugin is in by looking in the index\n const typeAndKindKey = getTypeAndKindKey(pluginType, kind);\n const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);\n if (resource === undefined) {\n throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);\n }\n\n // Treat the plugin module as a bunch of named exports that have plugins\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n\n // We currently assume that plugin modules will have named exports that match the kinds they handle\n const plugin = pluginModule[kind];\n if (plugin === undefined) {\n throw new Error(\n `The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`\n );\n }\n\n return plugin as PluginImplementation<T>;\n },\n [getPluginIndexes, loadPluginModule]\n );\n\n const listPluginMetadata = useCallback(\n async (pluginType: PluginType) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginIndexes.pluginMetadataByType.get(pluginType) ?? [];\n },\n [getPluginIndexes]\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds]\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useEvent","useRef","useCallback","useMemo","PluginRegistryContext","usePluginIndexes","getTypeAndKindKey","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","pluginType","kind","pluginIndexes","typeAndKindKey","pluginResourcesByTypeAndKind","Error","pluginModule","plugin","metadata","name","listPluginMetadata","pluginMetadataByType","context","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAsBA,QAAQ,QAAQ,mBAAmB;AACzD,SAASC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAmB,QAAQ;AAShE,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,gBA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iB;IAGtC,MAAMoB,qBAAqBnC,YACzB,OAAOyB;QACL,MAAME,gBAAgB,MAAMf;YACrBe;QAAP,OAAOA,CAAAA,0CAAAA,cAAcS,oBAAoB,CAACjB,GAAG,CAACM,yBAAvCE,qDAAAA,0CAAsD,EAAE;IACjE,GACA;QAACf;KAAiB;IAGpB,iDAAiD;IACjD,MAAMyB,UAAUpC,QACd,IAAO,CAAA;YAAEuB;YAAWW;YAAoBxB;QAAmB,CAAA,GAC3D;QAACa;QAAWW;QAAoBxB;KAAmB;IAErD,qBAAO,KAACT,sBAAsBoC,QAAQ;QAACC,OAAOF;kBAAU3B;;AAC1D"}
@@ -5,7 +5,7 @@ import { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType }
5
5
  export interface PluginRegistryContextType {
6
6
  getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;
7
7
  listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;
8
- defaultPluginKinds: DefaultPluginKinds;
8
+ defaultPluginKinds?: DefaultPluginKinds;
9
9
  }
10
10
  export declare const PluginRegistryContext: import("react").Context<PluginRegistryContextType | undefined>;
11
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/plugin-registry.ts"],"names":[],"mappings":";AAcA,OAAO,EAAwB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,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E,UAAU,EAAE,OAAO,CAAC,EAAE,4BAA4B,2EAGnG;AAED,wBAAgB,mCAAmC,yFAelD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/plugin-registry.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;\n defaultPluginKinds: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry() {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\n\n// Allows consumers to pass useQuery options from react-query when loading a plugin\ntype UsePluginOptions<T extends PluginType> = Omit<\n UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType, string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Loads a plugin and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>) {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery(['getPlugin', pluginType, kind], () => getPlugin(pluginType, kind), options);\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{ kind: string }>) {\n const { getPlugin } = usePluginRegistry();\n return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.\n */\nexport function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions) {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery(['listPluginMetadata', pluginType], () => listPluginMetadata(pluginType), options);\n}\n\nexport function usePluginBuiltinVariableDefinitions() {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery(['usePluginBuiltinVariableDefinitions'], async () => {\n const datasources = await listPluginMetadata('Datasource');\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","usePlugins","plugins","queries","map","p","queryKey","queryFn","useListPluginMetadata","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","Set","datasource","result","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyB,wBAAwB;AAU9E,OAAO,MAAMC,wBAAwBJ,cAAqDK,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMN,WAAWG;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UAAgCC,UAAa,EAAEC,IAAY,EAAEC,OAA6B;QAI5FA;IAHZ,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,CAAAA,mBAAAA,oBAAAA,8BAAAA,QAASC,OAAO,cAAhBD,8BAAAA,mBAAoB,IAAG,KAAMD,SAAS;IAClD;IACA,MAAM,EAAEG,SAAS,EAAE,GAAGR;IACtB,OAAOJ,SAAS;QAAC;QAAaQ;QAAYC;KAAK,EAAE,IAAMG,UAAUJ,YAAYC,OAAOC;AACtF;AAEA;;CAEC,GACD,OAAO,SAASG,WAAiCL,UAAa,EAAEM,OAAgC;IAC9F,MAAM,EAAEF,SAAS,EAAE,GAAGR;IACtB,OAAOH,WAAW;QAChBc,SAASD,QAAQE,GAAG,CAAC,CAACC;YACpB,OAAO;gBACLC,UAAU;oBAAC;oBAAaV;oBAAYS,EAAER,IAAI;iBAAC;gBAC3CU,SAAS,IAAMP,UAAUJ,YAAYS,EAAER,IAAI;YAC7C;QACF;IACF;AACF;AAQA;;CAEC,GACD,OAAO,SAASW,sBAAsBZ,UAAsB,EAAEE,OAAsC;IAClG,MAAM,EAAEW,kBAAkB,EAAE,GAAGjB;IAC/B,OAAOJ,SAAS;QAAC;QAAsBQ;KAAW,EAAE,IAAMa,mBAAmBb,aAAaE;AAC5F;AAEA,OAAO,SAASY;IACd,MAAM,EAAEV,SAAS,EAAES,kBAAkB,EAAE,GAAGjB;IAE1C,OAAOJ,SAAS;QAAC;KAAsC,EAAE;QACvD,MAAMuB,cAAc,MAAMF,mBAAmB;QAC7C,MAAMG,kBAAkB,IAAIC,IAAIF,YAAYP,GAAG,CAAC,CAACU,aAAeA,WAAWjB,IAAI;QAC/E,MAAMkB,SAAsC,EAAE;QAC9C,KAAK,MAAMlB,QAAQe,gBAAiB;YAClC,MAAMI,SAAS,MAAMhB,UAAU,cAAcH;YAC7C,IAAImB,OAAOC,6BAA6B,EAAE;gBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAeJ,OAAOK,IAAI,CAACD;YAC7E;QACF;QACA,OAAOJ;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/runtime/plugin-registry.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;\n defaultPluginKinds?: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry() {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\n\n// Allows consumers to pass useQuery options from react-query when loading a plugin\ntype UsePluginOptions<T extends PluginType> = Omit<\n UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType, string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Loads a plugin and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>) {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery(['getPlugin', pluginType, kind], () => getPlugin(pluginType, kind), options);\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{ kind: string }>) {\n const { getPlugin } = usePluginRegistry();\n return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.\n */\nexport function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions) {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery(['listPluginMetadata', pluginType], () => listPluginMetadata(pluginType), options);\n}\n\nexport function usePluginBuiltinVariableDefinitions() {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery(['usePluginBuiltinVariableDefinitions'], async () => {\n const datasources = await listPluginMetadata('Datasource');\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","usePlugins","plugins","queries","map","p","queryKey","queryFn","useListPluginMetadata","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","Set","datasource","result","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyB,wBAAwB;AAU9E,OAAO,MAAMC,wBAAwBJ,cAAqDK,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMN,WAAWG;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UAAgCC,UAAa,EAAEC,IAAY,EAAEC,OAA6B;QAI5FA;IAHZ,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,CAAAA,mBAAAA,oBAAAA,8BAAAA,QAASC,OA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MappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/validation/duration.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB,aAGsB,CAAC"}
@@ -0,0 +1,17 @@
1
+ // Copyright 2024 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { DURATION_REGEX } from '@perses-dev/core';
14
+ import { z } from 'zod';
15
+ export const durationValidationSchema = z.string().nonempty('Required').regex(DURATION_REGEX, 'Must be a valid duration string');
16
+
17
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/validation/duration.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DURATION_REGEX } from '@perses-dev/core';\nimport { z } from 'zod';\n\nexport const durationValidationSchema = z\n .string()\n .nonempty('Required')\n .regex(DURATION_REGEX, 'Must be a valid duration string');\n"],"names":["DURATION_REGEX","z","durationValidationSchema","string","nonempty","regex"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,cAAc,QAAQ,mBAAmB;AAClD,SAASC,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,2BAA2BD,EACrCE,MAAM,GACNC,QAAQ,CAAC,YACTC,KAAK,CAACL,gBAAgB,mCAAmC"}
@@ -1,4 +1,5 @@
1
1
  export * from './datasource';
2
+ export * from './duration';
2
3
  export * from './resource';
3
4
  export * from './secret';
4
5
  export * from './variable';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
@@ -11,6 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './datasource';
14
+ export * from './duration';
14
15
  export * from './resource';
15
16
  export * from './secret';
16
17
  export * from './variable';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './resource';\nexport * from './secret';\nexport * from './variable';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,aAAa"}
1
+ {"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './duration';\nexport * from './resource';\nexport * from './secret';\nexport * from './variable';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,WAAW;AACzB,cAAc,aAAa"}
@@ -14,23 +14,23 @@ export declare const roleValidationSchema: z.ZodObject<{
14
14
  spec: z.ZodObject<{
15
15
  permissions: z.ZodArray<z.ZodObject<{
16
16
  actions: z.ZodArray<z.ZodEnum<["*", "create", "read", "update", "delete"]>, "atleastone">;
17
- scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
17
+ scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "EphemeralDashboard", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
18
18
  }, "strip", z.ZodTypeAny, {
19
19
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
20
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
20
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
21
21
  }, {
22
22
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
23
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
23
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
24
24
  }>, "many">;
25
25
  }, "strip", z.ZodTypeAny, {
26
26
  permissions: {
27
27
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
28
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
28
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
29
29
  }[];
30
30
  }, {
31
31
  permissions: {
32
32
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
33
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
33
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
34
34
  }[];
35
35
  }>;
36
36
  }, "strip", z.ZodTypeAny, {
@@ -38,7 +38,7 @@ export declare const roleValidationSchema: z.ZodObject<{
38
38
  spec: {
39
39
  permissions: {
40
40
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
41
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
41
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
42
42
  }[];
43
43
  };
44
44
  metadata: {
@@ -50,7 +50,7 @@ export declare const roleValidationSchema: z.ZodObject<{
50
50
  spec: {
51
51
  permissions: {
52
52
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
53
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
53
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
54
54
  }[];
55
55
  };
56
56
  metadata: {
@@ -70,23 +70,23 @@ export declare const globalRoleValidationSchema: z.ZodObject<{
70
70
  spec: z.ZodObject<{
71
71
  permissions: z.ZodArray<z.ZodObject<{
72
72
  actions: z.ZodArray<z.ZodEnum<["*", "create", "read", "update", "delete"]>, "atleastone">;
73
- scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
73
+ scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "EphemeralDashboard", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
74
74
  }, "strip", z.ZodTypeAny, {
75
75
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
76
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
76
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
77
77
  }, {
78
78
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
79
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
79
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
80
80
  }>, "many">;
81
81
  }, "strip", z.ZodTypeAny, {
82
82
  permissions: {
83
83
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
84
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
84
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
85
85
  }[];
86
86
  }, {
87
87
  permissions: {
88
88
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
89
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
89
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
90
90
  }[];
91
91
  }>;
92
92
  }, "strip", z.ZodTypeAny, {
@@ -94,7 +94,7 @@ export declare const globalRoleValidationSchema: z.ZodObject<{
94
94
  spec: {
95
95
  permissions: {
96
96
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
97
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
97
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
98
98
  }[];
99
99
  };
100
100
  metadata: {
@@ -105,7 +105,7 @@ export declare const globalRoleValidationSchema: z.ZodObject<{
105
105
  spec: {
106
106
  permissions: {
107
107
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
108
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
108
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
109
109
  }[];
110
110
  };
111
111
  metadata: {
@@ -127,23 +127,23 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
127
127
  spec: z.ZodObject<{
128
128
  permissions: z.ZodArray<z.ZodObject<{
129
129
  actions: z.ZodArray<z.ZodEnum<["*", "create", "read", "update", "delete"]>, "atleastone">;
130
- scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
130
+ scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "EphemeralDashboard", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
131
131
  }, "strip", z.ZodTypeAny, {
132
132
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
133
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
133
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
134
134
  }, {
135
135
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
136
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
136
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
137
137
  }>, "many">;
138
138
  }, "strip", z.ZodTypeAny, {
139
139
  permissions: {
140
140
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
141
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
141
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
142
142
  }[];
143
143
  }, {
144
144
  permissions: {
145
145
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
146
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
146
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
147
147
  }[];
148
148
  }>;
149
149
  }, "strip", z.ZodTypeAny, {
@@ -151,7 +151,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
151
151
  spec: {
152
152
  permissions: {
153
153
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
154
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
154
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
155
155
  }[];
156
156
  };
157
157
  metadata: {
@@ -163,7 +163,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
163
163
  spec: {
164
164
  permissions: {
165
165
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
166
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
166
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
167
167
  }[];
168
168
  };
169
169
  metadata: {
@@ -182,23 +182,23 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
182
182
  spec: z.ZodObject<{
183
183
  permissions: z.ZodArray<z.ZodObject<{
184
184
  actions: z.ZodArray<z.ZodEnum<["*", "create", "read", "update", "delete"]>, "atleastone">;
185
- scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
185
+ scopes: z.ZodArray<z.ZodEnum<["*", "Dashboard", "Datasource", "EphemeralDashboard", "Folder", "GlobalDatasource", "GlobalRole", "GlobalRoleBinding", "GlobalSecret", "GlobalVariable", "Project", "Role", "RoleBinding", "Secret", "User", "Variable"]>, "atleastone">;
186
186
  }, "strip", z.ZodTypeAny, {
187
187
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
188
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
188
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
189
189
  }, {
190
190
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
191
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
191
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
192
192
  }>, "many">;
193
193
  }, "strip", z.ZodTypeAny, {
194
194
  permissions: {
195
195
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
196
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
196
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
197
197
  }[];
198
198
  }, {
199
199
  permissions: {
200
200
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
201
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
201
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
202
202
  }[];
203
203
  }>;
204
204
  }, "strip", z.ZodTypeAny, {
@@ -206,7 +206,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
206
206
  spec: {
207
207
  permissions: {
208
208
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
209
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
209
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
210
210
  }[];
211
211
  };
212
212
  metadata: {
@@ -217,7 +217,7 @@ export declare const rolesEditorValidationSchema: z.ZodDiscriminatedUnion<"kind"
217
217
  spec: {
218
218
  permissions: {
219
219
  actions: ["create" | "read" | "update" | "delete" | "*", ...("create" | "read" | "update" | "delete" | "*")[]];
220
- scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
220
+ scopes: ["*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User", ...("*" | "Variable" | "Datasource" | "Secret" | "GlobalSecret" | "Project" | "Dashboard" | "EphemeralDashboard" | "Folder" | "GlobalDatasource" | "GlobalRole" | "GlobalRoleBinding" | "GlobalVariable" | "Role" | "RoleBinding" | "User")[]];
221
221
  }[];
222
222
  };
223
223
  metadata: {
@@ -1 +1 @@
1
- {"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/validation/role.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6BxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS/B,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGtC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
1
+ {"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/validation/role.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8BxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS/B,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGtC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -25,6 +25,7 @@ const permissionValidationSchema = z.object({
25
25
  '*',
26
26
  'Dashboard',
27
27
  'Datasource',
28
+ 'EphemeralDashboard',
28
29
  'Folder',
29
30
  'GlobalDatasource',
30
31
  'GlobalRole',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/validation/role.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\nimport { resourceIdValidationSchema } from './resource';\n\nconst permissionValidationSchema = z.object({\n // TODO: use SCOPE & ACTIONS constants\n actions: z.array(z.enum(['*', 'create', 'read', 'update', 'delete'])).nonempty('Must contains at least 1 action'),\n scopes: z\n .array(\n z.enum([\n '*',\n 'Dashboard',\n 'Datasource',\n 'Folder',\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'User',\n 'Variable',\n ])\n )\n .nonempty('Must contains at least 1 scope'), // TODO: limit project role\n});\n\nexport const roleValidationSchema = z.object({\n kind: z.literal('Role'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n project: resourceIdValidationSchema,\n }),\n spec: z.object({\n permissions: z.array(permissionValidationSchema),\n }),\n});\n\nexport const globalRoleValidationSchema = z.object({\n kind: z.literal('GlobalRole'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n }),\n spec: z.object({\n permissions: z.array(permissionValidationSchema),\n }),\n});\n\nexport const rolesEditorValidationSchema = z.discriminatedUnion('kind', [\n roleValidationSchema,\n globalRoleValidationSchema,\n]);\n\nexport type RolesEditorValidationType = z.infer<typeof rolesEditorValidationSchema>;\n"],"names":["z","resourceIdValidationSchema","permissionValidationSchema","object","actions","array","enum","nonempty","scopes","roleValidationSchema","kind","literal","metadata","name","project","spec","permissions","globalRoleValidationSchema","rolesEditorValidationSchema","discriminatedUnion"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,0BAA0B,QAAQ,aAAa;AAExD,MAAMC,6BAA6BF,EAAEG,MAAM,CAAC;IAC1C,sCAAsC;IACtCC,SAASJ,EAAEK,KAAK,CAACL,EAAEM,IAAI,CAAC;QAAC;QAAK;QAAU;QAAQ;QAAU;KAAS,GAAGC,QAAQ,CAAC;IAC/EC,QAAQR,EACLK,KAAK,CACJL,EAAEM,IAAI,CAAC;QACL;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD,GAEFC,QAAQ,CAAC;AACd;AAEA,OAAO,MAAME,uBAAuBT,EAAEG,MAAM,CAAC;IAC3CO,MAAMV,EAAEW,OAAO,CAAC;IAChBC,UAAUZ,EAAEG,MAAM,CAAC;QACjBU,MAAMZ;QACNa,SAASb;IACX;IACAc,MAAMf,EAAEG,MAAM,CAAC;QACba,aAAahB,EAAEK,KAAK,CAACH;IACvB;AACF,GAAG;AAEH,OAAO,MAAMe,6BAA6BjB,EAAEG,MAAM,CAAC;IACjDO,MAAMV,EAAEW,OAAO,CAAC;IAChBC,UAAUZ,EAAEG,MAAM,CAAC;QACjBU,MAAMZ;IACR;IACAc,MAAMf,EAAEG,MAAM,CAAC;QACba,aAAahB,EAAEK,KAAK,CAACH;IACvB;AACF,GAAG;AAEH,OAAO,MAAMgB,8BAA8BlB,EAAEmB,kBAAkB,CAAC,QAAQ;IACtEV;IACAQ;CACD,EAAE"}
1
+ {"version":3,"sources":["../../src/validation/role.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\nimport { resourceIdValidationSchema } from './resource';\n\nconst permissionValidationSchema = z.object({\n // TODO: use SCOPE & ACTIONS constants\n actions: z.array(z.enum(['*', 'create', 'read', 'update', 'delete'])).nonempty('Must contains at least 1 action'),\n scopes: z\n .array(\n z.enum([\n '*',\n 'Dashboard',\n 'Datasource',\n 'EphemeralDashboard',\n 'Folder',\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'User',\n 'Variable',\n ])\n )\n .nonempty('Must contains at least 1 scope'), // TODO: limit project role\n});\n\nexport const roleValidationSchema = z.object({\n kind: z.literal('Role'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n project: resourceIdValidationSchema,\n }),\n spec: z.object({\n permissions: z.array(permissionValidationSchema),\n }),\n});\n\nexport const globalRoleValidationSchema = z.object({\n kind: z.literal('GlobalRole'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n }),\n spec: z.object({\n permissions: z.array(permissionValidationSchema),\n }),\n});\n\nexport const rolesEditorValidationSchema = z.discriminatedUnion('kind', [\n roleValidationSchema,\n globalRoleValidationSchema,\n]);\n\nexport type RolesEditorValidationType = z.infer<typeof rolesEditorValidationSchema>;\n"],"names":["z","resourceIdValidationSchema","permissionValidationSchema","object","actions","array","enum","nonempty","scopes","roleValidationSchema","kind","literal","metadata","name","project","spec","permissions","globalRoleValidationSchema","rolesEditorValidationSchema","discriminatedUnion"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,0BAA0B,QAAQ,aAAa;AAExD,MAAMC,6BAA6BF,EAAEG,MAAM,CAAC;IAC1C,sCAAsC;IACtCC,SAASJ,EAAEK,KAAK,CAACL,EAAEM,IAAI,CAAC;QAAC;QAAK;QAAU;QAAQ;QAAU;KAAS,GAAGC,QAAQ,CAAC;IAC/EC,QAAQR,EACLK,KAAK,CACJL,EAAEM,IAAI,CAAC;QACL;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD,GAEFC,QAAQ,CAAC;AACd;AAEA,OAAO,MAAME,uBAAuBT,EAAEG,MAAM,CAAC;IAC3CO,MAAMV,EAAEW,OAAO,CAAC;IAChBC,UAAUZ,EAAEG,MAAM,CAAC;QACjBU,MAAMZ;QACNa,SAASb;IACX;IACAc,MAAMf,EAAEG,MAAM,CAAC;QACba,aAAahB,EAAEK,KAAK,CAACH;IACvB;AACF,GAAG;AAEH,OAAO,MAAMe,6BAA6BjB,EAAEG,MAAM,CAAC;IACjDO,MAAMV,EAAEW,OAAO,CAAC;IAChBC,UAAUZ,EAAEG,MAAM,CAAC;QACjBU,MAAMZ;IACR;IACAc,MAAMf,EAAEG,MAAM,CAAC;QACba,aAAahB,EAAEK,KAAK,CAACH;IACvB;AACF,GAAG;AAEH,OAAO,MAAMgB,8BAA8BlB,EAAEmB,kBAAkB,CAAC,QAAQ;IACtEV;IACAQ;CACD,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.44.0-rc1",
3
+ "version": "0.44.0-rc2",
4
4
  "description": "The plugin feature in Pereses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -28,8 +28,8 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "0.44.0-rc1",
32
- "@perses-dev/core": "0.44.0-rc1",
31
+ "@perses-dev/components": "0.44.0-rc2",
32
+ "@perses-dev/core": "0.44.0-rc2",
33
33
  "date-fns": "^2.30.0",
34
34
  "immer": "^9.0.15",
35
35
  "react-hook-form": "^7.46.1",
@@ -38,7 +38,7 @@
38
38
  "zod": "^3.22.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@perses-dev/storybook": "0.44.0-rc1"
41
+ "@perses-dev/storybook": "0.44.0-rc2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@mui/material": "^5.10.0",