Converts legacy CustomSchemaField format to new MetadataFieldSchema format.
This function provides backward compatibility by converting the old Record-based schema format to the new array-based format. It also emits a deprecation warning.
convertLegacySchema(
metadataKey: string,
legacySchema: Record<string, CustomSchemaField>
): MetadataFieldSchema[]| Name | Type | Description |
|---|---|---|
metadataKey* | string | the custom metadata key prefix |
legacySchema* | Record<string, CustomSchemaField> | The legacy schema in Record<string, CustomSchemaField> format |
const legacySchema = {
userId: { type: SchemaFieldTypes.TAG, SEPARATOR: "|" },
price: { type: SchemaFieldTypes.NUMERIC, SORTABLE: true }
};
const newSchema = convertLegacySchema(legacySchema);
// Returns: [
// { name: "userId", type: "tag", options: { separator: "|" } },
// { name: "price", type: "numeric", options: { sortable: true } }
// ]