@zenstackhq/server 1.0.0-alpha.99 → 1.0.0-beta.10
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/api/base.d.ts +8 -0
- package/api/base.js +19 -0
- package/api/base.js.map +1 -0
- package/api/rest/index.d.ts +19 -0
- package/api/rest/index.js +1313 -0
- package/api/rest/index.js.map +1 -0
- package/api/rpc/index.d.ts +2 -0
- package/api/rpc/index.js +263 -0
- package/api/rpc/index.js.map +1 -0
- package/api/utils.d.ts +12 -0
- package/api/utils.js +79 -0
- package/api/utils.js.map +1 -0
- package/express/index.d.ts +1 -0
- package/express/index.js +15 -0
- package/express/index.js.map +1 -1
- package/express/middleware.d.ts +10 -10
- package/express/middleware.js +55 -17
- package/express/middleware.js.map +1 -1
- package/fastify/index.d.ts +1 -0
- package/fastify/index.js +15 -0
- package/fastify/index.js.map +1 -1
- package/fastify/plugin.d.ts +4 -13
- package/fastify/plugin.js +32 -24
- package/fastify/plugin.js.map +1 -1
- package/next/app-route-handler.d.ts +15 -0
- package/next/app-route-handler.js +80 -0
- package/next/app-route-handler.js.map +1 -0
- package/next/index.d.ts +38 -0
- package/next/index.js +18 -0
- package/next/index.js.map +1 -0
- package/next/pages-route-handler.d.ts +9 -0
- package/next/pages-route-handler.js +68 -0
- package/next/pages-route-handler.js.map +1 -0
- package/package.json +18 -9
- package/sveltekit/handler.d.ts +19 -0
- package/sveltekit/handler.js +87 -0
- package/sveltekit/handler.js.map +1 -0
- package/sveltekit/index.d.ts +2 -0
- package/sveltekit/index.js +24 -0
- package/sveltekit/index.js.map +1 -0
- package/types.d.ts +96 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/openapi/index.d.ts +0 -46
- package/openapi/index.js +0 -193
- package/openapi/index.js.map +0 -1
- package/openapi/utils.d.ts +0 -4
- package/openapi/utils.js +0 -25
- package/openapi/utils.js.map +0 -1
package/types.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ModelMeta, ZodSchemas } from '@zenstackhq/runtime';
|
|
2
|
+
import { DbClientContract } from '@zenstackhq/runtime';
|
|
3
|
+
type LoggerMethod = (message: string, code?: string) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Logger config.
|
|
6
|
+
*/
|
|
7
|
+
export type LoggerConfig = {
|
|
8
|
+
debug?: LoggerMethod;
|
|
9
|
+
info?: LoggerMethod;
|
|
10
|
+
warn?: LoggerMethod;
|
|
11
|
+
error?: LoggerMethod;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* API request context
|
|
15
|
+
*/
|
|
16
|
+
export type RequestContext = {
|
|
17
|
+
/**
|
|
18
|
+
* The PrismaClient instance
|
|
19
|
+
*/
|
|
20
|
+
prisma: DbClientContract;
|
|
21
|
+
/**
|
|
22
|
+
* The HTTP method
|
|
23
|
+
*/
|
|
24
|
+
method: string;
|
|
25
|
+
/**
|
|
26
|
+
* The request endpoint path (excluding any prefix)
|
|
27
|
+
*/
|
|
28
|
+
path: string;
|
|
29
|
+
/**
|
|
30
|
+
* The query parameters
|
|
31
|
+
*/
|
|
32
|
+
query?: Record<string, string | string[]>;
|
|
33
|
+
/**
|
|
34
|
+
* The request body object
|
|
35
|
+
*/
|
|
36
|
+
requestBody?: unknown;
|
|
37
|
+
/**
|
|
38
|
+
* Model metadata. By default loaded from the standard output location
|
|
39
|
+
* of the `@zenstackhq/model-meta` plugin. You can pass it in explicitly
|
|
40
|
+
* if you configured the plugin to output to a different location.
|
|
41
|
+
*/
|
|
42
|
+
modelMeta?: ModelMeta;
|
|
43
|
+
/**
|
|
44
|
+
* Zod schemas for validating create and update payloads. By default
|
|
45
|
+
* loaded from the standard output location of the `@zenstackhq/zod`
|
|
46
|
+
* plugin. You can pass it in explicitly if you configured the plugin
|
|
47
|
+
* to output to a different location.
|
|
48
|
+
*/
|
|
49
|
+
zodSchemas?: ZodSchemas;
|
|
50
|
+
/**
|
|
51
|
+
* Logging configuration. Set to `null` to disable logging.
|
|
52
|
+
* If unset or set to `undefined`, log will be output to console.
|
|
53
|
+
*/
|
|
54
|
+
logger?: LoggerConfig;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* API response
|
|
58
|
+
*/
|
|
59
|
+
export type Response = {
|
|
60
|
+
status: number;
|
|
61
|
+
body: unknown;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* API request handler function
|
|
65
|
+
*/
|
|
66
|
+
export type HandleRequestFn = (req: RequestContext) => Promise<Response>;
|
|
67
|
+
/**
|
|
68
|
+
* Base type for options used to create a server adapter.
|
|
69
|
+
*/
|
|
70
|
+
export interface AdapterBaseOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Logger settings
|
|
73
|
+
*/
|
|
74
|
+
logger?: LoggerConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Model metadata. By default loaded from the standard output location
|
|
77
|
+
* of the `@zenstackhq/model-meta` plugin. You can pass it in explicitly
|
|
78
|
+
* if you configured the plugin to output to a different location.
|
|
79
|
+
*/
|
|
80
|
+
modelMeta?: ModelMeta;
|
|
81
|
+
/**
|
|
82
|
+
* Zod schemas for validating request input. Pass `true` to load from standard location
|
|
83
|
+
* (need to enable `@core/zod` plugin in schema.zmodel) or omit to disable input validation.
|
|
84
|
+
*/
|
|
85
|
+
zodSchemas?: ZodSchemas | boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Api request handler function. Can be created using `@zenstackhq/server/api/rest` or `@zenstackhq/server/api/rpc` factory functions.
|
|
88
|
+
* Defaults to RPC-style API handler created with `/api/rpc`.
|
|
89
|
+
*/
|
|
90
|
+
handler?: HandleRequestFn;
|
|
91
|
+
/**
|
|
92
|
+
* Whether to use superjson for serialization/deserialization. Defaults to `false`.
|
|
93
|
+
*/
|
|
94
|
+
useSuperJson?: boolean;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/openapi/index.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { DbClientContract } from '@zenstackhq/runtime';
|
|
2
|
-
import type { ModelZodSchema } from '@zenstackhq/runtime/zod';
|
|
3
|
-
type LoggerMethod = (message: string, code?: string) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Logger config.
|
|
6
|
-
*/
|
|
7
|
-
export type LoggerConfig = {
|
|
8
|
-
debug?: LoggerMethod;
|
|
9
|
-
info?: LoggerMethod;
|
|
10
|
-
warn?: LoggerMethod;
|
|
11
|
-
error?: LoggerMethod;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Options for initializing a Next.js API endpoint request handler.
|
|
15
|
-
* @see requestHandler
|
|
16
|
-
*/
|
|
17
|
-
export type RequestHandlerOptions = {
|
|
18
|
-
/**
|
|
19
|
-
* Logger configuration. By default log to console. Set to null to turn off logging.
|
|
20
|
-
*/
|
|
21
|
-
logger?: LoggerConfig | null;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* OpenApi request context.
|
|
25
|
-
*/
|
|
26
|
-
export type RequestContext = {
|
|
27
|
-
method: string;
|
|
28
|
-
path: string;
|
|
29
|
-
query?: Record<string, string | string[]>;
|
|
30
|
-
requestBody?: unknown;
|
|
31
|
-
prisma: DbClientContract;
|
|
32
|
-
logger?: LoggerConfig;
|
|
33
|
-
zodSchemas?: ModelZodSchema;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* OpenApi response.
|
|
37
|
-
*/
|
|
38
|
-
export type Response = {
|
|
39
|
-
status: number;
|
|
40
|
-
body: unknown;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Handles OpenApi requests
|
|
44
|
-
*/
|
|
45
|
-
export declare function handleRequest({ method, path, query, requestBody, prisma, logger, zodSchemas, }: RequestContext): Promise<Response>;
|
|
46
|
-
export {};
|
package/openapi/index.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.handleRequest = void 0;
|
|
13
|
-
const runtime_1 = require("@zenstackhq/runtime");
|
|
14
|
-
const change_case_1 = require("change-case");
|
|
15
|
-
const zod_validation_error_1 = require("zod-validation-error");
|
|
16
|
-
const utils_1 = require("./utils");
|
|
17
|
-
function getZodSchema(zodSchemas, model, operation) {
|
|
18
|
-
if (zodSchemas[model]) {
|
|
19
|
-
return zodSchemas[model][operation];
|
|
20
|
-
}
|
|
21
|
-
else if (zodSchemas[(0, change_case_1.pascalCase)(model)]) {
|
|
22
|
-
return zodSchemas[(0, change_case_1.pascalCase)(model)][operation];
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function zodValidate(zodSchemas, model, operation, args) {
|
|
29
|
-
const zodSchema = zodSchemas && getZodSchema(zodSchemas, model, operation);
|
|
30
|
-
if (zodSchema) {
|
|
31
|
-
const parseResult = zodSchema.safeParse(args);
|
|
32
|
-
if (parseResult.success) {
|
|
33
|
-
return { data: parseResult.data, error: undefined };
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return { data: undefined, error: (0, zod_validation_error_1.fromZodError)(parseResult.error).message };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return { data: args, error: undefined };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Handles OpenApi requests
|
|
45
|
-
*/
|
|
46
|
-
function handleRequest({ method, path, query, requestBody, prisma, logger, zodSchemas, }) {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const parts = path.split('/').filter((p) => !!p);
|
|
50
|
-
const op = parts.pop();
|
|
51
|
-
const model = parts.pop();
|
|
52
|
-
if (parts.length !== 0 || !op || !model) {
|
|
53
|
-
return { status: 400, body: { message: 'invalid request path' } };
|
|
54
|
-
}
|
|
55
|
-
method = method.toUpperCase();
|
|
56
|
-
const dbOp = op;
|
|
57
|
-
let args;
|
|
58
|
-
let resCode = 200;
|
|
59
|
-
switch (dbOp) {
|
|
60
|
-
case 'create':
|
|
61
|
-
case 'createMany':
|
|
62
|
-
case 'upsert':
|
|
63
|
-
if (method !== 'POST') {
|
|
64
|
-
return { status: 400, body: { message: 'invalid request method, only POST is supported' } };
|
|
65
|
-
}
|
|
66
|
-
if (!requestBody) {
|
|
67
|
-
return { status: 400, body: { message: 'missing request body' } };
|
|
68
|
-
}
|
|
69
|
-
args = requestBody;
|
|
70
|
-
// TODO: upsert's status code should be conditional
|
|
71
|
-
resCode = 201;
|
|
72
|
-
break;
|
|
73
|
-
case 'findFirst':
|
|
74
|
-
case 'findUnique':
|
|
75
|
-
case 'findMany':
|
|
76
|
-
case 'aggregate':
|
|
77
|
-
case 'groupBy':
|
|
78
|
-
case 'count':
|
|
79
|
-
if (method !== 'GET') {
|
|
80
|
-
return { status: 400, body: { message: 'invalid request method, only GET is supported' } };
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
args = (query === null || query === void 0 ? void 0 : query.q) ? unmarshal(query.q) : {};
|
|
84
|
-
}
|
|
85
|
-
catch (_c) {
|
|
86
|
-
return { status: 400, body: { message: 'query param must contain valid JSON' } };
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
case 'update':
|
|
90
|
-
case 'updateMany':
|
|
91
|
-
if (method !== 'PUT' && method !== 'PATCH') {
|
|
92
|
-
return { status: 400, body: { message: 'invalid request method, only PUT AND PATCH are supported' } };
|
|
93
|
-
}
|
|
94
|
-
if (!requestBody) {
|
|
95
|
-
return { status: 400, body: { message: 'missing request body' } };
|
|
96
|
-
}
|
|
97
|
-
args = requestBody;
|
|
98
|
-
break;
|
|
99
|
-
case 'delete':
|
|
100
|
-
case 'deleteMany':
|
|
101
|
-
if (method !== 'DELETE') {
|
|
102
|
-
return { status: 400, body: { message: 'invalid request method, only DELETE is supported' } };
|
|
103
|
-
}
|
|
104
|
-
try {
|
|
105
|
-
args = (query === null || query === void 0 ? void 0 : query.q) ? unmarshal(query.q) : {};
|
|
106
|
-
}
|
|
107
|
-
catch (_d) {
|
|
108
|
-
return { status: 400, body: { message: 'query param must contain valid JSON' } };
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
default:
|
|
112
|
-
return { status: 400, body: { message: 'invalid operation: ' + op } };
|
|
113
|
-
}
|
|
114
|
-
if (zodSchemas) {
|
|
115
|
-
const { data, error } = zodValidate(zodSchemas, model, dbOp, args);
|
|
116
|
-
if (error) {
|
|
117
|
-
return { status: 400, body: { message: error } };
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
args = data;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
if (!prisma[model]) {
|
|
125
|
-
return { status: 400, body: { message: `unknown model name: ${model}` } };
|
|
126
|
-
}
|
|
127
|
-
const result = yield prisma[model][dbOp](args);
|
|
128
|
-
(0, utils_1.stripAuxFields)(result);
|
|
129
|
-
return { status: resCode, body: result };
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
if ((0, runtime_1.isPrismaClientKnownRequestError)(err)) {
|
|
133
|
-
logError(logger, err.code, err.message);
|
|
134
|
-
if (err.code === 'P2004') {
|
|
135
|
-
// rejected by policy
|
|
136
|
-
return {
|
|
137
|
-
status: 403,
|
|
138
|
-
body: {
|
|
139
|
-
prisma: true,
|
|
140
|
-
rejectedByPolicy: true,
|
|
141
|
-
code: err.code,
|
|
142
|
-
message: err.message,
|
|
143
|
-
reason: (_a = err.meta) === null || _a === void 0 ? void 0 : _a.reason,
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
return {
|
|
149
|
-
status: 400,
|
|
150
|
-
body: {
|
|
151
|
-
prisma: true,
|
|
152
|
-
code: err.code,
|
|
153
|
-
message: err.message,
|
|
154
|
-
reason: (_b = err.meta) === null || _b === void 0 ? void 0 : _b.reason,
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
else if ((0, runtime_1.isPrismaClientUnknownRequestError)(err) || (0, runtime_1.isPrismaClientValidationError)(err)) {
|
|
160
|
-
logError(logger, err.message);
|
|
161
|
-
return {
|
|
162
|
-
status: 400,
|
|
163
|
-
body: {
|
|
164
|
-
prisma: true,
|
|
165
|
-
message: err.message,
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
logError(logger, err.message);
|
|
171
|
-
return {
|
|
172
|
-
status: 400,
|
|
173
|
-
body: {
|
|
174
|
-
message: err.message,
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
exports.handleRequest = handleRequest;
|
|
182
|
-
function unmarshal(value) {
|
|
183
|
-
return JSON.parse(value);
|
|
184
|
-
}
|
|
185
|
-
function logError(logger, message, code) {
|
|
186
|
-
if (logger === undefined) {
|
|
187
|
-
console.error(`@zenstackhq/openapi: error ${code ? '[' + code + ']' : ''}, ${message}`);
|
|
188
|
-
}
|
|
189
|
-
else if (logger === null || logger === void 0 ? void 0 : logger.error) {
|
|
190
|
-
logger.error(message, code);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=index.js.map
|
package/openapi/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openapi/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAM6B;AAE7B,6CAAyC;AACzC,+DAAoD;AACpD,mCAAyC;AA8CzC,SAAS,YAAY,CAAC,UAA0B,EAAE,KAAa,EAAE,SAA6B;IAC1F,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;KACvC;SAAM,IAAI,UAAU,CAAC,IAAA,wBAAU,EAAC,KAAK,CAAC,CAAC,EAAE;QACtC,OAAO,UAAU,CAAC,IAAA,wBAAU,EAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;KACnD;SAAM;QACH,OAAO,SAAS,CAAC;KACpB;AACL,CAAC;AAED,SAAS,WAAW,CAChB,UAAsC,EACtC,KAAa,EACb,SAA6B,EAC7B,IAAa;IAEb,MAAM,SAAS,GAAG,UAAU,IAAI,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAC3E,IAAI,SAAS,EAAE;QACX,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,WAAW,CAAC,OAAO,EAAE;YACrB,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;SACvD;aAAM;YACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAA,mCAAY,EAAC,WAAW,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;SAC9E;KACJ;SAAM;QACH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OAAe,EAAE,IAAa;IACrF,IAAI,MAAM,KAAK,SAAS,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,8BAA8B,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC,CAAC;KAC3F;SAAM,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,EAAE;QACtB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;KAC/B;AACL,CAAC"}
|
package/openapi/utils.d.ts
DELETED
package/openapi/utils.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stripAuxFields = void 0;
|
|
4
|
-
const sdk_1 = require("@zenstackhq/sdk");
|
|
5
|
-
/**
|
|
6
|
-
* Recursively strip auxiliary fields from the given data.
|
|
7
|
-
*/
|
|
8
|
-
function stripAuxFields(data) {
|
|
9
|
-
if (Array.isArray(data)) {
|
|
10
|
-
return data.forEach(stripAuxFields);
|
|
11
|
-
}
|
|
12
|
-
else if (data && typeof data === 'object') {
|
|
13
|
-
for (const [key, value] of Object.entries(data)) {
|
|
14
|
-
if (sdk_1.AUXILIARY_FIELDS.includes(key)) {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
delete data[key];
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
stripAuxFields(value);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.stripAuxFields = stripAuxFields;
|
|
25
|
-
//# sourceMappingURL=utils.js.map
|
package/openapi/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/openapi/utils.ts"],"names":[],"mappings":";;;AAAA,yCAAmD;AAEnD;;GAEG;AACH,SAAgB,cAAc,CAAC,IAAa;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;KACvC;SAAM,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC7C,IAAI,sBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAChC,8DAA8D;gBAC9D,OAAQ,IAAY,CAAC,GAAG,CAAC,CAAC;aAC7B;iBAAM;gBACH,cAAc,CAAC,KAAK,CAAC,CAAC;aACzB;SACJ;KACJ;AACL,CAAC;AAbD,wCAaC"}
|