@tailor-platform/sdk 1.56.0 → 1.57.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.
- package/CHANGELOG.md +20 -0
- package/README.md +0 -23
- package/dist/{application-YHZIkjdy.mjs → application-CdkoGX27.mjs} +37 -4
- package/dist/application-CdkoGX27.mjs.map +1 -0
- package/dist/application-x_mURdR0.mjs +4 -0
- package/dist/cli/erd-viewer-assets/app.js +1181 -0
- package/dist/cli/erd-viewer-assets/index.html +73 -0
- package/dist/cli/erd-viewer-assets/serve.json +13 -0
- package/dist/cli/erd-viewer-assets/styles.css +789 -0
- package/dist/cli/index.mjs +686 -345
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +7 -2
- package/dist/cli/lib.mjs +2 -2
- package/dist/client-DLPEPJ_s.mjs.map +1 -1
- package/dist/configure/index.d.mts +2 -2
- package/dist/configure/index.mjs +1 -1
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-BW3v5XYC.d.mts → index-B61gFI9a.d.mts} +7 -2
- package/dist/{runtime-B8F1nklz.mjs → runtime-1YuaoNr8.mjs} +57 -63
- package/dist/runtime-1YuaoNr8.mjs.map +1 -0
- package/dist/{types-BinLwXM9.mjs → types-BwGth3a1.mjs} +57 -28
- package/dist/types-BwGth3a1.mjs.map +1 -0
- package/dist/{types-UeXbHFXW.mjs → types-Ccwchyj5.mjs} +1 -1
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/{workflow.generated-BHdBzgx6.d.mts → workflow.generated-Kz-nQrTf.d.mts} +10 -1
- package/docs/cli/tailordb.md +31 -26
- package/docs/cli-reference.md +2 -2
- package/package.json +1 -3
- package/dist/application-C9-t0qQb.mjs +0 -4
- package/dist/application-YHZIkjdy.mjs.map +0 -1
- package/dist/runtime-B8F1nklz.mjs.map +0 -1
- package/dist/types-BinLwXM9.mjs.map +0 -1
|
@@ -15,15 +15,24 @@ const regex = {
|
|
|
15
15
|
* @param options - Field options
|
|
16
16
|
* @param fields - Nested fields for object-like types
|
|
17
17
|
* @param values - Allowed values for enum-like fields
|
|
18
|
+
* @param metadata - Pre-built metadata to clone from (used by `clone()`); when
|
|
19
|
+
* given, the mutable containers are deep-copied here and `options`/`values` are
|
|
20
|
+
* ignored for metadata construction
|
|
18
21
|
* @returns A new TailorField
|
|
19
22
|
*/
|
|
20
|
-
function createTailorField(type, options, fields, values) {
|
|
21
|
-
const _metadata =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
function createTailorField(type, options, fields, values, metadata) {
|
|
24
|
+
const _metadata = metadata ? {
|
|
25
|
+
...metadata,
|
|
26
|
+
...metadata.allowedValues && { allowedValues: metadata.allowedValues.map((v) => ({ ...v })) },
|
|
27
|
+
...metadata.validate && { validate: metadata.validate.map((v) => Array.isArray(v) ? [...v] : v) }
|
|
28
|
+
} : { required: true };
|
|
29
|
+
if (!metadata) {
|
|
30
|
+
if (options) {
|
|
31
|
+
if (options.optional === true) _metadata.required = false;
|
|
32
|
+
if (options.array === true) _metadata.array = true;
|
|
33
|
+
}
|
|
34
|
+
if (values) _metadata.allowedValues = mapAllowedValues(values);
|
|
25
35
|
}
|
|
26
|
-
if (values) _metadata.allowedValues = mapAllowedValues(values);
|
|
27
36
|
/**
|
|
28
37
|
* Validate a single value (not an array element)
|
|
29
38
|
* Used internally for array element validation
|
|
@@ -33,59 +42,60 @@ function createTailorField(type, options, fields, values) {
|
|
|
33
42
|
function validateValue(args) {
|
|
34
43
|
const { value, data, user, pathArray } = args;
|
|
35
44
|
const issues = [];
|
|
45
|
+
const path = pathArray.length > 0 ? pathArray : void 0;
|
|
36
46
|
switch (type) {
|
|
37
47
|
case "string":
|
|
38
48
|
if (typeof value !== "string") issues.push({
|
|
39
49
|
message: `Expected a string: received ${String(value)}`,
|
|
40
|
-
path
|
|
50
|
+
path
|
|
41
51
|
});
|
|
42
52
|
break;
|
|
43
53
|
case "integer":
|
|
44
54
|
if (typeof value !== "number" || !Number.isInteger(value)) issues.push({
|
|
45
55
|
message: `Expected an integer: received ${String(value)}`,
|
|
46
|
-
path
|
|
56
|
+
path
|
|
47
57
|
});
|
|
48
58
|
break;
|
|
49
59
|
case "float":
|
|
50
60
|
if (typeof value !== "number" || !Number.isFinite(value)) issues.push({
|
|
51
61
|
message: `Expected a number: received ${String(value)}`,
|
|
52
|
-
path
|
|
62
|
+
path
|
|
53
63
|
});
|
|
54
64
|
break;
|
|
55
65
|
case "boolean":
|
|
56
66
|
if (typeof value !== "boolean") issues.push({
|
|
57
67
|
message: `Expected a boolean: received ${String(value)}`,
|
|
58
|
-
path
|
|
68
|
+
path
|
|
59
69
|
});
|
|
60
70
|
break;
|
|
61
71
|
case "uuid":
|
|
62
72
|
if (typeof value !== "string" || !regex.uuid.test(value)) issues.push({
|
|
63
73
|
message: `Expected a valid UUID: received ${String(value)}`,
|
|
64
|
-
path
|
|
74
|
+
path
|
|
65
75
|
});
|
|
66
76
|
break;
|
|
67
77
|
case "date":
|
|
68
78
|
if (typeof value !== "string" || !regex.date.test(value)) issues.push({
|
|
69
79
|
message: `Expected to match "yyyy-MM-dd" format: received ${String(value)}`,
|
|
70
|
-
path
|
|
80
|
+
path
|
|
71
81
|
});
|
|
72
82
|
break;
|
|
73
83
|
case "datetime":
|
|
74
84
|
if (typeof value !== "string" || !regex.datetime.test(value)) issues.push({
|
|
75
85
|
message: `Expected to match ISO format: received ${String(value)}`,
|
|
76
|
-
path
|
|
86
|
+
path
|
|
77
87
|
});
|
|
78
88
|
break;
|
|
79
89
|
case "time":
|
|
80
90
|
if (typeof value !== "string" || !regex.time.test(value)) issues.push({
|
|
81
91
|
message: `Expected to match "HH:mm" format: received ${String(value)}`,
|
|
82
|
-
path
|
|
92
|
+
path
|
|
83
93
|
});
|
|
84
94
|
break;
|
|
85
95
|
case "decimal":
|
|
86
96
|
if (typeof value !== "string" || !regex.decimal.test(value)) issues.push({
|
|
87
97
|
message: `Expected a decimal string: received ${String(value)}`,
|
|
88
|
-
path
|
|
98
|
+
path
|
|
89
99
|
});
|
|
90
100
|
break;
|
|
91
101
|
case "enum":
|
|
@@ -93,14 +103,14 @@ function createTailorField(type, options, fields, values) {
|
|
|
93
103
|
const allowedValues = field._metadata.allowedValues.map((v) => v.value);
|
|
94
104
|
if (typeof value !== "string" || !allowedValues.includes(value)) issues.push({
|
|
95
105
|
message: `Must be one of [${allowedValues.join(", ")}]: received ${String(value)}`,
|
|
96
|
-
path
|
|
106
|
+
path
|
|
97
107
|
});
|
|
98
108
|
}
|
|
99
109
|
break;
|
|
100
110
|
case "nested":
|
|
101
111
|
if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Date) issues.push({
|
|
102
112
|
message: `Expected an object: received ${String(value)}`,
|
|
103
|
-
path
|
|
113
|
+
path
|
|
104
114
|
});
|
|
105
115
|
else if (field.fields && Object.keys(field.fields).length > 0) for (const [fieldName, nestedField] of Object.entries(field.fields)) {
|
|
106
116
|
const fieldValue = value?.[fieldName];
|
|
@@ -129,7 +139,7 @@ function createTailorField(type, options, fields, values) {
|
|
|
129
139
|
user
|
|
130
140
|
})) issues.push({
|
|
131
141
|
message,
|
|
132
|
-
path
|
|
142
|
+
path
|
|
133
143
|
});
|
|
134
144
|
}
|
|
135
145
|
return issues;
|
|
@@ -142,11 +152,12 @@ function createTailorField(type, options, fields, values) {
|
|
|
142
152
|
function parseInternal(args) {
|
|
143
153
|
const { value, data, user, pathArray } = args;
|
|
144
154
|
const issues = [];
|
|
155
|
+
const path = pathArray.length > 0 ? pathArray : void 0;
|
|
145
156
|
const isNullOrUndefined = value === null || value === void 0;
|
|
146
157
|
if (field._metadata.required && isNullOrUndefined) {
|
|
147
158
|
issues.push({
|
|
148
159
|
message: "Required field is missing",
|
|
149
|
-
path
|
|
160
|
+
path
|
|
150
161
|
});
|
|
151
162
|
return { issues };
|
|
152
163
|
}
|
|
@@ -155,7 +166,7 @@ function createTailorField(type, options, fields, values) {
|
|
|
155
166
|
if (!Array.isArray(value)) {
|
|
156
167
|
issues.push({
|
|
157
168
|
message: "Expected an array",
|
|
158
|
-
path
|
|
169
|
+
path
|
|
159
170
|
});
|
|
160
171
|
return { issues };
|
|
161
172
|
}
|
|
@@ -182,6 +193,18 @@ function createTailorField(type, options, fields, values) {
|
|
|
182
193
|
if (issues.length > 0) return { issues };
|
|
183
194
|
return { value };
|
|
184
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Clone the field and apply metadata updates to the clone.
|
|
198
|
+
* The original instance is never mutated, so a field shared across places
|
|
199
|
+
* cannot leak metadata between them.
|
|
200
|
+
* @param metadataUpdates - Metadata properties to overwrite on the clone
|
|
201
|
+
* @returns A new field with the updated metadata
|
|
202
|
+
*/
|
|
203
|
+
function cloneWith(metadataUpdates) {
|
|
204
|
+
const cloned = field.clone();
|
|
205
|
+
Object.assign(cloned._metadata, metadataUpdates);
|
|
206
|
+
return cloned;
|
|
207
|
+
}
|
|
185
208
|
const field = {
|
|
186
209
|
type,
|
|
187
210
|
fields: fields ?? {},
|
|
@@ -192,16 +215,13 @@ function createTailorField(type, options, fields, values) {
|
|
|
192
215
|
return { ...this._metadata };
|
|
193
216
|
},
|
|
194
217
|
description(description) {
|
|
195
|
-
|
|
196
|
-
return this;
|
|
218
|
+
return cloneWith({ description });
|
|
197
219
|
},
|
|
198
220
|
typeName(typeName) {
|
|
199
|
-
|
|
200
|
-
return this;
|
|
221
|
+
return cloneWith({ typeName });
|
|
201
222
|
},
|
|
202
223
|
validate(...validateInputs) {
|
|
203
|
-
|
|
204
|
-
return this;
|
|
224
|
+
return cloneWith({ validate: validateInputs });
|
|
205
225
|
},
|
|
206
226
|
parse(args) {
|
|
207
227
|
return parseInternal({
|
|
@@ -211,7 +231,16 @@ function createTailorField(type, options, fields, values) {
|
|
|
211
231
|
pathArray: []
|
|
212
232
|
});
|
|
213
233
|
},
|
|
214
|
-
_parseInternal: parseInternal
|
|
234
|
+
_parseInternal: parseInternal,
|
|
235
|
+
clone() {
|
|
236
|
+
let clonedFields = fields;
|
|
237
|
+
if (fields) {
|
|
238
|
+
const cloned = {};
|
|
239
|
+
for (const [key, nestedField] of Object.entries(fields)) cloned[key] = nestedField.clone();
|
|
240
|
+
clonedFields = cloned;
|
|
241
|
+
}
|
|
242
|
+
return createTailorField(type, options, clonedFields, values, this._metadata);
|
|
243
|
+
}
|
|
215
244
|
};
|
|
216
245
|
return field;
|
|
217
246
|
}
|
|
@@ -340,4 +369,4 @@ const t = {
|
|
|
340
369
|
|
|
341
370
|
//#endregion
|
|
342
371
|
export { t };
|
|
343
|
-
//# sourceMappingURL=types-
|
|
372
|
+
//# sourceMappingURL=types-BwGth3a1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BwGth3a1.mjs","names":[],"sources":["../src/configure/types/type.ts"],"sourcesContent":["import { type AllowedValues, type AllowedValuesOutput, mapAllowedValues } from \"./field\";\nimport type {\n DefinedFieldMetadata,\n TailorFieldType,\n TailorToTs,\n FieldMetadata,\n FieldOptions,\n FieldOutput,\n} from \"@/types/field-types\";\nimport type { InferFieldsOutput, Prettify } from \"@/types/helpers\";\nimport type { TailorField as TailorFieldBase } from \"@/types/tailor-field\";\nimport type { TailorUser } from \"@/types/user\";\nimport type { FieldValidateInput } from \"@/types/validation\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n// This helper type intentionally uses `any` as a placeholder for unknown field output.\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyField = TailorField<any>;\n\n/**\n * Full TailorField interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorField<\n Defined extends DefinedFieldMetadata = DefinedFieldMetadata,\n // Generic default output type (kept loose on purpose for library ergonomics).\n // oxlint-disable-next-line no-explicit-any\n Output = any,\n M extends FieldMetadata = FieldMetadata,\n T extends TailorFieldType = TailorFieldType,\n> extends TailorFieldBase<Defined, Output, M, T> {\n readonly fields: Record<string, TailorAnyField>;\n _metadata: M;\n\n /**\n * Set a description for the field\n * @param description - The description text\n * @returns The field with updated metadata\n */\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorField<Prettify<CurrentDefined & { description: true }>, Output>;\n\n /**\n * Set a custom type name for enum or nested types\n * @param typeName - The custom type name\n * @returns The field with updated metadata\n */\n typeName<CurrentDefined extends Defined>(\n this: CurrentDefined extends { typeName: unknown }\n ? never\n : CurrentDefined extends { type: \"enum\" | \"nested\" }\n ? TailorField<CurrentDefined, Output>\n : never,\n typeName: string,\n ): TailorField<Prettify<CurrentDefined & { typeName: true }>, Output>;\n\n /**\n * Add validation functions to the field\n * @param validate - One or more validation functions\n * @returns The field with updated metadata\n */\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ): TailorField<Prettify<CurrentDefined & { validate: true }>, Output>;\n\n /**\n * Parse and validate a value against this field's validation rules\n * Returns StandardSchema Result type with success or failure\n * @param args - Value, context data, and user\n * @returns Validation result\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n * @param args - Parse arguments\n * @returns Validation result\n */\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n}\n\n/**\n * Internal shape carried by every runtime field for clone-on-write support.\n *\n * `clone()` is intentionally kept off the public {@link TailorField} interface:\n * adding it there would force `TailorDBField` (which has a differently-typed\n * `clone`) to stop being assignable to `TailorField`, breaking the supported\n * `t.object({ field: db.string() })` usage. Every `t.*` and `db.*` field carries\n * a `clone()` at runtime, so the internal cast in `clone()` is safe.\n */\ntype CloneableField = { clone(): TailorAnyField };\n\nconst regex = {\n uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n date: /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/,\n time: /^(?<hour>\\d{2}):(?<minute>\\d{2})$/,\n datetime:\n /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})T(?<hour>\\d{2}):(?<minute>\\d{2}):(?<second>\\d{2})(.(?<millisec>\\d{3}))?Z$/,\n decimal: /^-?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/,\n} as const;\n\ntype FieldParseArgs = {\n value: unknown;\n data: unknown;\n user: TailorUser;\n};\n\ntype FieldValidateValueArgs<T extends TailorFieldType> = {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\ntype FieldParseInternalArgs = {\n // Runtime input is unknown/untyped; we validate and narrow it inside the parser.\n // oxlint-disable-next-line no-explicit-any\n value: any;\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\n/**\n * Creates a new TailorField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @param metadata - Pre-built metadata to clone from (used by `clone()`); when\n * given, the mutable containers are deep-copied here and `options`/`values` are\n * ignored for metadata construction\n * @returns A new TailorField\n */\nfunction createTailorField<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyField>,\n values?: AllowedValues,\n metadata?: FieldMetadata,\n): TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n> {\n // When cloning, take ownership of the source metadata and deep-copy its mutable\n // containers (enum value objects and `[fn, message]` validator tuples; validator\n // functions are kept by reference) so no two instances share mutable state.\n const _metadata: FieldMetadata = metadata\n ? {\n ...metadata,\n ...(metadata.allowedValues && {\n allowedValues: metadata.allowedValues.map((v) => ({ ...v })),\n }),\n ...(metadata.validate && {\n validate: metadata.validate.map((v) => (Array.isArray(v) ? ([...v] as typeof v) : v)),\n }),\n }\n : { required: true };\n\n if (!metadata) {\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @param args - Value, context data, and user\n * @returns Array of validation issues\n */\n function validateValue(args: FieldValidateValueArgs<T>): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n // Type-specific validation\n switch (type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value)) {\n issues.push({\n message: `Expected an integer: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"float\":\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({\n message: `Expected a number: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"boolean\":\n if (typeof value !== \"boolean\") {\n issues.push({\n message: `Expected a boolean: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"uuid\":\n if (typeof value !== \"string\" || !regex.uuid.test(value)) {\n issues.push({\n message: `Expected a valid UUID: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"date\":\n if (typeof value !== \"string\" || !regex.date.test(value)) {\n issues.push({\n message: `Expected to match \"yyyy-MM-dd\" format: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"datetime\":\n if (typeof value !== \"string\" || !regex.datetime.test(value)) {\n issues.push({\n message: `Expected to match ISO format: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"time\":\n if (typeof value !== \"string\" || !regex.time.test(value)) {\n issues.push({\n message: `Expected to match \"HH:mm\" format: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"decimal\":\n if (typeof value !== \"string\" || !regex.decimal.test(value)) {\n issues.push({\n message: `Expected a decimal string: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._metadata.allowedValues.map((v) => v.value);\n if (typeof value !== \"string\" || !allowedValues.includes(value)) {\n issues.push({\n message: `Must be one of [${allowedValues.join(\", \")}]: received ${String(value)}`,\n path,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path,\n });\n } else if (field.fields && Object.keys(field.fields).length > 0) {\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = value?.[fieldName];\n const result = nestedField._parseInternal({\n value: fieldValue,\n data,\n user,\n pathArray: pathArray.concat(fieldName),\n });\n if (result.issues) {\n issues.push(...result.issues);\n }\n }\n }\n break;\n }\n\n // Custom validation functions\n const validateFns = field._metadata.validate;\n if (validateFns && validateFns.length > 0) {\n for (const validateInput of validateFns) {\n const { fn, message } =\n typeof validateInput === \"function\"\n ? { fn: validateInput, message: \"Validation failed\" }\n : { fn: validateInput[0], message: validateInput[1] };\n\n if (!fn({ value, data, user })) {\n issues.push({\n message,\n path,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @param args - Parse arguments\n * @returns Parse result with value or issues\n */\n function parseInternal(\n args: FieldParseInternalArgs,\n ): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation and normalize to null\n if (!field._metadata.required && isNullOrUndefined) {\n return { value: value ?? null };\n }\n\n // 2. Check array type\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path,\n });\n return { issues };\n }\n\n // Validate each array element (without array flag)\n for (let i = 0; i < value.length; i++) {\n const elementValue = value[i];\n const elementPath = pathArray.concat(`[${i}]`);\n\n // Validate element with same type but without array flag\n const elementIssues = validateValue({\n value: elementValue,\n data,\n user,\n pathArray: elementPath,\n });\n if (elementIssues.length > 0) {\n issues.push(...elementIssues);\n }\n }\n\n if (issues.length > 0) {\n return { issues };\n }\n return { value: value as FieldOutput<OutputBase, TOptions> };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = validateValue({ value, data, user, pathArray });\n issues.push(...valueIssues);\n\n if (issues.length > 0) {\n return { issues };\n }\n\n return { value };\n }\n\n /**\n * Clone the field and apply metadata updates to the clone.\n * The original instance is never mutated, so a field shared across places\n * cannot leak metadata between them.\n * @param metadataUpdates - Metadata properties to overwrite on the clone\n * @returns A new field with the updated metadata\n */\n function cloneWith(metadataUpdates: Partial<FieldMetadata>) {\n const cloned = field.clone();\n Object.assign(cloned._metadata, metadataUpdates);\n return cloned;\n }\n\n const field: TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n > &\n CloneableField = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as {\n type: T;\n array: TOptions extends { array: true } ? true : false;\n },\n _output: undefined as FieldOutput<OutputBase, TOptions>,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n description(description: string) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ description }) as any;\n },\n\n typeName(typeName: string) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ typeName }) as any;\n },\n\n validate(...validateInputs: FieldValidateInput<FieldOutput<OutputBase, TOptions>>[]) {\n // Clone-on-write so a shared field instance never leaks metadata.\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ validate: validateInputs }) as any;\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n return parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n\n clone() {\n // Deep clone nested object fields so the new instance shares no mutable state.\n let clonedFields = fields;\n if (fields) {\n const cloned: Record<string, TailorAnyField> = {};\n for (const [key, nestedField] of Object.entries(fields)) {\n // Both t.* and db.* fields carry clone() at runtime (see CloneableField).\n cloned[key] = (nestedField as TailorAnyField & CloneableField).clone();\n }\n clonedFields = cloned;\n }\n\n // Rebuild via the factory, handing it this field's metadata so the new\n // parseInternal/validateValue closures rebind to the clone and the factory\n // owns the metadata deep-copy.\n // oxlint-disable-next-line no-explicit-any\n return createTailorField(type, options, clonedFields, values, this._metadata) as any;\n },\n };\n\n return field;\n}\n\n/**\n * Create a UUID field for resolver input/output.\n * @param options - Field configuration options\n * @returns A UUID field\n * @example t.uuid()\n */\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"uuid\", options);\n}\n\n/**\n * Create a string field for resolver input/output.\n * @param options - Field configuration options\n * @returns A string field\n * @example t.string()\n * @example t.string({ optional: true })\n * @example t.string({ array: true })\n */\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"string\", options);\n}\n\n/**\n * Create a boolean field for resolver input/output.\n * @param options - Field configuration options\n * @returns A boolean field\n * @example t.bool()\n */\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"boolean\", options);\n}\n\n/**\n * Create an integer field for resolver input/output.\n * @param options - Field configuration options\n * @returns An integer field\n * @example t.int()\n */\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"integer\", options);\n}\n\n/**\n * Create a float field for resolver input/output.\n * @param options - Field configuration options\n * @returns A float field\n * @example t.float()\n */\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"float\", options);\n}\n\n/**\n * Create a decimal field for resolver input/output (stored as string for precision).\n * @param options - Field configuration options\n * @returns A decimal field\n * @example t.decimal()\n * @example t.decimal({ optional: true })\n */\nfunction decimal<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"decimal\", options);\n}\n\n/**\n * Create a date field for resolver input/output.\n * @param options - Field configuration options\n * @returns A date field\n * @example t.date()\n */\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"date\", options);\n}\n\n/**\n * Create a datetime field for resolver input/output.\n * @param options - Field configuration options\n * @returns A datetime field\n * @example t.datetime()\n */\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"datetime\", options);\n}\n\n/**\n * Create a time field for resolver input/output.\n * @param options - Field configuration options\n * @returns A time field\n * @example t.time()\n */\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"time\", options);\n}\n\n/**\n * Create an enum field for resolver input/output.\n * @param values - Array of allowed string values\n * @param options - Field configuration options\n * @returns An enum field\n * @example t.enum([\"active\", \"inactive\"])\n */\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createTailorField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\n/**\n * Create a nested object field for resolver input/output.\n * @param fields - Record of field definitions\n * @param options - Field options (optional, array)\n * @returns A nested object field\n * @example\n * // Single object:\n * output: t.object({ name: t.string(), email: t.string() })\n * @example\n * // Array of objects:\n * items: t.object({ name: t.string() }, { array: true })\n */\nfunction object<const F extends Record<string, TailorAnyField>, const Opt extends FieldOptions>(\n fields: F,\n options?: Opt,\n) {\n const objectField = createTailorField(\"nested\", options, fields) as TailorField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n return objectField;\n}\n\nexport const t = {\n uuid,\n string,\n b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,kBAAkB,MAAM,SAAS,cAAc,QAAQ,KAAK,SAAS;EAC9E;CACF;CAEA,OAAO;AACT;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,QAAQ,OAAO;AAC1C;;;;;;;;;AAUA,SAAS,OAAuC,SAAe;CAC7D,OAAO,kBAAkB,UAAU,OAAO;AAC5C;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;;;;;;AAQA,SAAS,IAAoC,SAAe;CAC1D,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;;;;;;AAQA,SAAS,MAAsC,SAAe;CAC5D,OAAO,kBAAkB,SAAS,OAAO;AAC3C;;;;;;;;AASA,SAAS,QAAwC,SAAe;CAC9D,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,QAAQ,OAAO;AAC1C;;;;;;;AAQA,SAAS,SAAyC,SAAe;CAC/D,OAAO,kBAAkB,YAAY,OAAO;AAC9C;;;;;;;AAQA,SAAS,KAAqC,SAAe;CAC3D,OAAO,kBAAkB,QAAQ,OAAO;AAC1C;;;;;;;;AASA,SAAS,MACP,QACA,SAIA;CACA,OAAO,kBAAuD,QAAQ,SAAS,QAAW,MAAM;AAClG;;;;;;;;;;;;;AAcA,SAAS,OACP,QACA,SACA;CAKA,OAJoB,kBAAkB,UAAU,SAAS,MAIxC;AACnB;AAEA,MAAa,IAAI;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { M as TailorInvoker } from "../../tailordb-BlBGmQK-.mjs";
|
|
2
|
-
import { W as TailorDBType } from "../../workflow.generated-
|
|
3
|
-
import { At as TailorField, bt as WORKFLOW_TEST_ENV_KEY, n as output } from "../../index-
|
|
2
|
+
import { W as TailorDBType } from "../../workflow.generated-Kz-nQrTf.mjs";
|
|
3
|
+
import { At as TailorField, bt as WORKFLOW_TEST_ENV_KEY, n as output } from "../../index-B61gFI9a.mjs";
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/test/mock.d.ts
|
|
@@ -36,12 +36,21 @@ type TailorTypePermission<User extends object = InferredAttributeMap, Type exten
|
|
|
36
36
|
type ActionPermission<Level extends "record" | "gql" = "record" | "gql", User extends object = InferredAttributeMap, Type extends object = object, Update extends boolean = boolean> = {
|
|
37
37
|
conditions: PermissionCondition<Level, User, Update, Type> | readonly PermissionCondition<Level, User, Update, Type>[];
|
|
38
38
|
description?: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Whether matching records are granted (`true`) or denied (`false`).
|
|
41
|
+
* Omitting `permit` in this object form defaults to `deny` and emits a
|
|
42
|
+
* warning; set it explicitly. (The array shorthand defaults to `allow`.)
|
|
43
|
+
*/
|
|
39
44
|
permit?: boolean;
|
|
40
45
|
} | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])];
|
|
41
46
|
type TailorTypeGqlPermission<User extends object = InferredAttributeMap, Type extends object = object> = readonly GqlPermissionPolicy<User, Type>[];
|
|
42
47
|
type GqlPermissionPolicy<User extends object = InferredAttributeMap, Type extends object = object> = {
|
|
43
48
|
conditions: readonly PermissionCondition<"gql", User, boolean, Type>[];
|
|
44
49
|
actions: "all" | readonly GqlPermissionAction[];
|
|
50
|
+
/**
|
|
51
|
+
* Whether matching requests are granted (`true`) or denied (`false`).
|
|
52
|
+
* Omitting `permit` defaults to `deny` and emits a warning; set it explicitly.
|
|
53
|
+
*/
|
|
45
54
|
permit?: boolean;
|
|
46
55
|
description?: string;
|
|
47
56
|
};
|
|
@@ -1403,4 +1412,4 @@ type ConcurrencyPolicy = {
|
|
|
1403
1412
|
};
|
|
1404
1413
|
//#endregion
|
|
1405
1414
|
export { BeforeLoginHookArgs as A, TailorAnyDBField as B, IdPGqlOperationsInput as C, AuthExternalConfig as D, AuthConnectionTokenResult as E, UserAttributeListKey as F, db as G, TailorDBField as H, UserAttributeMap as I, TailorTypePermission as J, PermissionCondition as K, UsernameFieldKey as L, OAuth2ClientGrantType as M, SCIMAttributeType as N, AuthOwnConfig as O, UserAttributeKey as P, AllowedValuesOutput as Q, AuthConnectionConfig as R, IdPGqlOperations as S, AuthConfig as T, TailorDBInstance as U, TailorAnyDBType as V, TailorDBType as W, unsafeAllowAllTypePermission as X, unsafeAllowAllGqlPermission as Y, AllowedValues as Z, IdPConfig as _, ExecutorServiceConfig as a, IdpDefinitionBrand as b, ResolverServiceConfig as c, WorkflowServiceInput as d, StaticWebsiteConfig as f, SecretsDefinitionBrand as g, SecretsConfig as h, AppConfig as i, DefinedAuth as j, AuthServiceInput as k, ResolverServiceInput as l, StaticWebsiteInput as m, RetryPolicy as n, ExecutorServiceInput as o, StaticWebsiteDefinitionBrand as p, TailorTypeGqlPermission as q, HttpAdapterConfigInput as r, ResolverExternalConfig as s, ConcurrencyPolicy as t, WorkflowServiceConfig as u, IdPExternalConfig as v, IdPInput as w, IdPEmailConfig as x, IdPUserField as y, AuthConnectionOAuth2Config as z };
|
|
1406
|
-
//# sourceMappingURL=workflow.generated-
|
|
1415
|
+
//# sourceMappingURL=workflow.generated-Kz-nQrTf.d.mts.map
|
package/docs/cli/tailordb.md
CHANGED
|
@@ -28,11 +28,11 @@ tailor-sdk tailordb [command]
|
|
|
28
28
|
|
|
29
29
|
**Commands**
|
|
30
30
|
|
|
31
|
-
| Command | Description
|
|
32
|
-
| ------------------------------------------- |
|
|
33
|
-
| [`tailordb truncate`](#tailordb-truncate) | Truncate (delete all records from) TailorDB tables.
|
|
34
|
-
| [`tailordb migration`](#tailordb-migration) | Manage TailorDB schema migrations.
|
|
35
|
-
| [`tailordb erd`](#tailordb-erd) | Generate ERD artifacts
|
|
31
|
+
| Command | Description |
|
|
32
|
+
| ------------------------------------------- | ------------------------------------------------------------------------- |
|
|
33
|
+
| [`tailordb truncate`](#tailordb-truncate) | Truncate (delete all records from) TailorDB tables. |
|
|
34
|
+
| [`tailordb migration`](#tailordb-migration) | Manage TailorDB schema migrations. |
|
|
35
|
+
| [`tailordb erd`](#tailordb-erd) | Generate TailorDB ERD viewer artifacts from local TailorDB schema. (beta) |
|
|
36
36
|
|
|
37
37
|
<!-- politty:command:tailordb:subcommands:end -->
|
|
38
38
|
|
|
@@ -357,7 +357,7 @@ See [Global Options](../cli-reference.md#global-options) for options available t
|
|
|
357
357
|
|
|
358
358
|
<!-- politty:command:tailordb erd:description:start -->
|
|
359
359
|
|
|
360
|
-
Generate ERD artifacts
|
|
360
|
+
Generate TailorDB ERD viewer artifacts from local TailorDB schema. (beta)
|
|
361
361
|
|
|
362
362
|
<!-- politty:command:tailordb erd:description:end -->
|
|
363
363
|
|
|
@@ -375,11 +375,11 @@ tailor-sdk tailordb erd [command]
|
|
|
375
375
|
|
|
376
376
|
**Commands**
|
|
377
377
|
|
|
378
|
-
| Command | Description
|
|
379
|
-
| --------------------------------------------- |
|
|
380
|
-
| [`tailordb erd export`](#tailordb-erd-export) | Export
|
|
381
|
-
| [`tailordb erd serve`](#tailordb-erd-serve) | Generate and serve ERD locally
|
|
382
|
-
| [`tailordb erd deploy`](#tailordb-erd-deploy) | Deploy ERD static website for TailorDB namespace(s).
|
|
378
|
+
| Command | Description |
|
|
379
|
+
| --------------------------------------------- | ----------------------------------------------------------------- |
|
|
380
|
+
| [`tailordb erd export`](#tailordb-erd-export) | Export TailorDB ERD static viewer from local TailorDB schema. |
|
|
381
|
+
| [`tailordb erd serve`](#tailordb-erd-serve) | Generate and serve TailorDB ERD locally with watch reload. (beta) |
|
|
382
|
+
| [`tailordb erd deploy`](#tailordb-erd-deploy) | Deploy ERD static website for TailorDB namespace(s). |
|
|
383
383
|
|
|
384
384
|
<!-- politty:command:tailordb erd:subcommands:end -->
|
|
385
385
|
|
|
@@ -396,7 +396,7 @@ See [Global Options](../cli-reference.md#global-options) for options available t
|
|
|
396
396
|
|
|
397
397
|
<!-- politty:command:tailordb erd export:description:start -->
|
|
398
398
|
|
|
399
|
-
Export
|
|
399
|
+
Export TailorDB ERD static viewer from local TailorDB schema.
|
|
400
400
|
|
|
401
401
|
<!-- politty:command:tailordb erd export:description:end -->
|
|
402
402
|
|
|
@@ -414,13 +414,11 @@ tailor-sdk tailordb erd export [options]
|
|
|
414
414
|
|
|
415
415
|
**Options**
|
|
416
416
|
|
|
417
|
-
| Option
|
|
418
|
-
|
|
|
419
|
-
| `--
|
|
420
|
-
| `--
|
|
421
|
-
| `--
|
|
422
|
-
| `--namespace <NAMESPACE>` | `-n` | TailorDB namespace name (optional if only one namespace is defined in config) | No | - | - |
|
|
423
|
-
| `--output <OUTPUT>` | `-o` | Output directory path for tbls-compatible ERD JSON (writes to `<outputDir>/<namespace>/schema.json`) | No | `".tailor-sdk/erd"` | - |
|
|
417
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
418
|
+
| ------------------------- | ----- | ---------------------------------------------------------------------------------------------- | -------- | -------------------- | --------------------------------- |
|
|
419
|
+
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
|
|
420
|
+
| `--namespace <NAMESPACE>` | `-n` | TailorDB namespace name (optional if only one namespace is defined in config) | No | - | - |
|
|
421
|
+
| `--output <OUTPUT>` | `-o` | Output directory path for TailorDB ERD viewer files (writes to `<outputDir>/<namespace>/dist`) | No | `".tailor-sdk/erd"` | - |
|
|
424
422
|
|
|
425
423
|
<!-- politty:command:tailordb erd export:options:end -->
|
|
426
424
|
|
|
@@ -437,7 +435,7 @@ See [Global Options](../cli-reference.md#global-options) for options available t
|
|
|
437
435
|
|
|
438
436
|
<!-- politty:command:tailordb erd serve:description:start -->
|
|
439
437
|
|
|
440
|
-
Generate and serve ERD locally
|
|
438
|
+
Generate and serve TailorDB ERD locally with watch reload. (beta)
|
|
441
439
|
|
|
442
440
|
<!-- politty:command:tailordb erd serve:description:end -->
|
|
443
441
|
|
|
@@ -455,12 +453,12 @@ tailor-sdk tailordb erd serve [options]
|
|
|
455
453
|
|
|
456
454
|
**Options**
|
|
457
455
|
|
|
458
|
-
| Option
|
|
459
|
-
|
|
|
460
|
-
| `--
|
|
461
|
-
| `--
|
|
462
|
-
| `--
|
|
463
|
-
| `--
|
|
456
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
457
|
+
| ------------------------- | ----- | ------------------------------------------------------------------------- | -------- | -------------------- | --------------------------------- |
|
|
458
|
+
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
|
|
459
|
+
| `--namespace <NAMESPACE>` | `-n` | TailorDB namespace name (uses first namespace in config if not specified) | No | - | - |
|
|
460
|
+
| `--port <PORT>` | - | Local server port (0 selects a free port) | No | `0` | - |
|
|
461
|
+
| `--open` | - | Open the ERD viewer in the default browser | No | `false` | - |
|
|
464
462
|
|
|
465
463
|
<!-- politty:command:tailordb erd serve:options:end -->
|
|
466
464
|
|
|
@@ -510,6 +508,13 @@ See [Global Options](../cli-reference.md#global-options) for options available t
|
|
|
510
508
|
|
|
511
509
|
<!-- politty:command:tailordb erd deploy:global-options-link:end -->
|
|
512
510
|
|
|
511
|
+
**Notes:**
|
|
512
|
+
|
|
513
|
+
- ERD commands build from the local TailorDB schema, including plugin-generated TailorDB types.
|
|
514
|
+
- `tailordb erd export` writes a self-contained `index.html` viewer to `<output>/<namespace>/dist`.
|
|
515
|
+
- `tailordb erd serve` watches the config file and TailorDB type files, then reloads the browser viewer when the rebuilt `index.html` reports a new embedded schema revision.
|
|
516
|
+
- `tailordb erd deploy` still requires `erdSite` in `tailor.config.ts` because it uploads the generated viewer to a configured Static Website.
|
|
517
|
+
|
|
513
518
|
**Usage Examples:**
|
|
514
519
|
|
|
515
520
|
```bash
|
package/docs/cli-reference.md
CHANGED
|
@@ -130,8 +130,8 @@ Commands for managing TailorDB tables, data, and schema migrations.
|
|
|
130
130
|
| [tailordb migration script](./cli/tailordb.md#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory. |
|
|
131
131
|
| [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint to a specific number. |
|
|
132
132
|
| [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
|
|
133
|
-
| [tailordb erd export](./cli/tailordb.md#tailordb-erd-export) | Export
|
|
134
|
-
| [tailordb erd serve](./cli/tailordb.md#tailordb-erd-serve) | Generate and serve ERD locally
|
|
133
|
+
| [tailordb erd export](./cli/tailordb.md#tailordb-erd-export) | Export TailorDB ERD static viewer from local TailorDB schema. |
|
|
134
|
+
| [tailordb erd serve](./cli/tailordb.md#tailordb-erd-serve) | Generate and serve TailorDB ERD locally with watch reload. (beta) |
|
|
135
135
|
| [tailordb erd deploy](./cli/tailordb.md#tailordb-erd-deploy) | Deploy ERD static website for TailorDB namespace(s). |
|
|
136
136
|
|
|
137
137
|
### [Query Commands](./cli/query.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -143,7 +143,6 @@
|
|
|
143
143
|
"@inquirer/core": "11.2.1",
|
|
144
144
|
"@inquirer/prompts": "8.5.2",
|
|
145
145
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
146
|
-
"@liam-hq/cli": "0.7.24",
|
|
147
146
|
"@napi-rs/keyring": "1.3.0",
|
|
148
147
|
"@opentelemetry/api": "1.9.1",
|
|
149
148
|
"@opentelemetry/exporter-trace-otlp-proto": "0.218.0",
|
|
@@ -177,7 +176,6 @@
|
|
|
177
176
|
"politty": "0.5.1",
|
|
178
177
|
"rolldown": "1.0.3",
|
|
179
178
|
"semver": "7.8.1",
|
|
180
|
-
"serve": "14.2.6",
|
|
181
179
|
"sql-highlight": "6.1.0",
|
|
182
180
|
"std-env": "4.1.0",
|
|
183
181
|
"table": "6.9.0",
|