Skip to content

Commit

Permalink
Merge pull request #12 from Send4BR/dev
Browse files Browse the repository at this point in the history
TKR-3749 Atualizar schema no SDK ecommerce replicator [main]
  • Loading branch information
Abner Persio authored Apr 1, 2022
2 parents 53b6b87 + ec67714 commit 2e3a67a
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 57 deletions.
76 changes: 74 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ declare module '@aftersale/ecommerce-replication-sdk/lib/__mocks__/ecommerce-moc
connectorUrl: string;
connectorFields: {
Url: string;
"Any-Key": string;
"Any-Token": string;
'Any-Key': string;
'Any-Token': string;
};
};
features: string[];
Expand All @@ -38,6 +38,58 @@ declare module '@aftersale/ecommerce-replication-sdk/lib/__mocks__/ecommerce-moc
isActive: boolean;
}[];
utm: {};
notifications: number[];
demo: boolean;
couriers: {
id: string;
enabled: boolean;
customNames: string[];
courierUrl: null;
connectorUrl: string;
}[];
mappedEcommerceStatuses: {
'payment-pending': string;
'payment-approved': string;
'window-to-cancel': string;
handling: string;
'payment-denied': string;
invoiced: string;
invoice: string;
canceled: string;
cancel: string;
};
messages: {
courier: {
id: number;
isCustomizable: boolean;
title: string;
detail: string;
customDetail: null;
description: null;
actionIds: number[];
tags: never[];
}[];
platform: {
id: number;
isCustomizable: boolean;
title: string;
detail: string;
customDetail: null;
description: null;
actionIds: never[];
tags: never[];
}[];
system: {
id: number;
isCustomizable: boolean;
title: string;
detail: null;
customDetail: null;
description: null;
actionIds: number[];
tags: never[];
}[];
};
};
export default _default;

Expand Down Expand Up @@ -93,6 +145,26 @@ declare module '@aftersale/ecommerce-replication-sdk/lib/types/ecommerce' {
rules: string;
expirationDate: string | number | Date;
}[];
notifications: number[];
demo: boolean;
couriers: {
id: string;
enabled: boolean;
courierUrl: string | null;
connectorUrl: string | null;
customNames: string[];
authFields?: Record<string, unknown>;
}[];
mappedEcommerceStatuses: Record<string, string>;
messages: Record<'courier' | 'system' | 'platform', {
id: number;
isCustomizable: boolean;
title: string;
customDetail: string | null;
description: string | null;
actionIds: number[];
tags: string[];
}[]>;
};

}
Expand Down
3 changes: 2 additions & 1 deletion dist/index.esm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// lib/schema.ts
import S from "fluent-json-schema";
var schema = S.object().prop("uuid", S.string().required()).prop("enabled", S.boolean().required()).prop("name", S.string().required()).prop("storeUrl", S.string().required()).prop("trackingUrl", S.string().required()).prop("logoUrl", S.string().required()).prop("email", S.string().required()).prop("confirmationType", S.string().required()).prop("integrations", S.object().prop("platform", S.string().required()).prop("store_id", S.string().required()).prop("origin_domain", S.string().required()).prop("connectorUrl", S.string().required()).prop("connectorFields", S.object().required())).prop("channels", S.array().items(S.object().prop("id", S.string()).prop("data", S.object()))).prop("features", S.array().items(S.string())).prop("featureSettings", S.object().prop("loyalty", S.object().prop("enabled", S.boolean().required()))).prop("utm", S.object().required()).prop("createdAt", S.string().required()).prop("updatedAt", S.string().required()).prop("coupons", S.array().items(S.object().prop("isActive", S.boolean().required()).prop("name", S.string().required()).prop("rules", S.string().required()).prop("expirationDate", S.string().required())));
var ecommerceMessageSchema = S.object().prop("id", S.number()).prop("isCustomizable", S.boolean()).prop("title", S.string()).prop("customDetail", S.anyOf([S.string(), S.null()])).prop("description", S.anyOf([S.string(), S.null()])).prop("actionIds", S.array().items(S.number())).prop("tags", S.array().items(S.string()));
var schema = S.object().prop("uuid", S.string().required()).prop("enabled", S.boolean().required()).prop("name", S.string().required()).prop("storeUrl", S.string().required()).prop("trackingUrl", S.string().required()).prop("logoUrl", S.string().required()).prop("email", S.string().required()).prop("confirmationType", S.string().required()).prop("integrations", S.object().prop("platform", S.string().required()).prop("store_id", S.string().required()).prop("origin_domain", S.string().required()).prop("connectorUrl", S.string().required()).prop("connectorFields", S.object().required())).prop("channels", S.array().items(S.object().prop("id", S.string()).prop("data", S.object()))).prop("features", S.array().items(S.string())).prop("featureSettings", S.object().prop("loyalty", S.object().prop("enabled", S.boolean().required()))).prop("utm", S.object().required()).prop("createdAt", S.string().required()).prop("updatedAt", S.string().required()).prop("coupons", S.array().items(S.object().prop("isActive", S.boolean().required()).prop("name", S.string().required()).prop("rules", S.string().required()).prop("expirationDate", S.string().required()))).prop("notifications", S.array().items(S.number())).prop("demo", S.boolean()).prop("couriers", S.array().items(S.object().prop("customNames", S.array().items(S.string())).prop("enabled", S.boolean().required()).prop("id", S.string().required()).prop("courierUrl", S.anyOf([S.string(), S.null()])).prop("connectorUrl", S.anyOf([S.string(), S.null()])).prop("authFields", S.object()))).prop("mappedEcommerceStatuses", S.object().required()).prop("messsages", S.object().prop("courier", S.array().items(ecommerceMessageSchema).required()).prop("platform", S.array().items(ecommerceMessageSchema).required()).prop("system", S.array().items(ecommerceMessageSchema).required()));

