@unchainedshop/utils 1.1.1
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/README.md +3 -0
- package/lib/buildSortOption.d.ts +5 -0
- package/lib/buildSortOption.js +13 -0
- package/lib/buildSortOption.js.map +1 -0
- package/lib/db/build-db-indexes.d.ts +2 -0
- package/lib/db/build-db-indexes.js +23 -0
- package/lib/db/build-db-indexes.js.map +1 -0
- package/lib/db/check-id.d.ts +4 -0
- package/lib/db/check-id.js +6 -0
- package/lib/db/check-id.js.map +1 -0
- package/lib/db/generate-db-filter-by-id.d.ts +5 -0
- package/lib/db/generate-db-filter-by-id.js +5 -0
- package/lib/db/generate-db-filter-by-id.js.map +1 -0
- package/lib/db/generate-db-mutations.d.ts +7 -0
- package/lib/db/generate-db-mutations.js +76 -0
- package/lib/db/generate-db-mutations.js.map +1 -0
- package/lib/db/generate-db-object-id.d.ts +7 -0
- package/lib/db/generate-db-object-id.js +26 -0
- package/lib/db/generate-db-object-id.js.map +1 -0
- package/lib/director/BaseAdapter.d.ts +2 -0
- package/lib/director/BaseAdapter.js +7 -0
- package/lib/director/BaseAdapter.js.map +1 -0
- package/lib/director/BaseDirector.d.ts +5 -0
- package/lib/director/BaseDirector.js +21 -0
- package/lib/director/BaseDirector.js.map +1 -0
- package/lib/director/BaseDiscountAdapter.d.ts +2 -0
- package/lib/director/BaseDiscountAdapter.js +48 -0
- package/lib/director/BaseDiscountAdapter.js.map +1 -0
- package/lib/director/BaseDiscountDirector.d.ts +2 -0
- package/lib/director/BaseDiscountDirector.js +57 -0
- package/lib/director/BaseDiscountDirector.js.map +1 -0
- package/lib/director/BasePricingAdapter.d.ts +2 -0
- package/lib/director/BasePricingAdapter.js +25 -0
- package/lib/director/BasePricingAdapter.js.map +1 -0
- package/lib/director/BasePricingDirector.d.ts +2 -0
- package/lib/director/BasePricingDirector.js +61 -0
- package/lib/director/BasePricingDirector.js.map +1 -0
- package/lib/director/BasePricingSheet.d.ts +2 -0
- package/lib/director/BasePricingSheet.js +55 -0
- package/lib/director/BasePricingSheet.js.map +1 -0
- package/lib/find-localized-text.d.ts +2 -0
- package/lib/find-localized-text.js +39 -0
- package/lib/find-localized-text.js.map +1 -0
- package/lib/find-preserving-ids.d.ts +2 -0
- package/lib/find-preserving-ids.js +33 -0
- package/lib/find-preserving-ids.js.map +1 -0
- package/lib/find-unused-slug.d.ts +8 -0
- package/lib/find-unused-slug.js +24 -0
- package/lib/find-unused-slug.js.map +1 -0
- package/lib/generate-random-hash.d.ts +2 -0
- package/lib/generate-random-hash.js +7 -0
- package/lib/generate-random-hash.js.map +1 -0
- package/lib/locale-helpers.d.ts +7 -0
- package/lib/locale-helpers.js +34 -0
- package/lib/locale-helpers.js.map +1 -0
- package/lib/object-invert.d.ts +2 -0
- package/lib/object-invert.js +7 -0
- package/lib/object-invert.js.map +1 -0
- package/lib/pipe-promises.d.ts +2 -0
- package/lib/pipe-promises.js +2 -0
- package/lib/pipe-promises.js.map +1 -0
- package/lib/random-value-hex.d.ts +1 -0
- package/lib/random-value-hex.js +8 -0
- package/lib/random-value-hex.js.map +1 -0
- package/lib/schemas/AddressSchema.d.ts +1 -0
- package/lib/schemas/AddressSchema.js +13 -0
- package/lib/schemas/AddressSchema.js.map +1 -0
- package/lib/schemas/ContactSchema.d.ts +1 -0
- package/lib/schemas/ContactSchema.js +6 -0
- package/lib/schemas/ContactSchema.js.map +1 -0
- package/lib/schemas/UsersSchema.d.ts +3 -0
- package/lib/schemas/UsersSchema.js +52 -0
- package/lib/schemas/UsersSchema.js.map +1 -0
- package/lib/schemas/commonSchemaFields.d.ts +50 -0
- package/lib/schemas/commonSchemaFields.js +31 -0
- package/lib/schemas/commonSchemaFields.js.map +1 -0
- package/lib/slugify.d.ts +1 -0
- package/lib/slugify.js +11 -0
- package/lib/slugify.js.map +1 -0
- package/lib/utils-index.d.ts +36 -0
- package/lib/utils-index.js +45 -0
- package/lib/utils-index.js.map +1 -0
- package/package.json +44 -0
- package/tests/generate-db-mutations.test.js +69 -0
- package/tests/utils-index.test.js +44 -0
- package/tsconfig.build.json +26 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-localized-text.js","sourceRoot":"","sources":["../src/find-localized-text.js"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEjC,MAAM,GAAG,GAAG,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,yBAAyB;AAEhF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAE/C,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;IACpD,MAAM,cAAc,GAAG;QACrB,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;KACtD,CAAC;IACF,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,QAAQ,EAAE,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,CAAC,EAAE,UAAU,CAAC,KAAK;QACnB,CAAC,EAAE,QAAQ;QACX,CAAC,EAAE,MAAM;KACV,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE3C,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAElC,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9F,IAAI,gBAAgB,EAAE;QACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC1C,OAAO,gBAAgB,CAAC;KACzB;IAED,IAAI,YAAY,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU,EAAE;QACjD,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,OAAO,CAClD,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CACjD,CAAC;QACF,IAAI,mBAAmB,EAAE;YACvB,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;YAC7C,OAAO,mBAAmB,CAAC;SAC5B;KACF;IAED,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACzD,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { AMAZON_DOCUMENTDB_COMPAT_MODE } = process.env;
|
|
2
|
+
const sortByIndex = {
|
|
3
|
+
index: 1,
|
|
4
|
+
};
|
|
5
|
+
const sortBySequence = {
|
|
6
|
+
sequence: 1,
|
|
7
|
+
};
|
|
8
|
+
const defaultSort = AMAZON_DOCUMENTDB_COMPAT_MODE ? sortBySequence : sortByIndex;
|
|
9
|
+
export const findPreservingIds = (collection) => async (selector, ids, options) => {
|
|
10
|
+
const { skip, limit, sort = defaultSort } = options || {};
|
|
11
|
+
const filteredSelector = {
|
|
12
|
+
...selector,
|
|
13
|
+
_id: { $in: ids },
|
|
14
|
+
};
|
|
15
|
+
const filteredPipeline = [
|
|
16
|
+
{
|
|
17
|
+
$match: filteredSelector,
|
|
18
|
+
},
|
|
19
|
+
typeof sort === 'object' &&
|
|
20
|
+
'index' in sort && {
|
|
21
|
+
$addFields: {
|
|
22
|
+
index: { $indexOfArray: [ids, '$_id'] },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
sort && { $sort: sort },
|
|
26
|
+
skip && { $skip: skip },
|
|
27
|
+
limit && { $limit: limit },
|
|
28
|
+
].filter(Boolean);
|
|
29
|
+
const aggregationPointer = collection.aggregate(filteredPipeline);
|
|
30
|
+
const items = await aggregationPointer.toArray();
|
|
31
|
+
return items;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=find-preserving-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-preserving-ids.js","sourceRoot":"","sources":["../src/find-preserving-ids.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,6BAA6B,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEtD,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,WAAW,GAAG,6BAA6B,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;AAEjF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,CAAI,UAAyB,EAAE,EAAE,CACjC,KAAK,EAAE,QAAe,EAAE,GAAkB,EAAE,OAAqB,EAAqB,EAAE;IACtF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,WAAW,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC1D,MAAM,gBAAgB,GAAG;QACvB,GAAG,QAAQ;QACX,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;KAClB,CAAC;IAEF,MAAM,gBAAgB,GAAG;QACvB;YACE,MAAM,EAAE,gBAAgB;SACzB;QACD,OAAO,IAAI,KAAK,QAAQ;YACtB,OAAO,IAAI,IAAI,IAAI;YACjB,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE;aACxC;SACF;QACH,IAAI,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;QACvB,IAAI,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;QACvB,KAAK,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;KAC3B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAElB,MAAM,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACjD,OAAO,KAAiB,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const DELIMITER = '-';
|
|
2
|
+
const addSuffixToSlug = (slug, index = 1, delimiter = DELIMITER) => {
|
|
3
|
+
return `${slug}${delimiter}${index}`;
|
|
4
|
+
};
|
|
5
|
+
const incrementSuffixedSlug = (slugIncludingSuffix, delimiter = DELIMITER) => {
|
|
6
|
+
const slugParts = slugIncludingSuffix.split(delimiter);
|
|
7
|
+
const suffixedIndex = parseInt(slugParts.pop(), 10);
|
|
8
|
+
const slugWithoutSuffix = slugParts.join(delimiter);
|
|
9
|
+
return addSuffixToSlug(slugWithoutSuffix, suffixedIndex + 1);
|
|
10
|
+
};
|
|
11
|
+
export default (checkSlugIsUniqueFn, { slugify }) => {
|
|
12
|
+
const findUnusedSlug = async ({ title, existingSlug, newSlug }) => {
|
|
13
|
+
const slug = newSlug || existingSlug || `${slugify(title)}`;
|
|
14
|
+
if (!(await checkSlugIsUniqueFn(slug))) {
|
|
15
|
+
const isSlugAlreadySuffixed = !!newSlug;
|
|
16
|
+
return findUnusedSlug({
|
|
17
|
+
newSlug: isSlugAlreadySuffixed ? incrementSuffixedSlug(slug) : addSuffixToSlug(slug),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return slug;
|
|
21
|
+
};
|
|
22
|
+
return findUnusedSlug;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=find-unused-slug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-unused-slug.js","sourceRoot":"","sources":["../src/find-unused-slug.js"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE;IACjE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,mBAAmB,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE;IAC3E,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,eAAe,CAAC,iBAAiB,EAAE,aAAa,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,eAAe,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAClD,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE;QAChE,MAAM,IAAI,GAAG,OAAO,IAAI,YAAY,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5D,IAAI,CAAC,CAAC,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE;YACtC,MAAM,qBAAqB,GAAG,CAAC,CAAC,OAAO,CAAC;YACxC,OAAO,cAAc,CAAC;gBACpB,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;aACrF,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Hashids from 'hashids/cjs';
|
|
2
|
+
const hashids = new Hashids('unchained', 6, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890');
|
|
3
|
+
export default () => {
|
|
4
|
+
const randomNumber = Math.floor(Math.random() * (999999999 - 1)) + 1;
|
|
5
|
+
return hashids.encode(randomNumber);
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=generate-random-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-random-hash.js","sourceRoot":"","sources":["../src/generate-random-hash.js"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAAa,CAAC;AAElC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,sCAAsC,CAAC,CAAC;AAEpF,eAAe,GAAG,EAAE;IAClB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrE,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const systemLocale: any;
|
|
2
|
+
export function resolveBestSupported(acceptLanguage: any, supportedLocales: any): any;
|
|
3
|
+
export function resolveBestCountry(localeCountry: any, shopCountry: any, countries: any): any;
|
|
4
|
+
export function resolveUserRemoteAddress(req: any): {
|
|
5
|
+
remoteAddress: any;
|
|
6
|
+
remotePort: any;
|
|
7
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Locales, Locale } from 'locale';
|
|
2
|
+
const { UNCHAINED_LANG = 'de', UNCHAINED_COUNTRY = 'CH' } = process.env;
|
|
3
|
+
export const systemLocale = new Locale(`${UNCHAINED_LANG}-${UNCHAINED_COUNTRY}`);
|
|
4
|
+
export const resolveBestSupported = (acceptLanguage, supportedLocales) => {
|
|
5
|
+
const acceptLocale = new Locales(acceptLanguage);
|
|
6
|
+
const bestLocale = acceptLocale.best(supportedLocales);
|
|
7
|
+
if (!bestLocale)
|
|
8
|
+
return systemLocale;
|
|
9
|
+
return bestLocale;
|
|
10
|
+
};
|
|
11
|
+
export const resolveBestCountry = (localeCountry, shopCountry, countries) => {
|
|
12
|
+
if (shopCountry) {
|
|
13
|
+
const resolvedCountry = countries.reduce((lastResolved, country) => {
|
|
14
|
+
if (shopCountry === country.isoCode) {
|
|
15
|
+
return country.isoCode;
|
|
16
|
+
}
|
|
17
|
+
return lastResolved;
|
|
18
|
+
}, null);
|
|
19
|
+
if (resolvedCountry) {
|
|
20
|
+
return resolvedCountry;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return localeCountry || systemLocale.country;
|
|
24
|
+
};
|
|
25
|
+
export const resolveUserRemoteAddress = (req) => {
|
|
26
|
+
const remoteAddress = req.headers['x-real-ip'] ||
|
|
27
|
+
req.headers['x-forwarded-for'] ||
|
|
28
|
+
req.connection.remoteAddress ||
|
|
29
|
+
req.socket.remoteAddress ||
|
|
30
|
+
req.connection.socket.remoteAddress;
|
|
31
|
+
const remotePort = req.connection?.remotePort || req.socket?.remotePort || req.connection?.socket?.remotePort;
|
|
32
|
+
return { remoteAddress, remotePort };
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=locale-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-helpers.js","sourceRoot":"","sources":["../src/locale-helpers.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,EAAE,cAAc,GAAG,IAAI,EAAE,iBAAiB,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAExE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,GAAG,cAAc,IAAI,iBAAiB,EAAE,CAAC,CAAC;AAEjF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,gBAAgB,EAAE,EAAE;IACvE,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,CAAC,UAAU;QAAE,OAAO,YAAY,CAAC;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;IAC1E,IAAI,WAAW,EAAE;QACf,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE;YACjE,IAAI,WAAW,KAAK,OAAO,CAAC,OAAO,EAAE;gBACnC,OAAO,OAAO,CAAC,OAAO,CAAC;aACxB;YACD,OAAO,YAAY,CAAC;QACtB,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,eAAe,EAAE;YACnB,OAAO,eAAe,CAAC;SACxB;KACF;IACD,OAAO,aAAa,IAAI,YAAY,CAAC,OAAO,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,EAAE;IAC9C,MAAM,aAAa,GACjB,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC;QACxB,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC9B,GAAG,CAAC,UAAU,CAAC,aAAa;QAC5B,GAAG,CAAC,MAAM,CAAC,aAAa;QACxB,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC;IAEtC,MAAM,UAAU,GACd,GAAG,CAAC,UAAU,EAAE,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC;IAE7F,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC;AACvC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const invertMapObject = (theMapObject) => Object.keys(theMapObject).reduce((invertedObj, key) => {
|
|
2
|
+
const newObj = invertedObj;
|
|
3
|
+
newObj[theMapObject[key]] = key;
|
|
4
|
+
return newObj;
|
|
5
|
+
}, {});
|
|
6
|
+
export default invertMapObject;
|
|
7
|
+
//# sourceMappingURL=object-invert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-invert.js","sourceRoot":"","sources":["../src/object-invert.js"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,EAAE,CACvC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE;IACpD,MAAM,MAAM,GAAG,WAAW,CAAC;IAC3B,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC,EAAE,EAAE,CAAC,CAAC;AAET,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe-promises.js","sourceRoot":"","sources":["../src/pipe-promises.js"],"names":[],"mappings":"AAAA,eAAe,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,EAAE,CACvC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function randomValueHex(len: number): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
export default function randomValueHex(len) {
|
|
3
|
+
return crypto
|
|
4
|
+
.randomBytes(Math.ceil(len / 2))
|
|
5
|
+
.toString('hex') // convert to hexadecimal format
|
|
6
|
+
.slice(0, len); // return required number of characters
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=random-value-hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random-value-hex.js","sourceRoot":"","sources":["../src/random-value-hex.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,GAAW;IAChD,OAAO,MAAM;SACV,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAC/B,QAAQ,CAAC,KAAK,CAAC,CAAC,gCAAgC;SAChD,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,uCAAuC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AddressSchema: any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import SimpleSchema from 'simpl-schema';
|
|
2
|
+
export const AddressSchema = new SimpleSchema({
|
|
3
|
+
firstName: String,
|
|
4
|
+
lastName: String,
|
|
5
|
+
company: String,
|
|
6
|
+
addressLine: String,
|
|
7
|
+
addressLine2: String,
|
|
8
|
+
city: String,
|
|
9
|
+
postalCode: String,
|
|
10
|
+
regionCode: String,
|
|
11
|
+
countryCode: String,
|
|
12
|
+
}, { requiredByDefault: false });
|
|
13
|
+
//# sourceMappingURL=AddressSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddressSchema.js","sourceRoot":"","sources":["../../src/schemas/AddressSchema.js"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C;IACE,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;IACnB,YAAY,EAAE,MAAM;IACpB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,MAAM;CACpB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ContactSchema: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactSchema.js","sourceRoot":"","sources":["../../src/schemas/ContactSchema.js"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,YAAY,CAC3C;IACE,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;CACrB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import SimpleSchema from 'simpl-schema';
|
|
2
|
+
import { AddressSchema } from './AddressSchema';
|
|
3
|
+
import { timestampFields } from './commonSchemaFields';
|
|
4
|
+
const ProfileSchema = new SimpleSchema({
|
|
5
|
+
displayName: String,
|
|
6
|
+
birthday: Date,
|
|
7
|
+
phoneMobile: String,
|
|
8
|
+
gender: String,
|
|
9
|
+
address: AddressSchema,
|
|
10
|
+
}, { requiredByDefault: false });
|
|
11
|
+
export const LastLoginSchema = new SimpleSchema({
|
|
12
|
+
timestamp: Date,
|
|
13
|
+
locale: String,
|
|
14
|
+
countryContext: String,
|
|
15
|
+
remoteAddress: String,
|
|
16
|
+
remotePort: String,
|
|
17
|
+
userAgent: String,
|
|
18
|
+
}, { requiredByDefault: false });
|
|
19
|
+
export const LastContactSchema = new SimpleSchema({
|
|
20
|
+
telNumber: String,
|
|
21
|
+
emailAddress: String,
|
|
22
|
+
}, { requiredByDefault: false });
|
|
23
|
+
export const UserSchema = new SimpleSchema({
|
|
24
|
+
emails: Array,
|
|
25
|
+
'emails.$': Object,
|
|
26
|
+
'emails.$.address': String,
|
|
27
|
+
'emails.$.verified': Boolean,
|
|
28
|
+
username: String,
|
|
29
|
+
lastLogin: LastLoginSchema,
|
|
30
|
+
profile: ProfileSchema,
|
|
31
|
+
lastBillingAddress: AddressSchema,
|
|
32
|
+
lastContact: LastContactSchema,
|
|
33
|
+
guest: Boolean,
|
|
34
|
+
initialPassword: Boolean,
|
|
35
|
+
tags: Array,
|
|
36
|
+
'tags.$': String,
|
|
37
|
+
avatarId: String,
|
|
38
|
+
meta: {
|
|
39
|
+
type: Object,
|
|
40
|
+
optional: true,
|
|
41
|
+
blackbox: true,
|
|
42
|
+
},
|
|
43
|
+
services: {
|
|
44
|
+
type: Object,
|
|
45
|
+
optional: true,
|
|
46
|
+
blackbox: true,
|
|
47
|
+
},
|
|
48
|
+
roles: Array,
|
|
49
|
+
'roles.$': String,
|
|
50
|
+
...timestampFields,
|
|
51
|
+
}, { requiredByDefault: false });
|
|
52
|
+
//# sourceMappingURL=UsersSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UsersSchema.js","sourceRoot":"","sources":["../../src/schemas/UsersSchema.js"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,aAAa,GAAG,IAAI,YAAY,CACpC;IACE,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,aAAa;CACvB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,YAAY,CAC7C;IACE,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,MAAM;IACd,cAAc,EAAE,MAAM;IACtB,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,MAAM;CAClB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,YAAY,CAC/C;IACE,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;CACrB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,YAAY,CACxC;IACE,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,MAAM;IAClB,kBAAkB,EAAE,MAAM;IAC1B,mBAAmB,EAAE,OAAO;IAC5B,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,aAAa;IACtB,kBAAkB,EAAE,aAAa;IACjC,WAAW,EAAE,iBAAiB;IAC9B,KAAK,EAAE,OAAO;IACd,eAAe,EAAE,OAAO;IACxB,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf;IACD,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,MAAM;IACjB,GAAG,eAAe;CACnB,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export namespace contextFields {
|
|
2
|
+
namespace context {
|
|
3
|
+
const type: ObjectConstructor;
|
|
4
|
+
const blackbox: boolean;
|
|
5
|
+
const required: boolean;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export const logFields: {
|
|
9
|
+
log: ArrayConstructor;
|
|
10
|
+
'log.$': {
|
|
11
|
+
type: ObjectConstructor;
|
|
12
|
+
};
|
|
13
|
+
'log.$.date': {
|
|
14
|
+
type: DateConstructor;
|
|
15
|
+
};
|
|
16
|
+
'log.$.status': {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
};
|
|
19
|
+
'log.$.info': {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export namespace timestampFields {
|
|
24
|
+
namespace created {
|
|
25
|
+
const type_1: DateConstructor;
|
|
26
|
+
export { type_1 as type };
|
|
27
|
+
const required_1: boolean;
|
|
28
|
+
export { required_1 as required };
|
|
29
|
+
}
|
|
30
|
+
namespace createdBy {
|
|
31
|
+
const type_2: StringConstructor;
|
|
32
|
+
export { type_2 as type };
|
|
33
|
+
}
|
|
34
|
+
namespace updated {
|
|
35
|
+
const type_3: DateConstructor;
|
|
36
|
+
export { type_3 as type };
|
|
37
|
+
}
|
|
38
|
+
namespace updatedBy {
|
|
39
|
+
const type_4: StringConstructor;
|
|
40
|
+
export { type_4 as type };
|
|
41
|
+
}
|
|
42
|
+
namespace deleted {
|
|
43
|
+
const type_5: DateConstructor;
|
|
44
|
+
export { type_5 as type };
|
|
45
|
+
}
|
|
46
|
+
namespace deletedBy {
|
|
47
|
+
const type_6: StringConstructor;
|
|
48
|
+
export { type_6 as type };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const contextFields = {
|
|
2
|
+
context: {
|
|
3
|
+
type: Object,
|
|
4
|
+
blackbox: true,
|
|
5
|
+
required: false,
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
export const logFields = {
|
|
9
|
+
log: Array,
|
|
10
|
+
'log.$': {
|
|
11
|
+
type: Object,
|
|
12
|
+
},
|
|
13
|
+
'log.$.date': {
|
|
14
|
+
type: Date,
|
|
15
|
+
},
|
|
16
|
+
'log.$.status': {
|
|
17
|
+
type: String,
|
|
18
|
+
},
|
|
19
|
+
'log.$.info': {
|
|
20
|
+
type: String,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export const timestampFields = {
|
|
24
|
+
created: { type: Date, required: true },
|
|
25
|
+
createdBy: { type: String },
|
|
26
|
+
updated: { type: Date },
|
|
27
|
+
updatedBy: { type: String },
|
|
28
|
+
deleted: { type: Date },
|
|
29
|
+
deletedBy: { type: String },
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=commonSchemaFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonSchemaFields.js","sourceRoot":"","sources":["../../src/schemas/commonSchemaFields.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;KACb;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,IAAI;KACX;IACD,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;KACb;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,MAAM;KACb;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACvC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IACvB,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;IACvB,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;CAC5B,CAAC"}
|
package/lib/slugify.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function slugify(text: any): any;
|
package/lib/slugify.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function slugify(text) {
|
|
2
|
+
return text
|
|
3
|
+
.toString()
|
|
4
|
+
.toLowerCase()
|
|
5
|
+
.replace(/\s+/g, '-') // Replace spaces with -
|
|
6
|
+
.replace(/[^\w-]+/g, '') // Remove all non-word chars
|
|
7
|
+
.replace(/--+/g, '-') // Replace multiple - with single -
|
|
8
|
+
.replace(/^-+/, '') // Trim - from start of text
|
|
9
|
+
.replace(/-+$/, ''); // Trim - from end of text
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=slugify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugify.js","sourceRoot":"","sources":["../src/slugify.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI;IAClC,OAAO,IAAI;SACR,QAAQ,EAAE;SACV,WAAW,EAAE;SACb,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,wBAAwB;SAC7C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,4BAA4B;SACpD,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,mCAAmC;SACxD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,4BAA4B;SAC/C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,0BAA0B;AACnD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { default as findLocalizedText } from "./find-localized-text";
|
|
2
|
+
export * from "./locale-helpers";
|
|
3
|
+
export { default as objectInvert } from "./object-invert";
|
|
4
|
+
export { default as findUnusedSlug } from "./find-unused-slug";
|
|
5
|
+
export { default as slugify } from "./slugify";
|
|
6
|
+
export { default as pipePromises } from "./pipe-promises";
|
|
7
|
+
export { default as generateRandomHash } from "./generate-random-hash";
|
|
8
|
+
export { default as randomValueHex } from "./random-value-hex";
|
|
9
|
+
export { default as buildSortOptions } from "./buildSortOption";
|
|
10
|
+
export { checkId } from "./db/check-id";
|
|
11
|
+
export { generateDbObjectId } from "./db/generate-db-object-id";
|
|
12
|
+
export { generateDbFilterById } from "./db/generate-db-filter-by-id";
|
|
13
|
+
export { generateDbMutations } from "./db/generate-db-mutations";
|
|
14
|
+
export { buildDbIndexes } from "./db/build-db-indexes";
|
|
15
|
+
export { findPreservingIds } from "./find-preserving-ids";
|
|
16
|
+
export { BaseAdapter } from "./director/BaseAdapter";
|
|
17
|
+
export { BaseDirector } from "./director/BaseDirector";
|
|
18
|
+
export { BasePricingAdapter } from "./director/BasePricingAdapter";
|
|
19
|
+
export { BasePricingDirector } from "./director/BasePricingDirector";
|
|
20
|
+
export { BasePricingSheet } from "./director/BasePricingSheet";
|
|
21
|
+
export { BaseDiscountAdapter } from "./director/BaseDiscountAdapter";
|
|
22
|
+
export { BaseDiscountDirector } from "./director/BaseDiscountDirector";
|
|
23
|
+
export namespace Schemas {
|
|
24
|
+
export { timestampFields };
|
|
25
|
+
export { contextFields };
|
|
26
|
+
export { logFields };
|
|
27
|
+
export { AddressSchema as Address };
|
|
28
|
+
export { ContactSchema as Contact };
|
|
29
|
+
export { UserSchema as User };
|
|
30
|
+
}
|
|
31
|
+
import { timestampFields } from "./schemas/commonSchemaFields";
|
|
32
|
+
import { contextFields } from "./schemas/commonSchemaFields";
|
|
33
|
+
import { logFields } from "./schemas/commonSchemaFields";
|
|
34
|
+
import { AddressSchema } from "./schemas/AddressSchema";
|
|
35
|
+
import { ContactSchema } from "./schemas/ContactSchema";
|
|
36
|
+
import { UserSchema } from "./schemas/UsersSchema";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AddressSchema } from './schemas/AddressSchema';
|
|
2
|
+
import { ContactSchema } from './schemas/ContactSchema';
|
|
3
|
+
import { timestampFields, contextFields, logFields } from './schemas/commonSchemaFields';
|
|
4
|
+
import { UserSchema } from './schemas/UsersSchema';
|
|
5
|
+
export { default as findLocalizedText } from './find-localized-text';
|
|
6
|
+
export * from './locale-helpers';
|
|
7
|
+
export { default as objectInvert } from './object-invert';
|
|
8
|
+
export { default as findUnusedSlug } from './find-unused-slug';
|
|
9
|
+
export { default as slugify } from './slugify';
|
|
10
|
+
export { default as pipePromises } from './pipe-promises';
|
|
11
|
+
export { default as generateRandomHash } from './generate-random-hash';
|
|
12
|
+
export { default as randomValueHex } from './random-value-hex';
|
|
13
|
+
export { default as buildSortOptions } from './buildSortOption';
|
|
14
|
+
/*
|
|
15
|
+
* Db utils
|
|
16
|
+
*/
|
|
17
|
+
export { checkId } from './db/check-id';
|
|
18
|
+
export { generateDbObjectId } from './db/generate-db-object-id';
|
|
19
|
+
export { generateDbFilterById } from './db/generate-db-filter-by-id';
|
|
20
|
+
export { generateDbMutations } from './db/generate-db-mutations';
|
|
21
|
+
export { buildDbIndexes } from './db/build-db-indexes';
|
|
22
|
+
export { findPreservingIds } from './find-preserving-ids';
|
|
23
|
+
/*
|
|
24
|
+
* Schemas
|
|
25
|
+
*/
|
|
26
|
+
const Schemas = {
|
|
27
|
+
timestampFields,
|
|
28
|
+
contextFields,
|
|
29
|
+
logFields,
|
|
30
|
+
Address: AddressSchema,
|
|
31
|
+
Contact: ContactSchema,
|
|
32
|
+
User: UserSchema,
|
|
33
|
+
};
|
|
34
|
+
export { Schemas };
|
|
35
|
+
/*
|
|
36
|
+
* Director
|
|
37
|
+
*/
|
|
38
|
+
export { BaseAdapter } from './director/BaseAdapter';
|
|
39
|
+
export { BaseDirector } from './director/BaseDirector';
|
|
40
|
+
export { BasePricingAdapter } from './director/BasePricingAdapter';
|
|
41
|
+
export { BasePricingDirector } from './director/BasePricingDirector';
|
|
42
|
+
export { BasePricingSheet } from './director/BasePricingSheet';
|
|
43
|
+
export { BaseDiscountAdapter } from './director/BaseDiscountAdapter';
|
|
44
|
+
export { BaseDiscountDirector } from './director/BaseDiscountDirector';
|
|
45
|
+
//# sourceMappingURL=utils-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-index.js","sourceRoot":"","sources":["../src/utils-index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AAEH,MAAM,OAAO,GAAG;IACd,eAAe;IACf,aAAa;IACb,SAAS;IACT,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unchainedshop/utils",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"main": "lib/utils-index.js",
|
|
5
|
+
"types": "lib/utils-index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rm -rf lib",
|
|
9
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
10
|
+
"watch": "tsc --watch",
|
|
11
|
+
"link:core": "npm link @unchainedshop/types && npm link @unchainedshop/logger",
|
|
12
|
+
"test": "METEOR_PACKAGE_DIRS=../ TEST_CLIENT=0 TEST_WATCH=1 meteor test-packages ./ --driver-package meteortesting:mocha --port 4200"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/unchainedshop/unchained.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"unchained",
|
|
20
|
+
"ecommerce",
|
|
21
|
+
"core"
|
|
22
|
+
],
|
|
23
|
+
"license": "EUPL-1.2",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/unchainedshop/unchained/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@unchainedshop/logger": "latest",
|
|
30
|
+
"abort-controller": "3.0.0",
|
|
31
|
+
"bson": "^4.6.4",
|
|
32
|
+
"hashids": "^2.2.10",
|
|
33
|
+
"locale": "0.1.0",
|
|
34
|
+
"lru-cache": "^7.10.1",
|
|
35
|
+
"simpl-schema": "^1.12.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/mocha": "^9.1.1",
|
|
39
|
+
"@unchainedshop/types": "latest",
|
|
40
|
+
"chai": "^4.3.6",
|
|
41
|
+
"mocha": "^10.0.0",
|
|
42
|
+
"typescript": "^4.7.3"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { assert } from 'chai';
|
|
2
|
+
import { generateDbMutations, Schemas } from 'meteor/unchained:utils';
|
|
3
|
+
import SimpleSchema from 'simpl-schema';
|
|
4
|
+
import { ObjectId } from 'bson';
|
|
5
|
+
|
|
6
|
+
const testUserId = 'user-1234';
|
|
7
|
+
|
|
8
|
+
const testSchema = new SimpleSchema({
|
|
9
|
+
name: String,
|
|
10
|
+
email: { type: String, optional: true },
|
|
11
|
+
users: { type: Array, defaultValue: [] },
|
|
12
|
+
'users.$': String,
|
|
13
|
+
...Schemas.timestampFields,
|
|
14
|
+
}, { requiredByDefault: false });
|
|
15
|
+
|
|
16
|
+
const testCollection = {
|
|
17
|
+
insertOne: () =>
|
|
18
|
+
new Promise((resolve) =>
|
|
19
|
+
resolve({ insertedId: new ObjectId('qwerASFF1234') })
|
|
20
|
+
),
|
|
21
|
+
updateOne: () => new Promise((resolve) => resolve(null)),
|
|
22
|
+
deleteOne: () => new Promise((resolve) => resolve({ deletedCount: 1 })),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('Test generate DB mutations', () => {
|
|
26
|
+
let mutations;
|
|
27
|
+
let docId;
|
|
28
|
+
|
|
29
|
+
it('Create mutations', () => {
|
|
30
|
+
mutations = generateDbMutations(testCollection, testSchema);
|
|
31
|
+
|
|
32
|
+
assert.ok(mutations);
|
|
33
|
+
assert.isDefined(mutations.create);
|
|
34
|
+
assert.isDefined(mutations.update);
|
|
35
|
+
assert.isDefined(mutations.delete);
|
|
36
|
+
});
|
|
37
|
+
it('Run insert mutation', async () => {
|
|
38
|
+
docId = await mutations.create({ name: 'Test name' }, testUserId);
|
|
39
|
+
assert.isDefined(docId);
|
|
40
|
+
|
|
41
|
+
await mutations
|
|
42
|
+
.create({ email: 'test.email@unchained.shop' }, testUserId)
|
|
43
|
+
.catch((error) => {
|
|
44
|
+
const errorDetails = error.details[0];
|
|
45
|
+
assert.equal(error.error, 'validation-error');
|
|
46
|
+
assert.equal(errorDetails.name, 'name');
|
|
47
|
+
assert.equal(errorDetails.message, 'Name is required');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
it('Run update mutation', async () => {
|
|
51
|
+
let result = await mutations.update(
|
|
52
|
+
docId,
|
|
53
|
+
{ $set: { email: 'test.email@unchained.shop' } },
|
|
54
|
+
testUserId
|
|
55
|
+
);
|
|
56
|
+
assert.isUndefined(result);
|
|
57
|
+
|
|
58
|
+
result = await mutations.update(
|
|
59
|
+
docId,
|
|
60
|
+
{ $push: { users: 'Abc-123' } },
|
|
61
|
+
testUserId
|
|
62
|
+
);
|
|
63
|
+
assert.isUndefined(result);
|
|
64
|
+
});
|
|
65
|
+
it('Run delete mutation', async () => {
|
|
66
|
+
const deletedDocs = await mutations.delete(docId, testUserId);
|
|
67
|
+
assert.equal(deletedDocs, 1);
|
|
68
|
+
});
|
|
69
|
+
});
|