@lyxa.ai/core 1.4.60 → 1.4.62

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.
@@ -3,9 +3,15 @@ import { ServiceFlagType, ServiceFlagReasonType } from '../../../utilities/enum'
3
3
  import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
4
4
  import { Admin } from './admin.model';
5
5
  import { ServiceBooking } from './service-booking.model';
6
+ import { User } from './user.model';
7
+ import { Vendor } from './vendor.model';
8
+ import { VendorParent } from './vendor-parent.model';
6
9
  export declare class ServiceFlag extends TimeStamps {
7
10
  serviceBooking: Ref<ServiceBooking>;
8
11
  orderId: string;
12
+ user?: Ref<User>;
13
+ vendor?: Ref<Vendor>;
14
+ vendorParent?: Ref<VendorParent>;
9
15
  flagType: ServiceFlagType;
10
16
  reasonType?: ServiceFlagReasonType;
11
17
  otherReason?: string;
@@ -15,9 +15,15 @@ const enum_1 = require("../../../utilities/enum");
15
15
  const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
16
16
  const admin_model_1 = require("./admin.model");
17
17
  const service_booking_model_1 = require("./service-booking.model");
18
+ const user_model_1 = require("./user.model");
19
+ const vendor_model_1 = require("./vendor.model");
20
+ const vendor_parent_model_1 = require("./vendor-parent.model");
18
21
  let ServiceFlag = class ServiceFlag extends defaultClasses_1.TimeStamps {
19
22
  serviceBooking;
20
23
  orderId;
24
+ user;
25
+ vendor;
26
+ vendorParent;
21
27
  flagType;
22
28
  reasonType;
23
29
  otherReason;
@@ -32,6 +38,18 @@ __decorate([
32
38
  (0, typegoose_1.prop)({ required: true, type: String }),
33
39
  __metadata("design:type", String)
34
40
  ], ServiceFlag.prototype, "orderId", void 0);
41
+ __decorate([
42
+ (0, typegoose_1.prop)({ ref: () => user_model_1.User }),
43
+ __metadata("design:type", Object)
44
+ ], ServiceFlag.prototype, "user", void 0);
45
+ __decorate([
46
+ (0, typegoose_1.prop)({ ref: () => vendor_model_1.Vendor }),
47
+ __metadata("design:type", Object)
48
+ ], ServiceFlag.prototype, "vendor", void 0);
49
+ __decorate([
50
+ (0, typegoose_1.prop)({ ref: () => vendor_parent_model_1.VendorParent }),
51
+ __metadata("design:type", Object)
52
+ ], ServiceFlag.prototype, "vendorParent", void 0);
35
53
  __decorate([
36
54
  (0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.ServiceFlagType }),
37
55
  __metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":"service-flag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-flag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAiF;AACjF,4EAAqE;AACrE,+CAAsC;AACtC,mEAAyD;AAGlD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,2BAAU;IAEnC,cAAc,CAAuB;IAGrC,OAAO,CAAU;IAGjB,QAAQ,CAAmB;IAG3B,UAAU,CAAyB;IAGnC,WAAW,CAAU;IAGrB,SAAS,CAAc;CAC9B,CAAA;AAlBY,kCAAW;AAEhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,sCAAc,EAAE,CAAC;;mDACR;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAe,EAAE,CAAC;;6CAC5B;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,OAAO,EAAE,4BAAqB,CAAC,KAAK,EAAE,CAAC;;+CAChD;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mBAAK,EAAE,CAAC;;8CACG;sBAjBlB,WAAW;IADvB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,CAAC;GACnD,WAAW,CAkBvB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { ServiceFlagType, ServiceFlagReasonType } from '../../../utilities/enum';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Admin } from './admin.model';\nimport { ServiceBooking } from './service-booking.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceFlags' } })\nexport class ServiceFlag extends TimeStamps {\n\t@prop({ required: true, ref: () => ServiceBooking })\n\tpublic serviceBooking!: Ref<ServiceBooking>;\n\n\t@prop({ required: true, type: String })\n\tpublic orderId!: string;\n\n\t@prop({ required: true, type: String, enum: ServiceFlagType })\n\tpublic flagType!: ServiceFlagType;\n\n\t@prop({ type: String, enum: ServiceFlagReasonType, default: ServiceFlagReasonType.OTHER })\n\tpublic reasonType?: ServiceFlagReasonType;\n\n\t@prop({ type: String })\n\tpublic otherReason?: string;\n\n\t@prop({ ref: () => Admin })\n\tpublic flaggedBy?: Ref<Admin>;\n}\n"]}