// lib/send.ts
async function send({ client, ecommerce }) {
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ __export(lib_exports, {

// lib/schema.ts
var import_fluent_json_schema = __toESM(require("fluent-json-schema"));
var schema = import_fluent_json_schema.default.object().prop("uuid", import_fluent_json_schema.default.string().required()).prop("enabled", import_fluent_json_schema.default.boolean().required()).prop("name", import_fluent_json_schema.default.string().required()).prop("storeUrl", import_fluent_json_schema.default.string().required()).prop("trackingUrl", import_fluent_json_schema.default.string().required()).prop("logoUrl", import_fluent_json_schema.default.string().required()).prop("email", import_fluent_json_schema.default.string().required()).prop("confirmationType", import_fluent_json_schema.default.string().required()).prop("integrations", import_fluent_json_schema.default.object().prop("platform", import_fluent_json_schema.default.string().required()).prop("store_id", import_fluent_json_schema.default.string().required()).prop("origin_domain", import_fluent_json_schema.default.string().required()).prop("connectorUrl", import_fluent_json_schema.default.string().required()).prop("connectorFields", import_fluent_json_schema.default.object().required())).prop("channels", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.object().prop("id", import_fluent_json_schema.default.string()).prop("data", import_fluent_json_schema.default.object()))).prop("features", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.string())).prop("featureSettings", import_fluent_json_schema.default.object().prop("loyalty", import_fluent_json_schema.default.object().prop("enabled", import_fluent_json_schema.default.boolean().required()))).prop("utm", import_fluent_json_schema.default.object().required()).prop("createdAt", import_fluent_json_schema.default.string().required()).prop("updatedAt", import_fluent_json_schema.default.string().required()).prop("coupons", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.object().prop("isActive", import_fluent_json_schema.default.boolean().required()).prop("name", import_fluent_json_schema.default.string().required()).prop("rules", import_fluent_json_schema.default.string().required()).prop("expirationDate", import_fluent_json_schema.default.string().required())));
var ecommerceMessageSchema = import_fluent_json_schema.default.object().prop("id", import_fluent_json_schema.default.number()).prop("isCustomizable", import_fluent_json_schema.default.boolean()).prop("title", import_fluent_json_schema.default.string()).prop("customDetail", import_fluent_json_schema.default.anyOf([import_fluent_json_schema.default.string(), import_fluent_json_schema.default.null()])).prop("description", import_fluent_json_schema.default.anyOf([import_fluent_json_schema.default.string(), import_fluent_json_schema.default.null()])).prop("actionIds", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.number())).prop("tags", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.string()));
var schema = import_fluent_json_schema.default.object().prop("uuid", import_fluent_json_schema.default.string().required()).prop("enabled", import_fluent_json_schema.default.boolean().required()).prop("name", import_fluent_json_schema.default.string().required()).prop("storeUrl", import_fluent_json_schema.default.string().required()).prop("trackingUrl", import_fluent_json_schema.default.string().required()).prop("logoUrl", import_fluent_json_schema.default.string().required()).prop("email", import_fluent_json_schema.default.string().required()).prop("confirmationType", import_fluent_json_schema.default.string().required()).prop("integrations", import_fluent_json_schema.default.object().prop("platform", import_fluent_json_schema.default.string().required()).prop("store_id", import_fluent_json_schema.default.string().required()).prop("origin_domain", import_fluent_json_schema.default.string().required()).prop("connectorUrl", import_fluent_json_schema.default.string().required()).prop("connectorFields", import_fluent_json_schema.default.object().required())).prop("channels", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.object().prop("id", import_fluent_json_schema.default.string()).prop("data", import_fluent_json_schema.default.object()))).prop("features", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.string())).prop("featureSettings", import_fluent_json_schema.default.object().prop("loyalty", import_fluent_json_schema.default.object().prop("enabled", import_fluent_json_schema.default.boolean().required()))).prop("utm", import_fluent_json_schema.default.object().required()).prop("createdAt", import_fluent_json_schema.default.string().required()).prop("updatedAt", import_fluent_json_schema.default.string().required()).prop("coupons", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.object().prop("isActive", import_fluent_json_schema.default.boolean().required()).prop("name", import_fluent_json_schema.default.string().required()).prop("rules", import_fluent_json_schema.default.string().required()).prop("expirationDate", import_fluent_json_schema.default.string().required()))).prop("notifications", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.number())).prop("demo", import_fluent_json_schema.default.boolean()).prop("couriers", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.object().prop("customNames", import_fluent_json_schema.default.array().items(import_fluent_json_schema.default.string())).prop("enabled", import_fluent_json_schema.default.boolean().required()).prop("id", import_fluent_json_schema.default.string().required()).prop("courierUrl", import_fluent_json_schema.default.anyOf([import_fluent_json_schema.default.string(), import_fluent_json_schema.default.null()])).prop("connectorUrl", import_fluent_json_schema.default.anyOf([import_fluent_json_schema.default.string(), import_fluent_json_schema.default.null()])).prop("authFields", import_fluent_json_schema.default.object()))).prop("mappedEcommerceStatuses", import_fluent_json_schema.default.object().required()).prop("messsages", import_fluent_json_schema.default.object().prop("courier", import_fluent_json_schema.default.array().items(ecommerceMessageSchema).required()).prop("platform", import_fluent_json_schema.default.array().items(ecommerceMessageSchema).required()).prop("system", import_fluent_json_schema.default.array().items(ecommerceMessageSchema).required()));

