@finos/legend-graph
Version:
Legend graph and graph manager
52 lines • 2.52 kB
JavaScript
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { UnsupportedOperationError, usingConstantValueSchema, usingModelSchema, } from '@finos/legend-shared';
import { createModelSchema, custom, deserialize, primitive, serialize, } from 'serializr';
import { V1_CreateSubscriptionInput, V1_DataSubscription, V1_DataSubscriptionResponse, V1_DataSubscriptionTargetType, V1_SnowflakeTarget, } from '../../../lakehouse/subscriptions/V1_ConsumerSubscriptions.js';
export const V1_SnowflakeTargetModelSchema = createModelSchema(V1_SnowflakeTarget, {
_type: usingConstantValueSchema(V1_DataSubscriptionTargetType.Snowflake),
snowflakeAccountId: primitive(),
snowflakeRegion: primitive(),
snowflakeNetwork: primitive(),
});
const V1_deseralizeDataSubscriptionTarget = (json) => {
switch (json._type) {
case V1_DataSubscriptionTargetType.Snowflake:
return deserialize(V1_SnowflakeTargetModelSchema, json);
default:
throw new UnsupportedOperationError();
}
};
const V1_seralizeDataSubscriptionTarget = (json) => {
if (json instanceof V1_SnowflakeTarget) {
return serialize(V1_SnowflakeTargetModelSchema, json);
}
throw new UnsupportedOperationError();
};
export const V1_dataSubscriptionModelSchema = createModelSchema(V1_DataSubscription, {
guid: primitive(),
dataContractId: primitive(),
target: custom(V1_seralizeDataSubscriptionTarget, V1_deseralizeDataSubscriptionTarget),
createdBy: primitive(),
});
export const V1_DataSubscriptionResponseModelSchema = createModelSchema(V1_DataSubscriptionResponse, {
subscriptions: usingModelSchema(V1_dataSubscriptionModelSchema),
});
export const V1_CreateSubscriptionInputModelSchema = createModelSchema(V1_CreateSubscriptionInput, {
contractId: primitive(),
target: custom(V1_seralizeDataSubscriptionTarget, V1_deseralizeDataSubscriptionTarget),
});
//# sourceMappingURL=V1_SubscriptionSerializationHelper.js.map