@perses-dev/core 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/model/index.js +1 -0
  3. package/dist/cjs/model/resource.js +14 -3
  4. package/dist/cjs/model/time.js +2 -2
  5. package/dist/cjs/model/trace-data.js +29 -1
  6. package/dist/cjs/model/user.js +16 -0
  7. package/dist/cjs/schema/datasource.js +85 -0
  8. package/dist/cjs/schema/display.js +27 -0
  9. package/dist/cjs/schema/duration.js +25 -0
  10. package/dist/cjs/schema/index.js +40 -0
  11. package/dist/cjs/schema/metadata.js +41 -0
  12. package/dist/cjs/schema/panel.js +104 -0
  13. package/dist/cjs/schema/plugin.js +27 -0
  14. package/dist/cjs/schema/role.js +86 -0
  15. package/dist/cjs/schema/rolebinding.js +65 -0
  16. package/dist/cjs/schema/secret.js +174 -0
  17. package/dist/cjs/schema/user.js +57 -0
  18. package/dist/cjs/schema/variable.js +171 -0
  19. package/dist/cjs/utils/fetch.js +12 -5
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/model/calculations.d.ts +1 -1
  25. package/dist/model/calculations.d.ts.map +1 -1
  26. package/dist/model/calculations.js.map +1 -1
  27. package/dist/model/datasource.d.ts +8 -8
  28. package/dist/model/datasource.d.ts.map +1 -1
  29. package/dist/model/datasource.js.map +1 -1
  30. package/dist/model/index.d.ts +1 -0
  31. package/dist/model/index.d.ts.map +1 -1
  32. package/dist/model/index.js +1 -0
  33. package/dist/model/index.js.map +1 -1
  34. package/dist/model/panels.d.ts +9 -1
  35. package/dist/model/panels.d.ts.map +1 -1
  36. package/dist/model/panels.js +1 -1
  37. package/dist/model/panels.js.map +1 -1
  38. package/dist/model/resource.d.ts +1 -0
  39. package/dist/model/resource.d.ts.map +1 -1
  40. package/dist/model/resource.js +3 -0
  41. package/dist/model/resource.js.map +1 -1
  42. package/dist/model/time.js +2 -2
  43. package/dist/model/time.js.map +1 -1
  44. package/dist/model/trace-data.d.ts +80 -7
  45. package/dist/model/trace-data.d.ts.map +1 -1
  46. package/dist/model/trace-data.js +7 -3
  47. package/dist/model/trace-data.js.map +1 -1
  48. package/dist/model/user.d.ts +21 -0
  49. package/dist/model/user.d.ts.map +1 -0
  50. package/dist/model/user.js +15 -0
  51. package/dist/model/user.js.map +1 -0
  52. package/dist/model/variables.d.ts +9 -8
  53. package/dist/model/variables.d.ts.map +1 -1
  54. package/dist/model/variables.js.map +1 -1
  55. package/dist/schema/datasource.d.ts +60 -0
  56. package/dist/schema/datasource.d.ts.map +1 -0
  57. package/dist/schema/datasource.js +54 -0
  58. package/dist/schema/datasource.js.map +1 -0
  59. package/dist/schema/display.d.ts +12 -0
  60. package/dist/schema/display.d.ts.map +1 -0
  61. package/dist/schema/display.js +19 -0
  62. package/dist/schema/display.js.map +1 -0
  63. package/dist/schema/duration.d.ts +3 -0
  64. package/dist/schema/duration.d.ts.map +1 -0
  65. package/dist/schema/duration.js +17 -0
  66. package/dist/schema/duration.js.map +1 -0
  67. package/dist/schema/index.d.ts +12 -0
  68. package/dist/schema/index.d.ts.map +1 -0
  69. package/dist/schema/index.js +25 -0
  70. package/dist/schema/index.js.map +1 -0
  71. package/dist/schema/metadata.d.ts +20 -0
  72. package/dist/schema/metadata.d.ts.map +1 -0
  73. package/dist/schema/metadata.js +22 -0
  74. package/dist/schema/metadata.js.map +1 -0
  75. package/dist/schema/panel.d.ts +13 -0
  76. package/dist/schema/panel.d.ts.map +1 -0
  77. package/dist/schema/panel.js +67 -0
  78. package/dist/schema/panel.js.map +1 -0
  79. package/dist/schema/plugin.d.ts +14 -0
  80. package/dist/schema/plugin.d.ts.map +1 -0
  81. package/dist/schema/plugin.js +19 -0
  82. package/dist/schema/plugin.js.map +1 -0
  83. package/dist/schema/role.d.ts +57 -0
  84. package/dist/schema/role.d.ts.map +1 -0
  85. package/dist/schema/role.js +61 -0
  86. package/dist/schema/role.js.map +1 -0
  87. package/dist/schema/rolebinding.d.ts +57 -0
  88. package/dist/schema/rolebinding.d.ts.map +1 -0
  89. package/dist/schema/rolebinding.js +40 -0
  90. package/dist/schema/rolebinding.js.map +1 -0
  91. package/dist/schema/secret.d.ts +1138 -0
  92. package/dist/schema/secret.d.ts.map +1 -0
  93. package/dist/schema/secret.js +152 -0
  94. package/dist/schema/secret.js.map +1 -0
  95. package/dist/schema/user.d.ts +8 -0
  96. package/dist/schema/user.d.ts.map +1 -0
  97. package/dist/schema/user.js +36 -0
  98. package/dist/schema/user.js.map +1 -0
  99. package/dist/schema/variable.d.ts +90 -0
  100. package/dist/schema/variable.d.ts.map +1 -0
  101. package/dist/schema/variable.js +119 -0
  102. package/dist/schema/variable.js.map +1 -0
  103. package/dist/utils/fetch.d.ts.map +1 -1
  104. package/dist/utils/fetch.js +12 -5
  105. package/dist/utils/fetch.js.map +1 -1
  106. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _export_star(require("./constants"), exports);
