@perses-dev/core 0.46.0 → 0.47.0-rc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/resource.js +14 -3
- package/dist/cjs/model/time.js +2 -2
- package/dist/cjs/model/trace-data.js +29 -1
- package/dist/cjs/model/user.js +16 -0
- package/dist/cjs/schema/datasource.js +85 -0
- package/dist/cjs/schema/display.js +27 -0
- package/dist/cjs/schema/duration.js +25 -0
- package/dist/cjs/schema/index.js +40 -0
- package/dist/cjs/schema/metadata.js +41 -0
- package/dist/cjs/schema/panel.js +104 -0
- package/dist/cjs/schema/plugin.js +27 -0
- package/dist/cjs/schema/role.js +86 -0
- package/dist/cjs/schema/rolebinding.js +65 -0
- package/dist/cjs/schema/secret.js +174 -0
- package/dist/cjs/schema/user.js +57 -0
- package/dist/cjs/schema/variable.js +171 -0
- package/dist/cjs/utils/fetch.js +12 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/calculations.d.ts +1 -1
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +8 -8
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/panels.d.ts +9 -1
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/resource.d.ts +1 -0
- package/dist/model/resource.d.ts.map +1 -1
- package/dist/model/resource.js +3 -0
- package/dist/model/resource.js.map +1 -1
- package/dist/model/time.js +2 -2
- package/dist/model/time.js.map +1 -1
- package/dist/model/trace-data.d.ts +80 -7
- package/dist/model/trace-data.d.ts.map +1 -1
- package/dist/model/trace-data.js +7 -3
- package/dist/model/trace-data.js.map +1 -1
- package/dist/model/user.d.ts +21 -0
- package/dist/model/user.d.ts.map +1 -0
- package/dist/model/user.js +15 -0
- package/dist/model/user.js.map +1 -0
- package/dist/model/variables.d.ts +9 -8
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/schema/datasource.d.ts +60 -0
- package/dist/schema/datasource.d.ts.map +1 -0
- package/dist/schema/datasource.js +54 -0
- package/dist/schema/datasource.js.map +1 -0
- package/dist/schema/display.d.ts +12 -0
- package/dist/schema/display.d.ts.map +1 -0
- package/dist/schema/display.js +19 -0
- package/dist/schema/display.js.map +1 -0
- package/dist/schema/duration.d.ts +3 -0
- package/dist/schema/duration.d.ts.map +1 -0
- package/dist/schema/duration.js +17 -0
- package/dist/schema/duration.js.map +1 -0
- package/dist/schema/index.d.ts +12 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/metadata.d.ts +20 -0
- package/dist/schema/metadata.d.ts.map +1 -0
- package/dist/schema/metadata.js +22 -0
- package/dist/schema/metadata.js.map +1 -0
- package/dist/schema/panel.d.ts +13 -0
- package/dist/schema/panel.d.ts.map +1 -0
- package/dist/schema/panel.js +67 -0
- package/dist/schema/panel.js.map +1 -0
- package/dist/schema/plugin.d.ts +14 -0
- package/dist/schema/plugin.d.ts.map +1 -0
- package/dist/schema/plugin.js +19 -0
- package/dist/schema/plugin.js.map +1 -0
- package/dist/schema/role.d.ts +57 -0
- package/dist/schema/role.d.ts.map +1 -0
- package/dist/schema/role.js +61 -0
- package/dist/schema/role.js.map +1 -0
- package/dist/schema/rolebinding.d.ts +57 -0
- package/dist/schema/rolebinding.d.ts.map +1 -0
- package/dist/schema/rolebinding.js +40 -0
- package/dist/schema/rolebinding.js.map +1 -0
- package/dist/schema/secret.d.ts +1138 -0
- package/dist/schema/secret.d.ts.map +1 -0
- package/dist/schema/secret.js +152 -0
- package/dist/schema/secret.js.map +1 -0
- package/dist/schema/user.d.ts +8 -0
- package/dist/schema/user.d.ts.map +1 -0
- package/dist/schema/user.js +36 -0
- package/dist/schema/user.js.map +1 -0
- package/dist/schema/variable.d.ts +90 -0
- package/dist/schema/variable.d.ts.map +1 -0
- package/dist/schema/variable.js +119 -0
- package/dist/schema/variable.js.map +1 -0
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +12 -5
- package/dist/utils/fetch.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../src/schema/secret.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8GzB,CAAC;AAEL,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIvB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAmE,CAAC;AAEpG,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
import { z } from 'zod';
|
|
14
|
+
import { metadataSchema, projectMetadataSchema } from './metadata';
|
|
15
|
+
export const secretSpecSchema = z.object({
|
|
16
|
+
basicAuth: z.object({
|
|
17
|
+
username: z.string().min(1),
|
|
18
|
+
password: z.string().optional(),
|
|
19
|
+
passwordFile: z.string().optional()
|
|
20
|
+
}).superRefine((val, ctx)=>{
|
|
21
|
+
if (val.password && val.password.length > 0 && val.passwordFile && val.passwordFile.length > 0) {
|
|
22
|
+
ctx.addIssue({
|
|
23
|
+
code: z.ZodIssueCode.custom,
|
|
24
|
+
message: 'Only one of the fields must be defined',
|
|
25
|
+
path: [
|
|
26
|
+
'password'
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
ctx.addIssue({
|
|
30
|
+
code: z.ZodIssueCode.custom,
|
|
31
|
+
message: 'Only one of the fields must be defined',
|
|
32
|
+
path: [
|
|
33
|
+
'passwordFile'
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}).optional(),
|
|
38
|
+
authorization: z.object({
|
|
39
|
+
type: z.string().optional(),
|
|
40
|
+
credentials: z.string().optional(),
|
|
41
|
+
credentialsFile: z.string().optional()
|
|
42
|
+
}).superRefine((val, ctx)=>{
|
|
43
|
+
if (val.credentials && val.credentials.length > 0 && val.credentialsFile && val.credentialsFile.length > 0) {
|
|
44
|
+
ctx.addIssue({
|
|
45
|
+
code: z.ZodIssueCode.custom,
|
|
46
|
+
message: 'Only one of the fields must be defined',
|
|
47
|
+
path: [
|
|
48
|
+
'credentials'
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
ctx.addIssue({
|
|
52
|
+
code: z.ZodIssueCode.custom,
|
|
53
|
+
message: 'Only one of the fields must be defined',
|
|
54
|
+
path: [
|
|
55
|
+
'credentialsFile'
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}).optional(),
|
|
60
|
+
tlsConfig: z.object({
|
|
61
|
+
ca: z.string().optional(),
|
|
62
|
+
cert: z.string().optional(),
|
|
63
|
+
key: z.string().optional(),
|
|
64
|
+
caFile: z.string().optional(),
|
|
65
|
+
certFile: z.string().optional(),
|
|
66
|
+
keyFile: z.string().optional(),
|
|
67
|
+
serverName: z.string().optional(),
|
|
68
|
+
insecureSkipVerify: z.boolean()
|
|
69
|
+
}).superRefine((val, ctx)=>{
|
|
70
|
+
if (val.ca && val.ca.length > 0 && val.caFile && val.caFile.length > 0) {
|
|
71
|
+
ctx.addIssue({
|
|
72
|
+
code: z.ZodIssueCode.custom,
|
|
73
|
+
message: 'Only one of the fields must be defined',
|
|
74
|
+
path: [
|
|
75
|
+
'ca'
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
ctx.addIssue({
|
|
79
|
+
code: z.ZodIssueCode.custom,
|
|
80
|
+
message: 'Only one of the fields must be defined',
|
|
81
|
+
path: [
|
|
82
|
+
'caFile'
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (val.cert && val.cert.length > 0 && val.certFile && val.certFile.length > 0) {
|
|
87
|
+
ctx.addIssue({
|
|
88
|
+
code: z.ZodIssueCode.custom,
|
|
89
|
+
message: 'Only one of the fields must be defined',
|
|
90
|
+
path: [
|
|
91
|
+
'cert'
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
ctx.addIssue({
|
|
95
|
+
code: z.ZodIssueCode.custom,
|
|
96
|
+
message: 'Only one of the fields must be defined',
|
|
97
|
+
path: [
|
|
98
|
+
'certFile'
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (val.key && val.key.length > 0 && val.keyFile && val.keyFile.length > 0) {
|
|
103
|
+
ctx.addIssue({
|
|
104
|
+
code: z.ZodIssueCode.custom,
|
|
105
|
+
message: 'Only one of the fields must be defined',
|
|
106
|
+
path: [
|
|
107
|
+
'key'
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
ctx.addIssue({
|
|
111
|
+
code: z.ZodIssueCode.custom,
|
|
112
|
+
message: 'Only one of the fields must be defined',
|
|
113
|
+
path: [
|
|
114
|
+
'keyFile'
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}).optional()
|
|
119
|
+
}).superRefine((val, ctx)=>{
|
|
120
|
+
if (val.basicAuth && val.authorization) {
|
|
121
|
+
ctx.addIssue({
|
|
122
|
+
code: z.ZodIssueCode.custom,
|
|
123
|
+
message: 'Only one of the fields must be defined',
|
|
124
|
+
path: [
|
|
125
|
+
'basicAuth'
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
ctx.addIssue({
|
|
129
|
+
code: z.ZodIssueCode.custom,
|
|
130
|
+
message: 'Only one of the fields must be defined',
|
|
131
|
+
path: [
|
|
132
|
+
'authorization'
|
|
133
|
+
]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
export const secretSchema = z.object({
|
|
138
|
+
kind: z.literal('Secret'),
|
|
139
|
+
metadata: projectMetadataSchema,
|
|
140
|
+
spec: secretSpecSchema
|
|
141
|
+
});
|
|
142
|
+
export const globalSecretSchema = z.object({
|
|
143
|
+
kind: z.literal('GlobalSecret'),
|
|
144
|
+
metadata: metadataSchema,
|
|
145
|
+
spec: secretSpecSchema
|
|
146
|
+
});
|
|
147
|
+
export const secretsEditorSchema = z.discriminatedUnion('kind', [
|
|
148
|
+
secretSchema,
|
|
149
|
+
globalSecretSchema
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/secret.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 { metadataSchema, projectMetadataSchema } from './metadata';\n\nexport const secretSpecSchema = z\n .object({\n basicAuth: z\n .object({\n username: z.string().min(1),\n password: z.string().optional(),\n passwordFile: z.string().optional(),\n })\n .superRefine((val, ctx) => {\n if (val.password && val.password.length > 0 && val.passwordFile && val.passwordFile.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['password'],\n });\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['passwordFile'],\n });\n }\n })\n .optional(),\n authorization: z\n .object({\n type: z.string().optional(),\n credentials: z.string().optional(),\n credentialsFile: z.string().optional(),\n })\n .superRefine((val, ctx) => {\n if (val.credentials && val.credentials.length > 0 && val.credentialsFile && val.credentialsFile.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['credentials'],\n });\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['credentialsFile'],\n });\n }\n })\n .optional(),\n tlsConfig: z\n .object({\n ca: z.string().optional(),\n cert: z.string().optional(),\n key: z.string().optional(),\n caFile: z.string().optional(),\n certFile: z.string().optional(),\n keyFile: z.string().optional(),\n serverName: z.string().optional(),\n insecureSkipVerify: z.boolean(),\n })\n .superRefine((val, ctx) => {\n if (val.ca && val.ca.length > 0 && val.caFile && val.caFile.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['ca'],\n });\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['caFile'],\n });\n }\n\n if (val.cert && val.cert.length > 0 && val.certFile && val.certFile.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['cert'],\n });\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['certFile'],\n });\n }\n\n if (val.key && val.key.length > 0 && val.keyFile && val.keyFile.length > 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['key'],\n });\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['keyFile'],\n });\n }\n })\n .optional(),\n })\n .superRefine((val, ctx) => {\n if (val.basicAuth && val.authorization) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['basicAuth'],\n });\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Only one of the fields must be defined',\n path: ['authorization'],\n });\n }\n });\n\nexport const secretSchema = z.object({\n kind: z.literal('Secret'),\n metadata: projectMetadataSchema,\n spec: secretSpecSchema,\n});\n\nexport const globalSecretSchema = z.object({\n kind: z.literal('GlobalSecret'),\n metadata: metadataSchema,\n spec: secretSpecSchema,\n});\n\nexport const secretsEditorSchema = z.discriminatedUnion('kind', [secretSchema, globalSecretSchema]);\n\nexport type SecretsEditorSchemaType = z.infer<typeof secretsEditorSchema>;\n"],"names":["z","metadataSchema","projectMetadataSchema","secretSpecSchema","object","basicAuth","username","string","min","password","optional","passwordFile","superRefine","val","ctx","length","addIssue","code","ZodIssueCode","custom","message","path","authorization","type","credentials","credentialsFile","tlsConfig","ca","cert","key","caFile","certFile","keyFile","serverName","insecureSkipVerify","boolean","secretSchema","kind","literal","metadata","spec","globalSecretSchema","secretsEditorSchema","discriminatedUnion"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EA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
2
|
+
import { NativeProvider, OAuthProvider, UserResource, UserSpec } from '../model';
|
|
3
|
+
export declare const nativeProviderSchema: z.Schema<NativeProvider>;
|
|
4
|
+
export declare const oauthProvidersSchema: z.ZodSchema<OAuthProvider>;
|
|
5
|
+
export declare const userSpecSchema: z.ZodSchema<UserSpec>;
|
|
6
|
+
export declare const userSchema: z.ZodSchema<UserResource>;
|
|
7
|
+
export type UserEditorSchemaType = z.infer<typeof userSchema>;
|
|
8
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/schema/user.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGjF,eAAO,MAAM,oBAAoB,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAExD,CAAC;AAEH,eAAO,MAAM,oBAAoB,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,CAI1D,CAAC;AAGH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAK/C,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,YAAY,CAI/C,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
import { z } from 'zod';
|
|
14
|
+
import { metadataSchema } from './metadata';
|
|
15
|
+
export const nativeProviderSchema = z.object({
|
|
16
|
+
password: z.string().optional()
|
|
17
|
+
});
|
|
18
|
+
export const oauthProvidersSchema = z.object({
|
|
19
|
+
issuer: z.string().optional(),
|
|
20
|
+
email: z.string().optional(),
|
|
21
|
+
subject: z.string().optional()
|
|
22
|
+
});
|
|
23
|
+
// TODO: handle exclusion native / oauth?
|
|
24
|
+
export const userSpecSchema = z.object({
|
|
25
|
+
firstName: z.string().optional(),
|
|
26
|
+
lastName: z.string().optional(),
|
|
27
|
+
nativeProvider: nativeProviderSchema.optional(),
|
|
28
|
+
oauthProviders: z.array(oauthProvidersSchema).optional()
|
|
29
|
+
});
|
|
30
|
+
export const userSchema = z.object({
|
|
31
|
+
kind: z.literal('User'),
|
|
32
|
+
metadata: metadataSchema,
|
|
33
|
+
spec: userSpecSchema
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/user.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 { NativeProvider, OAuthProvider, UserResource, UserSpec } from '../model';\nimport { metadataSchema } from './metadata';\n\nexport const nativeProviderSchema: z.Schema<NativeProvider> = z.object({\n password: z.string().optional(),\n});\n\nexport const oauthProvidersSchema: z.ZodSchema<OAuthProvider> = z.object({\n issuer: z.string().optional(),\n email: z.string().optional(),\n subject: z.string().optional(),\n});\n\n// TODO: handle exclusion native / oauth?\nexport const userSpecSchema: z.ZodSchema<UserSpec> = z.object({\n firstName: z.string().optional(),\n lastName: z.string().optional(),\n nativeProvider: nativeProviderSchema.optional(),\n oauthProviders: z.array(oauthProvidersSchema).optional(),\n});\n\nexport const userSchema: z.ZodSchema<UserResource> = z.object({\n kind: z.literal('User'),\n metadata: metadataSchema,\n spec: userSpecSchema,\n});\n\nexport type UserEditorSchemaType = z.infer<typeof userSchema>;\n"],"names":["z","metadataSchema","nativeProviderSchema","object","password","string","optional","oauthProvidersSchema","issuer","email","subject","userSpecSchema","firstName","lastName","nativeProvider","oauthProviders","array","userSchema","kind","literal","metadata","spec"],"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;AAExB,SAASC,cAAc,QAAQ,aAAa;AAE5C,OAAO,MAAMC,uBAAiDF,EAAEG,MAAM,CAAC;IACrEC,UAAUJ,EAAEK,MAAM,GAAGC,QAAQ;AAC/B,GAAG;AAEH,OAAO,MAAMC,uBAAmDP,EAAEG,MAAM,CAAC;IACvEK,QAAQR,EAAEK,MAAM,GAAGC,QAAQ;IAC3BG,OAAOT,EAAEK,MAAM,GAAGC,QAAQ;IAC1BI,SAASV,EAAEK,MAAM,GAAGC,QAAQ;AAC9B,GAAG;AAEH,yCAAyC;AACzC,OAAO,MAAMK,iBAAwCX,EAAEG,MAAM,CAAC;IAC5DS,WAAWZ,EAAEK,MAAM,GAAGC,QAAQ;IAC9BO,UAAUb,EAAEK,MAAM,GAAGC,QAAQ;IAC7BQ,gBAAgBZ,qBAAqBI,QAAQ;IAC7CS,gBAAgBf,EAAEgB,KAAK,CAACT,sBAAsBD,QAAQ;AACxD,GAAG;AAEH,OAAO,MAAMW,aAAwCjB,EAAEG,MAAM,CAAC;IAC5De,MAAMlB,EAAEmB,OAAO,CAAC;IAChBC,UAAUnB;IACVoB,MAAMV;AACR,GAAG"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ListVariableDefinition, ListVariableSpec, TextVariableDefinition, TextVariableSpec, Variable, VariableDefinition, VariableDisplay } from '../model';
|
|
3
|
+
import { PluginSchema } from './plugin';
|
|
4
|
+
export declare const variableDisplaySchema: z.ZodSchema<VariableDisplay>;
|
|
5
|
+
export declare const variableListSpecSchema: z.ZodSchema<ListVariableSpec>;
|
|
6
|
+
export declare function buildVariableListSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<ListVariableSpec>;
|
|
7
|
+
export declare const variableListSchema: z.ZodObject<{
|
|
8
|
+
kind: z.ZodLiteral<"ListVariable">;
|
|
9
|
+
spec: z.ZodType<ListVariableSpec<import("../model").UnknownSpec>, z.ZodTypeDef, ListVariableSpec<import("../model").UnknownSpec>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
kind: "ListVariable";
|
|
12
|
+
spec: ListVariableSpec<import("../model").UnknownSpec>;
|
|
13
|
+
}, {
|
|
14
|
+
kind: "ListVariable";
|
|
15
|
+
spec: ListVariableSpec<import("../model").UnknownSpec>;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function buildVariableListSchema(pluginSchema: PluginSchema): typeof variableListSchema;
|
|
18
|
+
export declare const variableTextSpecSchema: z.ZodSchema<TextVariableSpec>;
|
|
19
|
+
export declare const variableTextSchema: z.ZodObject<{
|
|
20
|
+
kind: z.ZodLiteral<"TextVariable">;
|
|
21
|
+
spec: z.ZodType<TextVariableSpec, z.ZodTypeDef, TextVariableSpec>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
kind: "TextVariable";
|
|
24
|
+
spec: TextVariableSpec;
|
|
25
|
+
}, {
|
|
26
|
+
kind: "TextVariable";
|
|
27
|
+
spec: TextVariableSpec;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const variableSpecSchema: z.ZodSchema<TextVariableDefinition | ListVariableDefinition>;
|
|
30
|
+
export declare function buildVariableSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<VariableDefinition>;
|
|
31
|
+
export declare const variableSchema: z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"Variable">;
|
|
33
|
+
metadata: z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
project: z.ZodString;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
project: string;
|
|
38
|
+
name: string;
|
|
39
|
+
}, {
|
|
40
|
+
project: string;
|
|
41
|
+
name: string;
|
|
42
|
+
}>;
|
|
43
|
+
spec: z.ZodType<TextVariableDefinition | ListVariableDefinition, z.ZodTypeDef, TextVariableDefinition | ListVariableDefinition>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
kind: "Variable";
|
|
46
|
+
spec: TextVariableDefinition | ListVariableDefinition;
|
|
47
|
+
metadata: {
|
|
48
|
+
project: string;
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
}, {
|
|
52
|
+
kind: "Variable";
|
|
53
|
+
spec: TextVariableDefinition | ListVariableDefinition;
|
|
54
|
+
metadata: {
|
|
55
|
+
project: string;
|
|
56
|
+
name: string;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
export declare const globalVariableSchema: z.ZodObject<{
|
|
60
|
+
kind: z.ZodLiteral<"GlobalVariable">;
|
|
61
|
+
metadata: z.ZodObject<{
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
project: z.ZodString;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
project: string;
|
|
66
|
+
name: string;
|
|
67
|
+
}, {
|
|
68
|
+
project: string;
|
|
69
|
+
name: string;
|
|
70
|
+
}>;
|
|
71
|
+
spec: z.ZodType<TextVariableDefinition | ListVariableDefinition, z.ZodTypeDef, TextVariableDefinition | ListVariableDefinition>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
kind: "GlobalVariable";
|
|
74
|
+
spec: TextVariableDefinition | ListVariableDefinition;
|
|
75
|
+
metadata: {
|
|
76
|
+
project: string;
|
|
77
|
+
name: string;
|
|
78
|
+
};
|
|
79
|
+
}, {
|
|
80
|
+
kind: "GlobalVariable";
|
|
81
|
+
spec: TextVariableDefinition | ListVariableDefinition;
|
|
82
|
+
metadata: {
|
|
83
|
+
project: string;
|
|
84
|
+
name: string;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
87
|
+
export declare const variablesSchema: z.ZodSchema<Variable>;
|
|
88
|
+
export declare const variableDefinitionSchema: z.ZodSchema<VariableDefinition>;
|
|
89
|
+
export declare function buildVariableDefinitionSchema(pluginSchema: PluginSchema): z.ZodSchema<VariableDefinition>;
|
|
90
|
+
//# sourceMappingURL=variable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/schema/variable.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAEtD,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,SAAS,CAAC,eAAe,CAI7D,CAAC;AAEH,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAoB/D,CAAC;AAEH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAsBrG;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAEH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,kBAAkB,CAK7F;AAED,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAK/D,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;EAG7B,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC,sBAAsB,GAAG,sBAAsB,CAG3F,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAEnG;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIzB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI/B,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAGhD,CAAC;AAEH,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAsB,CAAC;AAE5F,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAWzG"}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
import { z } from 'zod';
|
|
14
|
+
import { projectMetadataSchema } from './metadata';
|
|
15
|
+
import { pluginSchema } from './plugin';
|
|
16
|
+
export const variableDisplaySchema = z.object({
|
|
17
|
+
name: z.string().optional(),
|
|
18
|
+
description: z.string().optional(),
|
|
19
|
+
hidden: z.boolean().optional()
|
|
20
|
+
});
|
|
21
|
+
export const variableListSpecSchema = z.object({
|
|
22
|
+
name: z.string().min(1),
|
|
23
|
+
display: variableDisplaySchema.optional(),
|
|
24
|
+
defaultValue: z.string().or(z.array(z.string())).optional(),
|
|
25
|
+
allowAllValue: z.boolean(),
|
|
26
|
+
allowMultiple: z.boolean(),
|
|
27
|
+
customAllValue: z.string().optional(),
|
|
28
|
+
capturingRegexp: z.string().optional(),
|
|
29
|
+
sort: z.enum([
|
|
30
|
+
'none',
|
|
31
|
+
'alphabetical-asc',
|
|
32
|
+
'alphabetical-desc',
|
|
33
|
+
'numerical-asc',
|
|
34
|
+
'numerical-desc',
|
|
35
|
+
'alphabetical-ci-asc',
|
|
36
|
+
'alphabetical-ci-desc'
|
|
37
|
+
]).optional(),
|
|
38
|
+
plugin: pluginSchema
|
|
39
|
+
});
|
|
40
|
+
export function buildVariableListSpecSchema(pluginSchema) {
|
|
41
|
+
return z.object({
|
|
42
|
+
name: z.string().min(1),
|
|
43
|
+
display: variableDisplaySchema.optional(),
|
|
44
|
+
defaultValue: z.string().or(z.array(z.string())).optional(),
|
|
45
|
+
allowAllValue: z.boolean(),
|
|
46
|
+
allowMultiple: z.boolean(),
|
|
47
|
+
customAllValue: z.string().optional(),
|
|
48
|
+
capturingRegexp: z.string().optional(),
|
|
49
|
+
sort: z.enum([
|
|
50
|
+
'none',
|
|
51
|
+
'alphabetical-asc',
|
|
52
|
+
'alphabetical-desc',
|
|
53
|
+
'numerical-asc',
|
|
54
|
+
'numerical-desc',
|
|
55
|
+
'alphabetical-ci-asc',
|
|
56
|
+
'alphabetical-ci-desc'
|
|
57
|
+
]).optional(),
|
|
58
|
+
plugin: pluginSchema
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export const variableListSchema = z.object({
|
|
62
|
+
kind: z.literal('ListVariable'),
|
|
63
|
+
spec: variableListSpecSchema
|
|
64
|
+
});
|
|
65
|
+
export function buildVariableListSchema(pluginSchema) {
|
|
66
|
+
return z.object({
|
|
67
|
+
kind: z.literal('ListVariable'),
|
|
68
|
+
spec: buildVariableListSpecSchema(pluginSchema)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export const variableTextSpecSchema = z.object({
|
|
72
|
+
name: z.string().min(1),
|
|
73
|
+
display: variableDisplaySchema.optional(),
|
|
74
|
+
value: z.string().min(1),
|
|
75
|
+
constant: z.boolean().optional()
|
|
76
|
+
});
|
|
77
|
+
export const variableTextSchema = z.object({
|
|
78
|
+
kind: z.literal('TextVariable'),
|
|
79
|
+
spec: variableTextSpecSchema
|
|
80
|
+
});
|
|
81
|
+
export const variableSpecSchema = z.discriminatedUnion('kind', [
|
|
82
|
+
variableTextSchema,
|
|
83
|
+
variableListSchema
|
|
84
|
+
]);
|
|
85
|
+
export function buildVariableSpecSchema(pluginSchema) {
|
|
86
|
+
return z.union([
|
|
87
|
+
variableTextSchema,
|
|
88
|
+
buildVariableListSchema(pluginSchema)
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
export const variableSchema = z.object({
|
|
92
|
+
kind: z.literal('Variable'),
|
|
93
|
+
metadata: projectMetadataSchema,
|
|
94
|
+
spec: variableSpecSchema
|
|
95
|
+
});
|
|
96
|
+
export const globalVariableSchema = z.object({
|
|
97
|
+
kind: z.literal('GlobalVariable'),
|
|
98
|
+
metadata: projectMetadataSchema,
|
|
99
|
+
spec: variableSpecSchema
|
|
100
|
+
});
|
|
101
|
+
export const variablesSchema = z.discriminatedUnion('kind', [
|
|
102
|
+
variableSchema,
|
|
103
|
+
globalVariableSchema
|
|
104
|
+
]);
|
|
105
|
+
export const variableDefinitionSchema = variableSpecSchema;
|
|
106
|
+
export function buildVariableDefinitionSchema(pluginSchema) {
|
|
107
|
+
return z.discriminatedUnion('kind', [
|
|
108
|
+
z.object({
|
|
109
|
+
kind: z.literal('ListVariable'),
|
|
110
|
+
spec: buildVariableListSpecSchema(pluginSchema)
|
|
111
|
+
}),
|
|
112
|
+
z.object({
|
|
113
|
+
kind: z.literal('TextVariable'),
|
|
114
|
+
spec: variableTextSpecSchema
|
|
115
|
+
})
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/variable.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 {\n ListVariableDefinition,\n ListVariableSpec,\n TextVariableDefinition,\n TextVariableSpec,\n Variable,\n VariableDefinition,\n VariableDisplay,\n} from '../model';\nimport { projectMetadataSchema } from './metadata';\nimport { PluginSchema, pluginSchema } from './plugin';\n\nexport const variableDisplaySchema: z.ZodSchema<VariableDisplay> = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n hidden: z.boolean().optional(),\n});\n\nexport const variableListSpecSchema: z.ZodSchema<ListVariableSpec> = z.object({\n name: z.string().min(1),\n display: variableDisplaySchema.optional(),\n defaultValue: z.string().or(z.array(z.string())).optional(),\n allowAllValue: z.boolean(),\n allowMultiple: z.boolean(),\n customAllValue: z.string().optional(),\n capturingRegexp: z.string().optional(),\n sort: z\n .enum([\n 'none',\n 'alphabetical-asc',\n 'alphabetical-desc',\n 'numerical-asc',\n 'numerical-desc',\n 'alphabetical-ci-asc',\n 'alphabetical-ci-desc',\n ])\n .optional(),\n plugin: pluginSchema,\n});\n\nexport function buildVariableListSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<ListVariableSpec> {\n return z.object({\n name: z.string().min(1),\n display: variableDisplaySchema.optional(),\n defaultValue: z.string().or(z.array(z.string())).optional(),\n allowAllValue: z.boolean(),\n allowMultiple: z.boolean(),\n customAllValue: z.string().optional(),\n capturingRegexp: z.string().optional(),\n sort: z\n .enum([\n 'none',\n 'alphabetical-asc',\n 'alphabetical-desc',\n 'numerical-asc',\n 'numerical-desc',\n 'alphabetical-ci-asc',\n 'alphabetical-ci-desc',\n ])\n .optional(),\n plugin: pluginSchema,\n });\n}\n\nexport const variableListSchema = z.object({\n kind: z.literal('ListVariable'),\n spec: variableListSpecSchema,\n});\n\nexport function buildVariableListSchema(pluginSchema: PluginSchema): typeof variableListSchema {\n return z.object({\n kind: z.literal('ListVariable'),\n spec: buildVariableListSpecSchema(pluginSchema),\n });\n}\n\nexport const variableTextSpecSchema: z.ZodSchema<TextVariableSpec> = z.object({\n name: z.string().min(1),\n display: variableDisplaySchema.optional(),\n value: z.string().min(1),\n constant: z.boolean().optional(),\n});\n\nexport const variableTextSchema = z.object({\n kind: z.literal('TextVariable'),\n spec: variableTextSpecSchema,\n});\n\nexport const variableSpecSchema: z.ZodSchema<TextVariableDefinition | ListVariableDefinition> = z.discriminatedUnion(\n 'kind',\n [variableTextSchema, variableListSchema]\n);\n\nexport function buildVariableSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<VariableDefinition> {\n return z.union([variableTextSchema, buildVariableListSchema(pluginSchema)]);\n}\n\nexport const variableSchema = z.object({\n kind: z.literal('Variable'),\n metadata: projectMetadataSchema,\n spec: variableSpecSchema,\n});\n\nexport const globalVariableSchema = z.object({\n kind: z.literal('GlobalVariable'),\n metadata: projectMetadataSchema,\n spec: variableSpecSchema,\n});\n\nexport const variablesSchema: z.ZodSchema<Variable> = z.discriminatedUnion('kind', [\n variableSchema,\n globalVariableSchema,\n]);\n\nexport const variableDefinitionSchema: z.ZodSchema<VariableDefinition> = variableSpecSchema;\n\nexport function buildVariableDefinitionSchema(pluginSchema: PluginSchema): z.ZodSchema<VariableDefinition> {\n return z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('ListVariable'),\n spec: buildVariableListSpecSchema(pluginSchema),\n }),\n z.object({\n kind: z.literal('TextVariable'),\n spec: variableTextSpecSchema,\n }),\n ]);\n}\n"],"names":["z","projectMetadataSchema","pluginSchema","variableDisplaySchema","object","name","string","optional","description","hidden","boolean","variableListSpecSchema","min","display","defaultValue","or","array","allowAllValue","allowMultiple","customAllValue","capturingRegexp","sort","enum","plugin","buildVariableListSpecSchema","variableListSchema","kind","literal","spec","buildVariableListSchema","variableTextSpecSchema","value","constant","variableTextSchema","variableSpecSchema","discriminatedUnion","buildVariableSpecSchema","union","variableSchema","metadata","globalVariableSchema","variablesSchema","variableDefinitionSchema","buildVariableDefinitionSchema"],"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;AAUxB,SAASC,qBAAqB,QAAQ,aAAa;AACnD,SAAuBC,YAAY,QAAQ,WAAW;AAEtD,OAAO,MAAMC,wBAAsDH,EAAEI,MAAM,CAAC;IAC1EC,MAAML,EAAEM,MAAM,GAAGC,QAAQ;IACzBC,aAAaR,EAAEM,MAAM,GAAGC,QAAQ;IAChCE,QAAQT,EAAEU,OAAO,GAAGH,QAAQ;AAC9B,GAAG;AAEH,OAAO,MAAMI,yBAAwDX,EAAEI,MAAM,CAAC;IAC5EC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],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAsB,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAsB,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,qBAqBnE;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,cAI1E;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,MAAM,EAAE,MAAM,CAAC;gBACH,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAKzC;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAK5C"}
|
package/dist/utils/fetch.js
CHANGED
|
@@ -28,12 +28,19 @@
|
|
|
28
28
|
export async function fetch(...args) {
|
|
29
29
|
const response = await global.fetch(...args);
|
|
30
30
|
if (response.ok === false) {
|
|
31
|
-
const
|
|
32
|
-
if (json
|
|
33
|
-
|
|
31
|
+
const contentType = response.headers.get('content-type');
|
|
32
|
+
if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('application/json')) {
|
|
33
|
+
const json = await response.json();
|
|
34
|
+
if (json.error) {
|
|
35
|
+
throw new UserFriendlyError(json.error, response.status);
|
|
36
|
+
}
|
|
37
|
+
if (json.message) {
|
|
38
|
+
throw new UserFriendlyError(json.message, response.status);
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const text = await response.text();
|
|
42
|
+
if (text) {
|
|
43
|
+
throw new UserFriendlyError(text, response.status);
|
|
37
44
|
}
|
|
38
45
|
throw new FetchError(response);
|
|
39
46
|
}
|
package/dist/utils/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/fetch.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\n/**\n * Calls `global.fetch` and determines which type of error to show for non-200 responses.\n */\nexport async function fetch(...args: Parameters<typeof global.fetch>) {\n const response = await global.fetch(...args);\n if (response.ok === false) {\n const json = await response.json();\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/fetch.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\n/**\n * Calls `global.fetch` and determines which type of error to show for non-200 responses.\n */\nexport async function fetch(...args: Parameters<typeof global.fetch>) {\n const response = await global.fetch(...args);\n if (response.ok === false) {\n const contentType = response.headers.get('content-type');\n if (contentType?.includes('application/json')) {\n const json = await response.json();\n if (json.error) {\n throw new UserFriendlyError(json.error, response.status);\n }\n if (json.message) {\n throw new UserFriendlyError(json.message, response.status);\n }\n }\n\n const text = await response.text();\n if (text) {\n throw new UserFriendlyError(text, response.status);\n }\n throw new FetchError(response);\n }\n return response;\n}\n\n/**\n * Calls `global.fetch` and throws a `FetchError` on non-200 responses, but also\n * decodes the response body as JSON, casting it to type `T`. Returns the\n * decoded body.\n */\nexport async function fetchJson<T>(...args: Parameters<typeof global.fetch>) {\n const response = await fetch(...args);\n const json: T = await response.json();\n return json;\n}\n\n/**\n * Error thrown when fetch returns a non-200 response.\n */\nexport class FetchError extends Error {\n status: number;\n constructor(response: Readonly<Response>) {\n super(`${response.status} ${response.statusText}`);\n this.status = response.status;\n Object.setPrototypeOf(this, FetchError.prototype);\n }\n}\n\n/**\n * General error type for an error that has a message that is OK to show to the end user.\n */\nexport class UserFriendlyError extends Error {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n Object.setPrototypeOf(this, UserFriendlyError.prototype);\n }\n}\n"],"names":["fetch","args","response","global","ok","contentType","headers","get","includes","json","error","UserFriendlyError","status","message","text","FetchError","fetchJson","Error","constructor","statusText","Object","setPrototypeOf","prototype"],"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;;CAEC;;;;;;;;;;;;;AACD,OAAO,eAAeA,MAAM,GAAGC,IAAqC;IAClE,MAAMC,WAAW,MAAMC,OAAOH,KAAK,IAAIC;IACvC,IAAIC,SAASE,EAAE,KAAK,OAAO;QACzB,MAAMC,cAAcH,SAASI,OAAO,CAACC,GAAG,CAAC;QACzC,IAAIF,wBAAAA,kCAAAA,YAAaG,QAAQ,CAAC,qBAAqB;YAC7C,MAAMC,OAAO,MAAMP,SAASO,IAAI;YAChC,IAAIA,KAAKC,KAAK,EAAE;gBACd,MAAM,IAAIC,kBAAkBF,KAAKC,KAAK,EAAER,SAASU,MAAM;YACzD;YACA,IAAIH,KAAKI,OAAO,EAAE;gBAChB,MAAM,IAAIF,kBAAkBF,KAAKI,OAAO,EAAEX,SAASU,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