@cyberskill/shared 1.34.0 → 1.35.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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/nodejs/index.cjs +1 -1
- package/dist/nodejs/index.js +1 -1
- package/dist/nodejs/mongo.cjs +1 -1
- package/dist/nodejs/mongo.js +1 -1
- package/dist/utils/index-nodejs.cjs +1 -1
- package/dist/utils/index-nodejs.js +1 -1
- package/dist/utils/mongoose.cjs +1 -1
- package/dist/utils/mongoose.d.cts +5 -5
- package/dist/utils/mongoose.d.ts +5 -5
- package/dist/utils/mongoose.js +1 -1
- package/package.json +1 -1
package/dist/utils/mongoose.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ declare function generateModel<D extends Partial<C_Document>>({ mongoose, name,
|
|
|
9
9
|
declare function generateSlug(str?: string, options?: I_SlugifyOptions): string;
|
|
10
10
|
declare function generateShortId(uuid: string, length?: number): string;
|
|
11
11
|
declare function generateSlugQuery<D>(slug: string, filters?: T_FilterQuery<D>, id?: string): T_GenerateSlugQueryResponse<D>;
|
|
12
|
-
declare function getMongoGenericFields({ isNew,
|
|
12
|
+
declare function getMongoGenericFields<T extends 'date' | 'string'>({ isNew, returnDateAs, }?: {
|
|
13
13
|
isNew?: boolean;
|
|
14
|
-
|
|
14
|
+
returnDateAs?: T;
|
|
15
15
|
}): {
|
|
16
|
+
id?: string;
|
|
16
17
|
isDel: boolean;
|
|
17
|
-
createdAt: string
|
|
18
|
-
updatedAt: string
|
|
19
|
-
id?: string | undefined;
|
|
18
|
+
createdAt: T extends 'string' ? string : Date;
|
|
19
|
+
updatedAt: T extends 'string' ? string : Date;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { generateModel, generateSchema, generateShortId, generateSlug, generateSlugQuery, getMongoGenericFields };
|
package/dist/utils/mongoose.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=i(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function i(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,i;for(i=0;i<n.length;i++){o=n[i];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}import a from"crypto-js";import u from"mongoose-aggregate-paginate-v2";import c from"mongoose-paginate-v2";import l from"slugify";import{v4 as f}from"uuid";import{format as s}from"date-fns";function g(){return s(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function
|
|
1
|
+
function e(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function r(r){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};var o=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}o.forEach(function(t){e(r,t,n[t])})}return r}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(r){n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}t.push.apply(t,n)}return t}function n(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{t(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,r){if(e==null)return{};var t=i(e,r);var n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){n=a[o];if(r.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;t[n]=e[n]}}return t}function i(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var o,i;for(i=0;i<n.length;i++){o=n[i];if(r.indexOf(o)>=0)continue;t[o]=e[o]}return t}import a from"crypto-js";import u from"mongoose-aggregate-paginate-v2";import c from"mongoose-paginate-v2";import l from"slugify";import{v4 as f}from"uuid";import{format as s}from"date-fns";function g(){return s(new Date,"yyyy-MM-dd HH:mm:ss.SSS")}function v(e,r){r.filter(function(e){return typeof e=="function"}).forEach(function(r){return e.plugin(r)})}function d(e,r){r.forEach(function(r){var t=r.method,n=r.fn;return e.pre(t,n)})}function m(e){return new e.Schema({id:{type:String,default:f,required:!0,unique:!0},isDel:{type:Boolean,default:!1,required:!0}},{timestamps:!0})}function p(e){var r=e.mongoose,t=e.schema,n=e.virtuals,o=n===void 0?[]:n,i=e.standalone,a=i===void 0?!1:i;var u=new r.Schema(t,{strict:!0});return o.forEach(function(e){var r=e.name,t=e.options,n=e.get;var o=u.virtual(r,t);n&&o.get(n)}),a||u.add(m(r)),u}function y(e){var r=e.mongoose,t=e.name,n=e.schema,o=e.pagination,i=o===void 0?!1:o,a=e.aggregate,l=a===void 0?!1:a,f=e.virtuals,s=f===void 0?[]:f,g=e.middlewares,m=g===void 0?[]:g;if(!t)throw new Error("Model name is required.");if(r.models[t])return r.models[t];var y=p({mongoose:r,schema:n,virtuals:s});return v(y,[i&&c,l&&u]),d(y,m),r.model(t,y)}var O=l.default||l;function b(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;var n=t||{},i=n.lower,a=i===void 0?!0:i,u=n.locale,c=u===void 0?"vi":u,l=o(n,["lower","locale"]);return O(e,r({lower:a,locale:c},l))}function h(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:4;return a.SHA256(e).toString(a.enc.Hex).slice(0,r)}function w(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return n(r({},t,o&&{id:{$ne:o}}),{$or:[{slug:e},{slugHistory:e}]})}function j(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.isNew,o=t===void 0?!0:t,i=e.returnDateAs,a=i===void 0?"string":i;var u=a==="string"?g():new Date;return n(r({},o&&{id:f()}),{isDel:!1,createdAt:u,updatedAt:u})}export{u as aggregatePaginate,y as generateModel,p as generateSchema,h as generateShortId,b as generateSlug,w as generateSlugQuery,j as getMongoGenericFields,c as mongoosePaginate};
|