1
+ {"version":3,"file":"service-flag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-flag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAiF;AACjF,4EAAqE;AACrE,+CAAsC;AACtC,mEAAyD;AACzD,6CAAoC;AACpC,iDAAwC;AACxC,+DAAqD;AAG9C,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,2BAAU;IAEnC,cAAc,CAAuB;IAGrC,OAAO,CAAU;IAGjB,IAAI,CAAa;IAGjB,MAAM,CAAe;IAGrB,YAAY,CAAqB;IAGjC,QAAQ,CAAmB;IAG3B,UAAU,CAAyB;IAGnC,WAAW,CAAU;IAGrB,SAAS,CAAc;CAC9B,CAAA;AA3BY,kCAAW;AAEhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,sCAAc,EAAE,CAAC;;mDACR;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;yCACF;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,qBAAM,EAAE,CAAC;;2CACA;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;iDACM;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAe,EAAE,CAAC;;6CAC5B;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,OAAO,EAAE,4BAAqB,CAAC,KAAK,EAAE,CAAC;;+CAChD;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mBAAK,EAAE,CAAC;;8CACG;sBA1BlB,WAAW;IADvB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,CAAC;GACnD,WAAW,CA2BvB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { ServiceFlagType, ServiceFlagReasonType } from '../../../utilities/enum';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Admin } from './admin.model';\nimport { ServiceBooking } from './service-booking.model';\nimport { User } from './user.model';\nimport { Vendor } from './vendor.model';\nimport { VendorParent } from './vendor-parent.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceFlags' } })\nexport class ServiceFlag extends TimeStamps {\n\t@prop({ required: true, ref: () => ServiceBooking })\n\tpublic serviceBooking!: Ref<ServiceBooking>;\n\n\t@prop({ required: true, type: String })\n\tpublic orderId!: string;\n\n\t@prop({ ref: () => User })\n\tpublic user?: Ref<User>;\n\n\t@prop({ ref: () => Vendor })\n\tpublic vendor?: Ref<Vendor>;\n\n\t@prop({ ref: () => VendorParent })\n\tpublic vendorParent?: Ref<VendorParent>;\n\n\t@prop({ required: true, type: String, enum: ServiceFlagType })\n\tpublic flagType!: ServiceFlagType;\n\n\t@prop({ type: String, enum: ServiceFlagReasonType, default: ServiceFlagReasonType.OTHER })\n\tpublic reasonType?: ServiceFlagReasonType;\n\n\t@prop({ type: String })\n\tpublic otherReason?: string;\n\n\t@prop({ ref: () => Admin })\n\tpublic flaggedBy?: Ref<Admin>;\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.60
25
+ Version: 1.4.62
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.60",
3
+ "version": "1.4.62",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -1,3 +1,6 @@
1
1
  export declare function normalizeObjectIds(query: Record<string, any>, objectIdFields: string[]): void;
2
2
  export declare function normalizeUserPopulate(populate?: any[] | any): void;
3
3
  export declare const normalizeName: (text: string) => string;
4
+ export declare function omitNullish<T extends Record<string, any>>(obj: T): {
5
+ [K in keyof T as T[K] extends null | undefined ? never : K]: T[K];
6
+ };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeName = void 0;
4
4
  exports.normalizeObjectIds = normalizeObjectIds;
5
5
  exports.normalizeUserPopulate = normalizeUserPopulate;
6
+ exports.omitNullish = omitNullish;
6
7
  const typegoose_1 = require("@typegoose/typegoose");
7
8
  const projection_1 = require("./projection");
8
9
  const models_1 = require("../libraries/mongo/models");
@@ -44,4 +45,7 @@ const normalizeName = (text) => text
44
45
  .replace(/[^\p{Letter}\p{Number}\s]/gu, '')
45
46
  .toLowerCase();
46
47
  exports.normalizeName = normalizeName;
48
+ function omitNullish(obj) {
49
+ return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== null && v !== undefined));
50
+ }
47
51
  //# sourceMappingURL=normalize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sourceRoot":"/","sources":["utilities/normalize.ts"],"names":[],"mappings":";;;AAOA,gDAeC;AAOD,sDAeC;AA5CD,oDAAgD;AAChD,6CAA6D;AAC7D,sDAA6D;AAK7D,SAAgB,kBAAkB,CAAC,KAA0B,EAAE,cAAwB;IACtF,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrD,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClG,CAAC;gBACD,IAAI,KAAK,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,CAAC,iBAAiB,EAAE,EAAE,CAAC;KAC9B,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC;KAC1C,WAAW,EAAE,CAAC;AANJ,QAAA,aAAa,iBAMT","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { excludeFields, ProjectionType } from './projection';\nimport { getCoreUserModel } from '../libraries/mongo/models';\n\n/**\n * Converts specific fields in query to ObjectIds safely.\n */\nexport function normalizeObjectIds(query: Record<string, any>, objectIdFields: string[]): void {\n\tfor (const field of objectIdFields) {\n\t\tif (query?.[field]) {\n\t\t\tif (query?.[field]['$in'] || query?.[field]['$nin']) {\n\t\t\t\tif (query?.[field]['$in']) {\n\t\t\t\t\tquery[field]['$in'] = query?.[field]['$in'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t\t}\n\t\t\t\tif (query?.[field]['$nin']) {\n\t\t\t\t\tquery[field]['$nin'] = query?.[field]['$nin'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tquery[field] = new mongoose.Types.ObjectId(query[field]);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Adjusts user population rules:\n * - Excludes sensitive user fields\n * - Populates nested `coreUser`\n */\nexport function normalizeUserPopulate(populate?: any[] | any): void {\n\tif (!Array.isArray(populate)) {\n\t\tpopulate = populate ? [populate] : [];\n\t}\n\n\tconst findUserPopulate = populate.find((populate: any) => populate.path === 'user');\n\n\tif (findUserPopulate) {\n\t\tfindUserPopulate.select = excludeFields(findUserPopulate.select, ProjectionType.USER);\n\t\tfindUserPopulate.populate = {\n\t\t\tpath: 'coreUser',\n\t\t\tselect: '-_id name email profilePhoto',\n\t\t\tmodel: getCoreUserModel(),\n\t\t};\n\t}\n}\n\n/**\n * Normalizes a string by removing diacritics (accents) and punctuation/special chars and converting it to lowercase.\n *\n * @param text - The input string to normalize.\n * @returns The normalized string without accents and punctuation/special chars and in lowercase.\n *\n * @example\n * normalizeName(\"Crème Brûlée\"); // \"creme brulee\"\n * normalizeName(\"São Paulo\"); // \"sao paulo\"\n * normalizeName(\"Ka'ak\"); // \"kaak\"\n */\n// export const normalizeName = (text: string) =>\n// \ttext\n// \t\t.trim()\n// \t\t.normalize('NFD')\n// \t\t.replace(/[\\u0300-\\u036f]/g, '') // remove accents\n// \t\t.replace(/[^a-zA-Z0-9\\s]/g, '') // remove punctuation/special chars\n// \t\t.toLowerCase();\n\nexport const normalizeName = (text: string) =>\n\ttext\n\t\t.trim()\n\t\t.normalize('NFD')\n\t\t.replace(/\\p{Diacritic}/gu, '') // remove accents (Unicode-safe)\n\t\t.replace(/[^\\p{Letter}\\p{Number}\\s]/gu, '') // keep all languages\n\t\t.toLowerCase();\n"]}