// lib/send.ts
async function send({ client, ecommerce }) {
Expand Down
2 changes: 1 addition & 1 deletion dist/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

103 changes: 81 additions & 22 deletions lib/__mocks__/ecommerce-mock.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,95 @@
export default {
uuid: "33e671bc-d17f-42b4-9aad-3f32260f4685",
uuid: '33e671bc-d17f-42b4-9aad-3f32260f4685',
enabled: true,
name: "Mock Ecomm",
storeUrl: "https://mockecomm.test",
trackingUrl: "mockecomm.delivery.after.sale",
email: "[email protected]",
confirmationType: "email",
channels: [{ id: "sms", primary: true, data: {} }],
name: 'Mock Ecomm',
storeUrl: 'https://mockecomm.test',
trackingUrl: 'mockecomm.delivery.after.sale',
email: '[email protected]',
confirmationType: 'email',
channels: [{ id: 'sms', primary: true, data: {} }],
integration: {
platform: "vtex",
origin_domain: "mockecomm.test",
connectorUrl: "https://mockecomm.test",
platform: 'vtex',
origin_domain: 'mockecomm.test',
connectorUrl: 'https://mockecomm.test',
connectorFields: {
Url: "https://mockecomm.test",
"Any-Key": "fake-key",
"Any-Token": "fake-token",
Url: 'https://mockecomm.test',
'Any-Key': 'fake-key',
'Any-Token': 'fake-token',
},
},
features: ["feature"],
logoUrl:
"https://send4.blob.core.windows.net/send4sprint/ecommerces/aftersale.png",

createdAt: "2021-12-16T14:11:36.320Z",
updatedAt: "2021-12-16T14:11:36.320Z",
features: ['feature'],
logoUrl: 'https://send4.blob.core.windows.net/send4sprint/ecommerces/aftersale.png',
createdAt: '2021-12-16T14:11:36.320Z',
updatedAt: '2021-12-16T14:11:36.320Z',
featureSettings: { loyalty: { enabled: true } },
coupons: [
{
name: "10OFF",
expirationDate: "2021-12-16T14:11:36.320Z",
rules: "CONFIA",
name: '10OFF',
expirationDate: '2021-12-16T14:11:36.320Z',
rules: 'CONFIA',
isActive: true,
},
],
utm: {},
notifications: [12],
demo: true,
couriers: [
{
id: 'correios',
enabled: true,
customNames: ['correios'],
courierUrl: null,
connectorUrl: 'http://connector.url',
},
],
mappedEcommerceStatuses: {
'payment-pending': 'payment-pending',
'payment-approved': 'payment-approved',
'window-to-cancel': 'payment-approved',
handling: 'handling',
'payment-denied': 'payment-denied',
invoiced: 'invoiced',
invoice: 'invoiced',
canceled: 'canceled',
cancel: 'canceled',
},
messages: {
courier: [
{
id: 12,
isCustomizable: true,
title: 'Entrega finalizada com sucesso :)',
detail: 'Eba! Entrega realizada!',
customDetail: null,
description: null,
actionIds: [2, 6],
tags: [],
},
],
platform: [
{
id: 1,
isCustomizable: true,
title: 'Pronto para envio.',
detail:
'Nota Fiscal emitida! Seu pedido já está pronto para envio! Mais novidades, em breve.',
customDetail: null,
description: null,
actionIds: [],
tags: [],
},
],
system: [
{
id: 13,
isCustomizable: false,
title: 'Entrega confirmada pelo cliente.',
detail: null,
customDetail: null,
description: null,
actionIds: [1, 6],
tags: [],
},
],
},
};
85 changes: 55 additions & 30 deletions lib/schema.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,70 @@
import S from "fluent-json-schema";
import S from 'fluent-json-schema';

const ecommerceMessageSchema = S.object()
.prop('id', S.number())
.prop('isCustomizable', S.boolean())
.prop('title', S.string())
.prop('customDetail', S.anyOf([S.string(), S.null()]))
.prop('description', S.anyOf([S.string(), S.null()]))
.prop('actionIds', S.array().items(S.number()))
.prop('tags', S.array().items(S.string()));

export const schema = S.object()
.prop("uuid", S.string().required())
.prop("enabled", S.boolean().required())
.prop("name", S.string().required())
.prop("storeUrl", S.string().required())
.prop("trackingUrl", S.string().required())
.prop("logoUrl", S.string().required())
.prop("email", S.string().required())
.prop("confirmationType", S.string().required())
.prop('uuid', S.string().required())
.prop('enabled', S.boolean().required())
.prop('name', S.string().required())
.prop('storeUrl', S.string().required())
.prop('trackingUrl', S.string().required())
.prop('logoUrl', S.string().required())
.prop('email', S.string().required())
.prop('confirmationType', S.string().required())
.prop(
"integrations",
'integrations',
S.object()
.prop("platform", S.string().required())
.prop("store_id", S.string().required())
.prop("origin_domain", S.string().required())
.prop("connectorUrl", S.string().required())
.prop("connectorFields", S.object().required())
.prop('platform', S.string().required())
.prop('store_id', S.string().required())
.prop('origin_domain', S.string().required())
.prop('connectorUrl', S.string().required())
.prop('connectorFields', S.object().required())
)
.prop('channels', S.array().items(S.object().prop('id', S.string()).prop('data', S.object())))
.prop('features', S.array().items(S.string()))
.prop(
"channels",
S.array().items(S.object().prop("id", S.string()).prop("data", S.object()))
'featureSettings',
S.object().prop('loyalty', S.object().prop('enabled', S.boolean().required()))
)
.prop("features", S.array().items(S.string()))
.prop('utm', S.object().required())
.prop('createdAt', S.string().required())
.prop('updatedAt', S.string().required())
.prop(
"featureSettings",
S.object().prop(
"loyalty",
S.object().prop("enabled", S.boolean().required())
'coupons',
S.array().items(
S.object()
.prop('isActive', S.boolean().required())
.prop('name', S.string().required())
.prop('rules', S.string().required())
.prop('expirationDate', S.string().required())
)
)
.prop("utm", S.object().required())
.prop("createdAt", S.string().required())
.prop("updatedAt", S.string().required())
.prop('notifications', S.array().items(S.number()))
.prop('demo', S.boolean())
.prop(
"coupons",
'couriers',
S.array().items(
S.object()
.prop("isActive", S.boolean().required())
.prop("name", S.string().required())
.prop("rules", S.string().required())
.prop("expirationDate", S.string().required())
.prop('customNames', S.array().items(S.string()))
.prop('enabled', S.boolean().required())
.prop('id', S.string().required())
.prop('courierUrl', S.anyOf([S.string(), S.null()]))
.prop('connectorUrl', S.anyOf([S.string(), S.null()]))
.prop('authFields', S.object())
)
)
.prop('mappedEcommerceStatuses', S.object().required())
.prop(
'messsages',
S.object()
.prop('courier', S.array().items(ecommerceMessageSchema).required())
.prop('platform', S.array().items(ecommerceMessageSchema).required())
.prop('system', S.array().items(ecommerceMessageSchema).required())
);
Loading

0 comments on commit 2e3a67a

Please sign in to comment.