18
18
  _export_star(require("./model"), exports);
19
+ _export_star(require("./schema"), exports);
19
20
  _export_star(require("./utils"), exports);
20
21
  function _export_star(from, to) {
21
22
  Object.keys(from).forEach(function(k) {
@@ -39,6 +39,7 @@ _export_star(require("./time-series-data"), exports);
39
39
  _export_star(require("./time-series-queries"), exports);
40
40
  _export_star(require("./trace-data"), exports);
41
41
  _export_star(require("./units"), exports);
42
+ _export_star(require("./user"), exports);
42
43
  _export_star(require("./variables"), exports);
43
44
  function _export_star(from, to) {
44
45
  Object.keys(from).forEach(function(k) {
@@ -14,12 +14,23 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "getMetadataProject", {
18
- enumerable: true,
19
- get: function() {
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ getMetadataProject: function() {
20
25
  return getMetadataProject;
26
+ },
27
+ isProjectMetadata: function() {
28
+ return isProjectMetadata;
21
29
  }
22
30
  });
31
+ function isProjectMetadata(metadata) {
32
+ return 'project' in metadata;
33
+ }
23
34
  function getMetadataProject(metadata) {
24
35
  return 'project' in metadata ? metadata.project : undefined;
25
36
  }
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -144,7 +144,7 @@ function formatDuration(duration) {
144
144
  if (seconds) {
145
145
  result.push(`${seconds}s`);
146
146
  }
147
- const ms = (duration.seconds - seconds) * 1000;
147
+ const ms = Math.round((duration.seconds - seconds) * 1000);
148
148
  if (ms) {
149
149
  result.push(`${ms}ms`);
150
150
  }
@@ -10,7 +10,35 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- "use strict";
13
+ /**
14
+ * Common types
15
+ */ "use strict";
14
16
  Object.defineProperty(exports, "__esModule", {
15
17
  value: true
16
18
  });
19
+ function _export(target, all) {
20
+ for(var name in all)Object.defineProperty(target, name, {
21
+ enumerable: true,
22
+ get: all[name]
23
+ });
24
+ }
25
+ _export(exports, {
26
+ SpanStatusError: function() {
27
+ return SpanStatusError;
28
+ },
29
+ SpanStatusOk: function() {
30
+ return SpanStatusOk;
31
+ },
32
+ SpanStatusUnset: function() {
33
+ return SpanStatusUnset;
34
+ },
35
+ isValidTraceId: function() {
36
+ return isValidTraceId;
37
+ }
38
+ });
39
+ const SpanStatusUnset = 'STATUS_CODE_UNSET';
40
+ const SpanStatusOk = 'STATUS_CODE_OK';
41
+ const SpanStatusError = 'STATUS_CODE_ERROR';
42
+ function isValidTraceId(traceId) {
43
+ return /^[0-9a-fA-F]+$/.test(traceId);
44
+ }
@@ -0,0 +1,16 @@
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
+ });
@@ -0,0 +1,85 @@
1
+ // Copyright 2023 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ buildDatasourceDefinitionSchema: function() {
25
+ return buildDatasourceDefinitionSchema;
26
+ },
27
+ buildDatasourceSpecSchema: function() {
28
+ return buildDatasourceSpecSchema;
29
+ },
30
+ datasourceDefinitionSchema: function() {
31
+ return datasourceDefinitionSchema;
32
+ },
33
+ datasourceSchema: function() {
34
+ return datasourceSchema;
35
+ },
36
+ datasourceSpecSchema: function() {
37
+ return datasourceSpecSchema;
38
+ },
39
+ datasourcesSchema: function() {
40
+ return datasourcesSchema;
41
+ },
42
+ globalDatasourceSchema: function() {
43
+ return globalDatasourceSchema;
44
+ }
45
+ });
46
+ const _zod = require("zod");
47
+ const _metadata = require("./metadata");
48
+ const _plugin = require("./plugin");
49
+ const _display = require("./display");
50
+ const datasourceSpecSchema = _zod.z.object({
51
+ display: _display.displaySchema.optional(),
52
+ default: _zod.z.boolean(),
53
+ plugin: _plugin.pluginSchema
54
+ });
55
+ function buildDatasourceSpecSchema(pluginSchema) {
56
+ return _zod.z.object({
57
+ display: _display.displaySchema.optional(),
58
+ default: _zod.z.boolean(),
59
+ plugin: pluginSchema
60
+ });
61
+ }
62
+ const datasourceSchema = _zod.z.object({
63
+ kind: _zod.z.literal('Datasource'),
64
+ metadata: _metadata.projectMetadataSchema,
65
+ spec: datasourceSpecSchema
66
+ });
67
+ const globalDatasourceSchema = _zod.z.object({
68
+ kind: _zod.z.literal('GlobalDatasource'),
69
+ metadata: _metadata.metadataSchema,
70
+ spec: datasourceSpecSchema
71
+ });
72
+ const datasourcesSchema = _zod.z.discriminatedUnion('kind', [
73
+ datasourceSchema,
74
+ globalDatasourceSchema
75
+ ]);
76
+ const datasourceDefinitionSchema = _zod.z.object({
77
+ name: _zod.z.string().min(1),
78
+ spec: datasourceSpecSchema
79
+ });
80
+ function buildDatasourceDefinitionSchema(pluginSchema) {
81
+ return _zod.z.object({
82
+ name: _zod.z.string().min(1),
83
+ spec: buildDatasourceSpecSchema(pluginSchema)
84
+ });
85
+ }
@@ -0,0 +1,27 @@
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, "displaySchema", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return displaySchema;
21
+ }
22
+ });
23
+ const _zod = require("zod");
24
+ const displaySchema = _zod.z.object({
25
+ name: _zod.z.string().optional(),
26
+ description: _zod.z.string().optional()
27
+ });
@@ -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 _zod = require("zod");
24
+ const _model = require("../model");
25
+ const durationValidationSchema = _zod.z.string().min(1, 'Required').regex(_model.DURATION_REGEX, 'Must be a valid duration string');
@@ -0,0 +1,40 @@
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
+ _export_star(require("./datasource"), exports);
18
+ _export_star(require("./display"), exports);
19
+ _export_star(require("./duration"), exports);
20
+ _export_star(require("./metadata"), exports);
21
+ _export_star(require("./panel"), exports);
22
+ _export_star(require("./plugin"), exports);
23
+ _export_star(require("./role"), exports);
24
+ _export_star(require("./rolebinding"), exports);
25
+ _export_star(require("./secret"), exports);
26
+ _export_star(require("./user"), exports);
27
+ _export_star(require("./variable"), exports);
28
+ function _export_star(from, to) {
29
+ Object.keys(from).forEach(function(k) {
30
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
31
+ Object.defineProperty(to, k, {
32
+ enumerable: true,
33
+ get: function() {
34
+ return from[k];
35
+ }
36
+ });
37
+ }
38
+ });
39
+ return from;
40
+ }
@@ -0,0 +1,41 @@
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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ metadataSchema: function() {
25
+ return metadataSchema;
26
+ },
27
+ nameSchema: function() {
28
+ return nameSchema;
29
+ },
30
+ projectMetadataSchema: function() {
31
+ return projectMetadataSchema;
32
+ }
33
+ });
34
+ const _zod = require("zod");
35
+ const nameSchema = _zod.z.string().min(1, 'Required').max(75, 'Must be 75 or fewer characters long').regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');
36
+ const metadataSchema = _zod.z.object({
37
+ name: nameSchema
38
+ });
39
+ const projectMetadataSchema = metadataSchema.extend({
40
+ project: nameSchema
41
+ });
@@ -0,0 +1,104 @@
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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ buildPanelDefinitionSchema: function() {
25
+ return buildPanelDefinitionSchema;
26
+ },
27
+ buildPanelEditorSchema: function() {
28
+ return buildPanelEditorSchema;
29
+ },
30
+ buildPanelSpecSchema: function() {
31
+ return buildPanelSpecSchema;
32
+ },
33
+ linkSchema: function() {
34
+ return linkSchema;
35
+ },
36
+ panelDefinitionSchema: function() {
37
+ return panelDefinitionSchema;
38
+ },
39
+ panelDisplaySpec: function() {
40
+ return panelDisplaySpec;
41
+ },
42
+ panelEditorSchema: function() {
43
+ return panelEditorSchema;
44
+ },
45
+ panelSpecSchema: function() {
46
+ return panelSpecSchema;
47
+ },
48
+ querySpecSchema: function() {
49
+ return querySpecSchema;
50
+ }
51
+ });
52
+ const _zod = require("zod");
53
+ const _plugin = require("./plugin");
54
+ const panelDisplaySpec = _zod.z.object({
55
+ name: _zod.z.string(),
56
+ description: _zod.z.string().optional()
57
+ });
58
+ const querySpecSchema = _zod.z.object({
59
+ kind: _zod.z.string().min(1),
60
+ spec: _zod.z.object({
61
+ plugin: _plugin.pluginSchema
62
+ })
63
+ });
64
+ const linkSchema = _zod.z.object({
65
+ name: _zod.z.string().optional(),
66
+ url: _zod.z.string().min(1),
67
+ tooltip: _zod.z.string().optional(),
68
+ renderVariables: _zod.z.boolean().optional(),
69
+ targetBlank: _zod.z.boolean().optional()
70
+ });
71
+ const panelSpecSchema = _zod.z.object({
72
+ display: panelDisplaySpec,
73
+ plugin: _plugin.pluginSchema,
74
+ queries: _zod.z.array(querySpecSchema).optional(),
75
+ links: _zod.z.array(linkSchema).optional()
76
+ });
77
+ function buildPanelSpecSchema(pluginSchema) {
78
+ return _zod.z.object({
79
+ display: panelDisplaySpec,
80
+ plugin: pluginSchema,
81
+ queries: _zod.z.array(querySpecSchema).optional(),
82
+ links: _zod.z.array(linkSchema).optional()
83
+ });
84
+ }
85
+ const panelDefinitionSchema = _zod.z.object({
86
+ kind: _zod.z.literal('Panel'),
87
+ spec: panelSpecSchema
88
+ });
89
+ function buildPanelDefinitionSchema(pluginSchema) {
90
+ return _zod.z.object({
91
+ kind: _zod.z.literal('Panel'),
92
+ spec: buildPanelSpecSchema(pluginSchema)
93
+ });
94
+ }
95
+ const panelEditorSchema = _zod.z.object({
96
+ groupId: _zod.z.number(),
97
+ panelDefinition: panelDefinitionSchema
98
+ });
99
+ function buildPanelEditorSchema(pluginSchema) {
100
+ return _zod.z.object({
101
+ groupId: _zod.z.number(),
102
+ panelDefinition: buildPanelDefinitionSchema(pluginSchema)
103
+ });
104
+ }
@@ -0,0 +1,27 @@
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, "pluginSchema", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return pluginSchema;
21
+ }
22
+ });
23
+ const _zod = require("zod");
24
+ const pluginSchema = _zod.z.object({
25
+ kind: _zod.z.string().min(1, 'Required'),
26
+ spec: _zod.z.record(_zod.z.string(), _zod.z.any())
27
+ });
@@ -0,0 +1,86 @@
1
+ // Copyright 2023 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ globalRoleSchema: function() {
25
+ return globalRoleSchema;
26
+ },
27
+ permissionSchema: function() {
28
+ return permissionSchema;
29
+ },
30
+ roleSchema: function() {
31
+ return roleSchema;
32
+ },
33
+ roleSpecSchema: function() {
34
+ return roleSpecSchema;
35
+ },
36
+ rolesEditorSchema: function() {
37
+ return rolesEditorSchema;
38
+ }
39
+ });
40
+ const _zod = require("zod");
41
+ const _metadata = require("./metadata");
42
+ const permissionSchema = _zod.z.object({
43
+ // TODO: use SCOPE & ACTIONS constants
44
+ actions: _zod.z.array(_zod.z.enum([
45
+ '*',
46
+ 'create',
47
+ 'read',
48
+ 'update',
49
+ 'delete'
50
+ ])).nonempty('Must contains at least 1 action'),
51
+ scopes: _zod.z.array(_zod.z.enum([
52
+ '*',
53
+ 'Dashboard',
54
+ 'Datasource',
55
+ 'EphemeralDashboard',
56
+ 'Folder',
57
+ 'GlobalDatasource',
58
+ 'GlobalRole',
59
+ 'GlobalRoleBinding',
60
+ 'GlobalSecret',
61
+ 'GlobalVariable',
62
+ 'Project',
63
+ 'Role',
64
+ 'RoleBinding',
65
+ 'Secret',
66
+ 'User',
67
+ 'Variable'
68
+ ])).nonempty('Must contains at least 1 scope')
69
+ });
70
+ const roleSpecSchema = _zod.z.object({
71
+ permissions: _zod.z.array(permissionSchema)
72
+ });
73
+ const roleSchema = _zod.z.object({
74
+ kind: _zod.z.literal('Role'),
75
+ metadata: _metadata.projectMetadataSchema,
76
+ spec: roleSpecSchema
77
+ });
78
+ const globalRoleSchema = _zod.z.object({
79
+ kind: _zod.z.literal('GlobalRole'),
80
+ metadata: _metadata.metadataSchema,
81
+ spec: roleSpecSchema
82
+ });
83
+ const rolesEditorSchema = _zod.z.discriminatedUnion('kind', [
84
+ roleSchema,
85
+ globalRoleSchema
86
+ ]);
@@ -0,0 +1,65 @@
1
+ // Copyright 2023 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
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ globalRoleBindingSchema: function() {
25
+ return globalRoleBindingSchema;
26
+ },
27
+ roleBindingSchema: function() {
28
+ return roleBindingSchema;
29
+ },
30
+ roleBindingSpecSchema: function() {
31
+ return roleBindingSpecSchema;
32
+ },
33
+ roleBindingsEditorSchema: function() {
34
+ return roleBindingsEditorSchema;
35
+ },
36
+ subjectSchema: function() {
37
+ return subjectSchema;
38
+ }
39
+ });
40
+ const _zod = require("zod");
41
+ const _metadata = require("./metadata");
42
+ const subjectSchema = _zod.z.object({
43
+ kind: _zod.z.enum([
44
+ 'User'
45
+ ]),
46
+ name: _metadata.nameSchema
47
+ });
48
+ const roleBindingSpecSchema = _zod.z.object({
49
+ role: _metadata.nameSchema,
50
+ subjects: _zod.z.array(subjectSchema).nonempty()
51
+ });
52
+ const roleBindingSchema = _zod.z.object({
53
+ kind: _zod.z.literal('RoleBinding'),
54
+ metadata: _metadata.projectMetadataSchema,
55
+ spec: roleBindingSpecSchema
56
+ });
57
+ const globalRoleBindingSchema = _zod.z.object({
58
+ kind: _zod.z.literal('GlobalRoleBinding'),
59
+ metadata: _metadata.metadataSchema,
60
+ spec: roleBindingSpecSchema
61
+ });
62
+ const roleBindingsEditorSchema = _zod.z.discriminatedUnion('kind', [
63
+ roleBindingSchema,
64
+ globalRoleBindingSchema
65
+ ]);