1
+ {"version":3,"file":"normalize.js","sourceRoot":"/","sources":["utilities/normalize.ts"],"names":[],"mappings":";;;AAOA,gDAeC;AAOD,sDAeC;AAuCD,kCAMC;AAzFD,oDAAgD;AAChD,6CAA6D;AAC7D,sDAA6D;AAK7D,SAAgB,kBAAkB,CAAC,KAA0B,EAAE,cAAwB;IACtF,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrD,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClG,CAAC;gBACD,IAAI,KAAK,EAAE,CAAC,KAAK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AAE,EAAE,CAAC;KAC9B,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC;KAC1C,WAAW,EAAE,CAAC;AANJ,QAAA,aAAa,iBAMT;AAYjB,SAAgB,WAAW,CAC1B,GAAM;IAIN,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,CAAQ,CAAC;AACxG,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { excludeFields, ProjectionType } from './projection';\nimport { getCoreUserModel } from '../libraries/mongo/models';\n\n/**\n * Converts specific fields in query to ObjectIds safely.\n */\nexport function normalizeObjectIds(query: Record<string, any>, objectIdFields: string[]): void {\n\tfor (const field of objectIdFields) {\n\t\tif (query?.[field]) {\n\t\t\tif (query?.[field]['$in'] || query?.[field]['$nin']) {\n\t\t\t\tif (query?.[field]['$in']) {\n\t\t\t\t\tquery[field]['$in'] = query?.[field]['$in'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t\t}\n\t\t\t\tif (query?.[field]['$nin']) {\n\t\t\t\t\tquery[field]['$nin'] = query?.[field]['$nin'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tquery[field] = new mongoose.Types.ObjectId(query[field]);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Adjusts user population rules:\n * - Excludes sensitive user fields\n * - Populates nested `coreUser`\n */\nexport function normalizeUserPopulate(populate?: any[] | any): void {\n\tif (!Array.isArray(populate)) {\n\t\tpopulate = populate ? [populate] : [];\n\t}\n\n\tconst findUserPopulate = populate.find((populate: any) => populate.path === 'user');\n\n\tif (findUserPopulate) {\n\t\tfindUserPopulate.select = excludeFields(findUserPopulate.select, ProjectionType.USER);\n\t\tfindUserPopulate.populate = {\n\t\t\tpath: 'coreUser',\n\t\t\tselect: '-_id name email profilePhoto',\n\t\t\tmodel: getCoreUserModel(),\n\t\t};\n\t}\n}\n\n/**\n * Normalizes a string by removing diacritics (accents) and punctuation/special chars and converting it to lowercase.\n *\n * @param text - The input string to normalize.\n * @returns The normalized string without accents and punctuation/special chars and in lowercase.\n *\n * @example\n * normalizeName(\"Crème Brûlée\"); // \"creme brulee\"\n * normalizeName(\"São Paulo\"); // \"sao paulo\"\n * normalizeName(\"Ka'ak\"); // \"kaak\"\n */\n// export const normalizeName = (text: string) =>\n// \ttext\n// \t\t.trim()\n// \t\t.normalize('NFD')\n// \t\t.replace(/[\\u0300-\\u036f]/g, '') // remove accents\n// \t\t.replace(/[^a-zA-Z0-9\\s]/g, '') // remove punctuation/special chars\n// \t\t.toLowerCase();\n\nexport const normalizeName = (text: string) =>\n\ttext\n\t\t.trim()\n\t\t.normalize('NFD')\n\t\t.replace(/\\p{Diacritic}/gu, '') // remove accents (Unicode-safe)\n\t\t.replace(/[^\\p{Letter}\\p{Number}\\s]/gu, '') // keep all languages\n\t\t.toLowerCase();\n\n/**\n * Removes null and undefined properties from an object.\n *\n * @param obj - The object to filter\n * @returns A new object with null and undefined properties removed\n *\n * @example\n * const result = omitNullish({ a: 1, b: null, c: undefined, d: 2 });\n * // result: { a: 1, d: 2 }\n */\nexport function omitNullish<T extends Record<string, any>>(\n\tobj: T\n): {\n\t[K in keyof T as T[K] extends null | undefined ? never : K]: T[K];\n} {\n\treturn Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== null && v !== undefined)) as any;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.4.60",
3
+ "version": "1.4.62",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",