@intlayer/backend 5.7.7 → 5.8.0-canary.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.
Files changed (62) hide show
  1. package/dist/cjs/schemas/dictionary.schema.cjs.map +1 -1
  2. package/dist/cjs/schemas/discussion.schema.cjs.map +1 -1
  3. package/dist/cjs/schemas/oAuth2.schema.cjs.map +1 -1
  4. package/dist/cjs/schemas/organization.schema.cjs.map +1 -1
  5. package/dist/cjs/schemas/plans.schema.cjs.map +1 -1
  6. package/dist/cjs/schemas/project.schema.cjs.map +1 -1
  7. package/dist/cjs/schemas/session.schema.cjs.map +1 -1
  8. package/dist/cjs/schemas/tag.schema.cjs.map +1 -1
  9. package/dist/cjs/schemas/user.schema.cjs.map +1 -1
  10. package/dist/cjs/services/organization.service.cjs +1 -2
  11. package/dist/cjs/services/organization.service.cjs.map +1 -1
  12. package/dist/cjs/utils/AI/aiSdk.cjs +1 -2
  13. package/dist/cjs/utils/AI/aiSdk.cjs.map +1 -1
  14. package/dist/cjs/utils/AI/askDocQuestion/embeddings.json +20502 -9216
  15. package/dist/cjs/utils/AI/autocomplete/index.cjs +2 -5
  16. package/dist/cjs/utils/AI/autocomplete/index.cjs.map +1 -1
  17. package/dist/cjs/utils/AI/translateJSON/index.cjs +1 -2
  18. package/dist/cjs/utils/AI/translateJSON/index.cjs.map +1 -1
  19. package/dist/cjs/utils/permissions.cjs +1 -1
  20. package/dist/cjs/utils/permissions.cjs.map +1 -1
  21. package/dist/cjs/utils/rateLimiter.cjs.map +1 -1
  22. package/dist/esm/schemas/dictionary.schema.mjs.map +1 -1
  23. package/dist/esm/schemas/discussion.schema.mjs.map +1 -1
  24. package/dist/esm/schemas/oAuth2.schema.mjs.map +1 -1
  25. package/dist/esm/schemas/organization.schema.mjs.map +1 -1
  26. package/dist/esm/schemas/plans.schema.mjs.map +1 -1
  27. package/dist/esm/schemas/project.schema.mjs.map +1 -1
  28. package/dist/esm/schemas/session.schema.mjs.map +1 -1
  29. package/dist/esm/schemas/tag.schema.mjs.map +1 -1
  30. package/dist/esm/schemas/user.schema.mjs.map +1 -1
  31. package/dist/esm/services/organization.service.mjs +1 -2
  32. package/dist/esm/services/organization.service.mjs.map +1 -1
  33. package/dist/esm/utils/AI/aiSdk.mjs +1 -2
  34. package/dist/esm/utils/AI/aiSdk.mjs.map +1 -1
  35. package/dist/esm/utils/AI/askDocQuestion/embeddings.json +20502 -9216
  36. package/dist/esm/utils/AI/autocomplete/index.mjs +2 -5
  37. package/dist/esm/utils/AI/autocomplete/index.mjs.map +1 -1
  38. package/dist/esm/utils/AI/translateJSON/index.mjs +1 -2
  39. package/dist/esm/utils/AI/translateJSON/index.mjs.map +1 -1
  40. package/dist/esm/utils/permissions.mjs +1 -1
  41. package/dist/esm/utils/permissions.mjs.map +1 -1
  42. package/dist/esm/utils/rateLimiter.mjs.map +1 -1
  43. package/dist/types/models/dictionary.model.d.ts +1 -1
  44. package/dist/types/models/discussion.model.d.ts +1 -1
  45. package/dist/types/models/oAuth2.model.d.ts +1 -1
  46. package/dist/types/schemas/dictionary.schema.d.ts +2 -2
  47. package/dist/types/schemas/discussion.schema.d.ts +2 -2
  48. package/dist/types/schemas/oAuth2.schema.d.ts +2 -2
  49. package/dist/types/schemas/organization.schema.d.ts +2 -2
  50. package/dist/types/schemas/plans.schema.d.ts +2 -2
  51. package/dist/types/schemas/project.schema.d.ts +2 -2
  52. package/dist/types/schemas/session.schema.d.ts +2 -2
  53. package/dist/types/schemas/tag.schema.d.ts +2 -2
  54. package/dist/types/schemas/user.schema.d.ts +2 -2
  55. package/dist/types/services/organization.service.d.ts.map +1 -1
  56. package/dist/types/utils/AI/aiSdk.d.ts +2 -3
  57. package/dist/types/utils/AI/aiSdk.d.ts.map +1 -1
  58. package/dist/types/utils/AI/autocomplete/index.d.ts.map +1 -1
  59. package/dist/types/utils/AI/translateJSON/index.d.ts.map +1 -1
  60. package/dist/types/utils/rateLimiter.d.ts +1 -1
  61. package/dist/types/utils/rateLimiter.d.ts.map +1 -1
  62. package/package.json +20 -20
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/dictionary.schema.ts"],"sourcesContent":["import type {\n DictionarySchema,\n VersionedContentEl,\n} from '@/types/dictionary.types';\nimport { Schema } from 'mongoose';\n\nconst versionedContentElSchema = new Schema<VersionedContentEl>(\n {\n name: {\n type: String,\n },\n description: {\n type: String,\n },\n content: {\n type: Schema.Types.Mixed,\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n\nexport const dictionarySchema = new Schema<DictionarySchema>(\n {\n projectIds: {\n type: [Schema.Types.ObjectId],\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n tags: {\n type: [String],\n default: [],\n },\n content: {\n type: Map,\n of: versionedContentElSchema,\n required: true,\n default: null,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n filePath: {\n type: Map,\n of: String,\n default: null,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAuB;AAEvB,MAAM,2BAA2B,IAAI;AAAA,EACnC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,MAAM,uBAAO,MAAM;AAAA,MACnB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;AAEO,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,MAAM,CAAC,MAAM;AAAA,MACb,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/dictionary.schema.ts"],"sourcesContent":["import type {\n DictionarySchema,\n VersionedContentEl,\n} from '@/types/dictionary.types';\nimport { Schema } from 'mongoose';\n\nconst versionedContentElSchema = new Schema<VersionedContentEl>(\n {\n name: {\n type: String,\n },\n description: {\n type: String,\n },\n content: {\n type: Schema.Types.Mixed,\n required: true,\n },\n },\n {\n timestamps: true,\n }\n);\n\nexport const dictionarySchema = new Schema<DictionarySchema>(\n {\n projectIds: {\n type: [Schema.Types.ObjectId],\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n },\n title: {\n type: String,\n default: '',\n },\n description: {\n type: String,\n default: '',\n },\n tags: {\n type: [String],\n default: [],\n },\n content: {\n type: Map,\n of: versionedContentElSchema,\n required: true,\n default: null,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n filePath: {\n type: Map,\n of: String,\n default: null,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAAuB;AAEvB,MAAM,2BAA2B,IAAI;AAAA,EACnC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACP,MAAM,uBAAO,MAAM;AAAA,MACnB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,EACd;AACF;AAEO,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,MAAM,CAAC,MAAM;AAAA,MACb,SAAS,CAAC;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/discussion.schema.ts"],"sourcesContent":["import type { DiscussionSchema } from '@/types/discussion.types';\nimport { Schema } from 'mongoose';\n\nexport const discussionSchema = new Schema<DiscussionSchema>(\n {\n discutionId: {\n type: String,\n required: true,\n unique: true,\n },\n messages: [\n {\n role: {\n type: String,\n required: true,\n enum: ['user', 'assistant', 'system'],\n },\n content: {\n type: String,\n required: true,\n },\n timestamp: {\n type: Date,\n default: Date.now,\n },\n },\n ],\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'user',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'project',\n required: true,\n },\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'organization',\n required: true,\n },\n title: {\n type: String,\n required: false,\n },\n isArchived: {\n type: Boolean,\n default: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,UAAU;AAAA,UACV,MAAM,CAAC,QAAQ,aAAa,QAAQ;AAAA,QACtC;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,SAAS,KAAK;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/discussion.schema.ts"],"sourcesContent":["import type { DiscussionSchema } from '@/types/discussion.types';\nimport { Schema } from 'mongoose';\n\nexport const discussionSchema = new Schema<DiscussionSchema>(\n {\n discutionId: {\n type: String,\n required: true,\n unique: true,\n },\n messages: [\n {\n role: {\n type: String,\n required: true,\n enum: ['user', 'assistant', 'system'],\n },\n content: {\n type: String,\n required: true,\n },\n timestamp: {\n type: Date,\n default: Date.now,\n },\n },\n ],\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'user',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'project',\n required: true,\n },\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'organization',\n required: true,\n },\n title: {\n type: String,\n required: false,\n },\n isArchived: {\n type: Boolean,\n default: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,mBAAmB,IAAI;AAAA,EAClC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,UACJ,MAAM;AAAA,UACN,UAAU;AAAA,UACV,MAAM,CAAC,QAAQ,aAAa,QAAQ;AAAA,QACtC;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,UAAU;AAAA,QACZ;AAAA,QACA,WAAW;AAAA,UACT,MAAM;AAAA,UACN,SAAS,KAAK;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/oAuth2.schema.ts"],"sourcesContent":["import type { User } from '@/types/user.types';\nimport { Schema } from 'mongoose';\nimport type { Client, Token as TokenType } from 'oauth2-server';\n\nexport type Token = Omit<TokenType, 'client' | 'user'> & {\n clientId: Client['id'];\n userId: User['id'];\n};\n\nexport const accessTokenSchema = new Schema<Token>(\n {\n accessToken: {\n type: String,\n required: true,\n },\n accessTokenExpiresAt: {\n type: Date,\n },\n clientId: {\n type: String,\n ref: 'Project',\n required: true,\n },\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\naccessTokenSchema.index(\n { createdAt: 1 },\n {\n expireAfterSeconds: 60 * 60 * 24 * 10, // 10 Days\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAQhB,MAAM,oBAAoB,IAAI;AAAA,EACnC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,sBAAsB;AAAA,MACpB,MAAM;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEA,kBAAkB;AAAA,EAChB,EAAE,WAAW,EAAE;AAAA,EACf;AAAA,IACE,oBAAoB,KAAK,KAAK,KAAK;AAAA;AAAA,EACrC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/oAuth2.schema.ts"],"sourcesContent":["import type { User } from '@/types/user.types';\nimport { Schema } from 'mongoose';\nimport type { Client, Token as TokenType } from 'oauth2-server';\n\nexport type Token = Omit<TokenType, 'client' | 'user'> & {\n clientId: Client['id'];\n userId: User['id'];\n};\n\nexport const accessTokenSchema = new Schema<Token>(\n {\n accessToken: {\n type: String,\n required: true,\n },\n accessTokenExpiresAt: {\n type: Date,\n },\n clientId: {\n type: String,\n ref: 'Project',\n required: true,\n },\n userId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\naccessTokenSchema.index(\n { createdAt: 1 },\n {\n expireAfterSeconds: 60 * 60 * 24 * 10, // 10 Days\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAQhB,MAAM,oBAAoB,IAAI;AAAA,EACnC;AAAA,IACE,aAAa;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,sBAAsB;AAAA,MACpB,MAAM;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAEA,kBAAkB;AAAA,EAChB,EAAE,WAAW,EAAE;AAAA,EACf;AAAA,IACE,oBAAoB,KAAK,KAAK,KAAK;AAAA;AAAA,EACrC;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/organization.schema.ts"],"sourcesContent":["import { OrganizationSchema } from '@/export';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateOrganization';\nimport { Schema } from 'mongoose';\nimport { planSchema } from './plans.schema';\n\nexport const organizationSchema = new Schema<OrganizationSchema>(\n {\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n plan: {\n type: planSchema,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\n// Add virtual field for id\norganizationSchema.virtual('id').get(function () {\n return this._id.toString();\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kCAIO;AACP,sBAAuB;AACvB,mBAA2B;AAEpB,MAAM,qBAAqB,IAAI;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAGA,mBAAmB,QAAQ,IAAI,EAAE,IAAI,WAAY;AAC/C,SAAO,KAAK,IAAI,SAAS;AAC3B,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/organization.schema.ts"],"sourcesContent":["import { OrganizationSchema } from '@/export';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateOrganization';\nimport { Schema } from 'mongoose';\nimport { planSchema } from './plans.schema';\n\nexport const organizationSchema = new Schema<OrganizationSchema>(\n {\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n plan: {\n type: planSchema,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n\n// Add virtual field for id\norganizationSchema.virtual('id').get(function () {\n return this._id.toString();\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kCAIO;AACP,sBAAuB;AACvB,mBAA2B;AAEpB,MAAM,qBAAqB,IAAI;AAAA,EACpC;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,CAAC,uBAAO,MAAM,QAAQ;AAAA,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAGA,mBAAmB,QAAQ,IAAI,EAAE,IAAI,WAAY;AAC/C,SAAO,KAAK,IAAI,SAAS;AAC3B,CAAC;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/plans.schema.ts"],"sourcesContent":["import type { PlanSchema } from '@/types/plan.types';\nimport { Schema } from 'mongoose';\n\nexport const planSchema = new Schema<PlanSchema>(\n {\n type: {\n type: String,\n required: true,\n enum: ['PREMIUM', 'ENTERPRISE'],\n },\n period: {\n type: String,\n required: true,\n enum: ['MONTHLY', 'YEARLY'],\n default: 'MONTHLY',\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n subscriptionId: {\n type: String,\n required: true,\n },\n customerId: {\n type: String,\n required: true,\n },\n priceId: {\n type: String,\n required: true,\n },\n status: {\n type: String,\n required: true,\n enum: [\n 'active',\n 'canceled',\n 'past_due',\n 'unpaid',\n 'incomplete',\n 'incomplete_expired',\n 'paused',\n 'trialing',\n ],\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,YAAY;AAAA,IAChC;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,QAAQ;AAAA,MAC1B,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/plans.schema.ts"],"sourcesContent":["import type { PlanSchema } from '@/types/plan.types';\nimport { Schema } from 'mongoose';\n\nexport const planSchema = new Schema<PlanSchema>(\n {\n type: {\n type: String,\n required: true,\n enum: ['PREMIUM', 'ENTERPRISE'],\n },\n period: {\n type: String,\n required: true,\n enum: ['MONTHLY', 'YEARLY'],\n default: 'MONTHLY',\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n subscriptionId: {\n type: String,\n required: true,\n },\n customerId: {\n type: String,\n required: true,\n },\n priceId: {\n type: String,\n required: true,\n },\n status: {\n type: String,\n required: true,\n enum: [\n 'active',\n 'canceled',\n 'past_due',\n 'unpaid',\n 'incomplete',\n 'incomplete_expired',\n 'paused',\n 'trialing',\n ],\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,YAAY;AAAA,IAChC;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM,CAAC,WAAW,QAAQ;AAAA,MAC1B,SAAS;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/project.schema.ts"],"sourcesContent":["import type {\n OAuth2Access,\n Project,\n ProjectSchema,\n} from '@/types/project.types';\nimport { Locales } from '@intlayer/config';\nimport type { RenameId } from '@utils/mongoDB/types';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateProject';\nimport { Schema } from 'mongoose';\n\n// Define the oAuth2Access subdocument schema with timestamps\nconst oAuth2AccessSchema = new Schema<RenameId<OAuth2Access>>(\n {\n clientId: { type: String, required: true },\n clientSecret: { type: String, required: true },\n userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },\n name: { type: String, required: true },\n expiresAt: { type: Date },\n accessToken: { type: [String], required: true, default: [] },\n grants: { type: [String], required: true, default: [] },\n },\n {\n timestamps: true,\n }\n);\n\nconst projectConfigSchema = new Schema<Project['configuration']>(\n {\n internationalization: {\n locales: {\n type: [String],\n enum: Object.values(Locales),\n required: true,\n },\n defaultLocale: {\n type: String,\n enum: Object.values(Locales),\n },\n },\n editor: {\n applicationURL: {\n type: String,\n },\n cmsURL: {\n type: String,\n },\n },\n },\n {\n _id: false, // Prevents the generation of an _id field for this subdocument\n }\n);\n\nexport const projectSchema = new Schema<ProjectSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n configuration: projectConfigSchema,\n oAuth2Access: [oAuth2AccessSchema],\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,6BAIO;AACP,sBAAuB;AAGvB,MAAM,qBAAqB,IAAI;AAAA,EAC7B;AAAA,IACE,UAAU,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACzC,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC7C,QAAQ,EAAE,MAAM,uBAAO,MAAM,UAAU,KAAK,QAAQ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A,MAC5B,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/project.schema.ts"],"sourcesContent":["import type {\n OAuth2Access,\n Project,\n ProjectSchema,\n} from '@/types/project.types';\nimport { Locales } from '@intlayer/config';\nimport type { RenameId } from '@utils/mongoDB/types';\nimport {\n MEMBERS_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateProject';\nimport { Schema } from 'mongoose';\n\n// Define the oAuth2Access subdocument schema with timestamps\nconst oAuth2AccessSchema = new Schema<RenameId<OAuth2Access>>(\n {\n clientId: { type: String, required: true },\n clientSecret: { type: String, required: true },\n userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },\n name: { type: String, required: true },\n expiresAt: { type: Date },\n accessToken: { type: [String], required: true, default: [] },\n grants: { type: [String], required: true, default: [] },\n },\n {\n timestamps: true,\n }\n);\n\nconst projectConfigSchema = new Schema<Project['configuration']>(\n {\n internationalization: {\n locales: {\n type: [String],\n enum: Object.values(Locales),\n required: true,\n },\n defaultLocale: {\n type: String,\n enum: Object.values(Locales),\n },\n },\n editor: {\n applicationURL: {\n type: String,\n },\n cmsURL: {\n type: String,\n },\n },\n },\n {\n _id: false, // Prevents the generation of an _id field for this subdocument\n }\n);\n\nexport const projectSchema = new Schema<ProjectSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n name: {\n type: String,\n required: true,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n configuration: projectConfigSchema,\n oAuth2Access: [oAuth2AccessSchema],\n membersIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n adminsIds: {\n type: [Schema.Types.ObjectId],\n ref: 'User',\n required: true,\n minlength: MEMBERS_MIN_LENGTH,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAAwB;AAExB,6BAIO;AACP,sBAAuB;AAGvB,MAAM,qBAAqB,IAAI;AAAA,EAC7B;AAAA,IACE,UAAU,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACzC,cAAc,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IAC7C,QAAQ,EAAE,MAAM,uBAAO,MAAM,UAAU,KAAK,QAAQ,UAAU,KAAK;AAAA,IACnE,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,WAAW,EAAE,MAAM,KAAK;AAAA,IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,UAAU,MAAM,SAAS,CAAC,EAAE;AAAA,IAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,UA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AAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/session.schema.ts"],"sourcesContent":["import { SessionSchema } from '@/export';\nimport { Schema } from 'mongoose';\n\nexport const sessionSchema = new Schema<SessionSchema>(\n {\n activeOrganizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: false,\n },\n activeProjectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,gBAAgB,IAAI;AAAA,EAC/B;AAAA,IACE,sBAAsB;AAAA,MACpB,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/session.schema.ts"],"sourcesContent":["import { SessionSchema } from '@/export';\nimport { Schema } from 'mongoose';\n\nexport const sessionSchema = new Schema<SessionSchema>(\n {\n activeOrganizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: false,\n },\n activeProjectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AAEhB,MAAM,gBAAgB,IAAI;AAAA,EAC/B;AAAA,IACE,sBAAsB;AAAA,MACpB,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/tag.schema.ts"],"sourcesContent":["import type { TagSchema } from '@/types/tag.types';\nimport {\n KEY_MAX_LENGTH,\n KEY_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateTag';\nimport { Schema } from 'mongoose';\n\nexport const tagSchema = new Schema<TagSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n minlength: KEY_MIN_LENGTH,\n maxlength: KEY_MAX_LENGTH,\n },\n name: {\n type: String,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n description: {\n type: String,\n },\n instructions: {\n type: String,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAKO;AACP,sBAAuB;AAEhB,MAAM,YAAY,IAAI;AAAA,EAC3B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,cAAc;AAAA,MACZ,MAAM;AAAA,IACR;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/schemas/tag.schema.ts"],"sourcesContent":["import type { TagSchema } from '@/types/tag.types';\nimport {\n KEY_MAX_LENGTH,\n KEY_MIN_LENGTH,\n NAME_MAX_LENGTH,\n NAME_MIN_LENGTH,\n} from '@utils/validation/validateTag';\nimport { Schema } from 'mongoose';\n\nexport const tagSchema = new Schema<TagSchema>(\n {\n organizationId: {\n type: Schema.Types.ObjectId,\n ref: 'Organization',\n required: true,\n },\n projectId: {\n type: Schema.Types.ObjectId,\n ref: 'Project',\n required: true,\n },\n key: {\n type: String,\n required: true,\n minlength: KEY_MIN_LENGTH,\n maxlength: KEY_MAX_LENGTH,\n },\n name: {\n type: String,\n minlength: NAME_MIN_LENGTH,\n maxlength: NAME_MAX_LENGTH,\n },\n description: {\n type: String,\n },\n instructions: {\n type: String,\n },\n creatorId: {\n type: Schema.Types.ObjectId,\n ref: 'User',\n required: true,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAKO;AACP,sBAAuB;AAEhB,MAAM,YAAY,IAAI;AAAA,EAC3B;AAAA,IACE,gBAAgB;AAAA,MACd,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,cAAc;AAAA,MACZ,MAAM;AAAA,IACR;AAAA,IACA,WAAW;AAAA,MACT,MAAM,uBAAO,MAAM;AAAA,MACnB,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/schemas/user.schema.ts"],"sourcesContent":["import type { UserSchema } from '@/types/user.types';\nimport {\n NAMES_MAX_LENGTH,\n NAMES_MIN_LENGTH,\n} from '@utils/validation/validateUser';\nimport { Schema } from 'mongoose';\nimport validator from 'validator';\n\nexport const userSchema = new Schema<UserSchema>(\n {\n email: {\n type: String,\n required: true,\n unique: true,\n validate: [validator.isEmail, 'Please fill a valid email address'],\n lowercase: true,\n trim: true,\n },\n name: {\n type: String,\n maxlength: NAMES_MAX_LENGTH,\n minlength: NAMES_MIN_LENGTH,\n },\n phone: {\n type: String,\n maxlength: 20,\n },\n\n customerId: {\n type: String,\n required: false,\n },\n\n emailsList: {\n type: {\n newsLetter: {\n type: Boolean,\n default: false,\n },\n },\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAGO;AACP,sBAAuB;AACvB,uBAAsB;AAEf,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,UAAU,CAAC,iBAAAA,QAAU,SAAS,mCAAmC;AAAA,MACjE,WAAW;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,IACb;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,MAAM;AAAA,UACN,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAK;AAClB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":["validator"]}
1
+ {"version":3,"sources":["../../../src/schemas/user.schema.ts"],"sourcesContent":["import type { UserSchema } from '@/types/user.types';\nimport {\n NAMES_MAX_LENGTH,\n NAMES_MIN_LENGTH,\n} from '@utils/validation/validateUser';\nimport { Schema } from 'mongoose';\nimport validator from 'validator';\n\nexport const userSchema = new Schema<UserSchema>(\n {\n email: {\n type: String,\n required: true,\n unique: true,\n validate: [validator.isEmail, 'Please fill a valid email address'],\n lowercase: true,\n trim: true,\n },\n name: {\n type: String,\n maxlength: NAMES_MAX_LENGTH,\n minlength: NAMES_MIN_LENGTH,\n },\n phone: {\n type: String,\n maxlength: 20,\n },\n\n customerId: {\n type: String,\n required: false,\n },\n\n emailsList: {\n type: {\n newsLetter: {\n type: Boolean,\n default: false,\n },\n },\n required: false,\n },\n },\n {\n timestamps: true,\n\n toJSON: {\n virtuals: true, // keep the automatic `id` getter\n versionKey: false, // drop __v\n transform(doc, ret: any) {\n ret.id = ret._id.toString(); // convert _id to id\n delete ret._id; // remove _id\n },\n },\n toObject: {\n virtuals: true,\n transform(doc, ret: any) {\n ret.id = ret._id; // convert _id to id\n delete ret._id; // remove _id\n },\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAGO;AACP,sBAAuB;AACvB,uBAAsB;AAEf,MAAM,aAAa,IAAI;AAAA,EAC5B;AAAA,IACE,OAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,UAAU,CAAC,iBAAAA,QAAU,SAAS,mCAAmC;AAAA,MACjE,WAAW;AAAA,MACX,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AAAA,IACA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,WAAW;AAAA,IACb;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,QACJ,YAAY;AAAA,UACV,MAAM;AAAA,UACN,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA;AAAA,IACE,YAAY;AAAA,IAEZ,QAAQ;AAAA,MACN,UAAU;AAAA;AAAA,MACV,YAAY;AAAA;AAAA,MACZ,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI,IAAI,SAAS;AAC1B,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,UAAU;AAAA,MACV,UAAU,KAAK,KAAU;AACvB,YAAI,KAAK,IAAI;AACb,eAAO,IAAI;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":["validator"]}
@@ -96,8 +96,7 @@ const updatePlan = async (organization, plan) => {
96
96
  }
97
97
  const updateOrganizationResult = await import_organization.OrganizationModel.updateOne(
98
98
  { _id: organization.id },
99
- { $set: { plan: { ...prevPlan, ...plan } } },
100
- { new: true }
99
+ { $set: { plan: { ...prevPlan, ...plan } } }
101
100
  );
102
101
  if (updateOrganizationResult.matchedCount === 0) {
103
102
  throw new import_errors.GenericError("ORGANIZATION_UPDATE_FAILED", {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/organization.service.ts"],"sourcesContent":["import type {\n Organization,\n OrganizationCreationData,\n OrganizationDocument,\n} from '@/types/organization.types';\nimport type { Plan, PlanDocument } from '@/types/plan.types';\nimport { OrganizationModel } from '@models/organization.model';\nimport { GenericError } from '@utils/errors';\nimport type { OrganizationFilters } from '@utils/filtersAndPagination/getOrganizationFiltersAndPagination';\nimport {\n type OrganizationFields,\n validateOrganization,\n} from '@utils/validation/validateOrganization';\nimport type { Types } from 'mongoose';\n\n/**\n * Finds organizations based on filters and pagination options.\n * @param filters - MongoDB filter query.\n * @param skip - Number of documents to skip.\n * @param limit - Number of documents to limit.\n * @returns List of organizations matching the filters.\n */\nexport const findOrganizations = async (\n filters: OrganizationFilters,\n skip: number,\n limit: number\n): Promise<OrganizationDocument[]> =>\n await OrganizationModel.find(filters).skip(skip).limit(limit);\n\n/**\n * Finds an organization by its ID.\n * @param organizationId - The ID of the organization to find.\n * @returns The organization matching the ID.\n */\nexport const getOrganizationById = async (\n organizationId: string | Types.ObjectId\n): Promise<OrganizationDocument> => {\n const organization = await OrganizationModel.findById(organizationId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', { organizationId });\n }\n\n return organization;\n};\n\n/**\n * Counts the total number of organizations that match the filters.\n * @param filters - MongoDB filter query.\n * @returns Total number of organizations.\n */\nexport const countOrganizations = async (\n filters: OrganizationFilters\n): Promise<number> => {\n const result = await OrganizationModel.countDocuments(filters);\n\n if (typeof result === 'undefined') {\n throw new GenericError('ORGANIZATION_COUNT_FAILED', { filters });\n }\n\n return result;\n};\n\n/**\n * Creates a new organization in the database.\n * @param organization - The organization data to create.\n * @returns The created organization.\n */\nexport const createOrganization = async (\n organization: OrganizationCreationData,\n userId: string | Types.ObjectId\n): Promise<OrganizationDocument> => {\n const errors = validateOrganization(organization, ['name']);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('ORGANIZATION_INVALID_FIELDS', { errors });\n }\n\n try {\n const result = await OrganizationModel.create({\n creatorId: userId,\n membersIds: [userId],\n adminsIds: [userId],\n ...organization,\n });\n\n return result;\n } catch (error) {\n throw new GenericError('ORGANIZATION_CREATION_FAILED', {\n error: (error as Error).message,\n });\n }\n};\n\n/**\n * Updates an existing organization in the database by its ID.\n * @param organizationId - The ID of the organization to update.\n * @param organization - The updated organization data.\n * @returns The updated organization.\n */\nexport const updateOrganizationById = async (\n organizationId: string | Types.ObjectId,\n organization: Partial<Organization>\n): Promise<OrganizationDocument> => {\n const updatedKeys = Object.keys(organization) as OrganizationFields;\n const errors = validateOrganization(organization, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('ORGANIZATION_INVALID_FIELDS', {\n organizationId,\n errors,\n });\n }\n\n const result = await OrganizationModel.updateOne(\n { _id: organizationId },\n organization\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', { organizationId });\n }\n\n return await getOrganizationById(organizationId);\n};\n\n/**\n * Deletes an organization from the database by its ID.\n * @param organizationId - The ID of the organization to delete.\n * @returns The result of the deletion operation.\n */\nexport const deleteOrganizationById = async (\n organizationId: string | Types.ObjectId\n): Promise<OrganizationDocument> => {\n const organization =\n await OrganizationModel.findByIdAndDelete(organizationId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', { organizationId });\n }\n\n return organization;\n};\n\n/**\n * Updates an existing plan in the database by its ID.\n * @param planId - The ID of the plan to update.\n * @param plan - The updated plan data.\n * @returns The updated plan.\n */\nexport const updatePlan = async (\n organization: Organization | OrganizationDocument,\n plan: Partial<Plan>\n): Promise<OrganizationDocument | null> => {\n let prevPlan = organization.plan ?? {};\n\n if (typeof (prevPlan as PlanDocument)?.toObject === 'function') {\n prevPlan = (prevPlan as PlanDocument).toObject();\n }\n\n const updateOrganizationResult = await OrganizationModel.updateOne(\n { _id: organization.id },\n { $set: { plan: { ...prevPlan, ...plan } } },\n { new: true }\n );\n\n if (updateOrganizationResult.matchedCount === 0) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization.id,\n });\n }\n\n const updatedOrganization = await getOrganizationById(organization.id);\n\n return updatedOrganization;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAkC;AAClC,oBAA6B;AAE7B,kCAGO;AAUA,MAAM,oBAAoB,OAC/B,SACA,MACA,UAEA,MAAM,sCAAkB,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,KAAK;AAOvD,MAAM,sBAAsB,OACjC,mBACkC;AAClC,QAAM,eAAe,MAAM,sCAAkB,SAAS,cAAc;AAEpE,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,2BAAa,0BAA0B,EAAE,eAAe,CAAC;AAAA,EACrE;AAEA,SAAO;AACT;AAOO,MAAM,qBAAqB,OAChC,YACoB;AACpB,QAAM,SAAS,MAAM,sCAAkB,eAAe,OAAO;AAE7D,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,2BAAa,6BAA6B,EAAE,QAAQ,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAOO,MAAM,qBAAqB,OAChC,cACA,WACkC;AAClC,QAAM,aAAS,kDAAqB,cAAc,CAAC,MAAM,CAAC;AAE1D,MAAI,OAAO,KAAK,MAAM,EAAE,SAAS,GAAG;AAClC,UAAM,IAAI,2BAAa,+BAA+B,EAAE,OAAO,CAAC;AAAA,EAClE;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,sCAAkB,OAAO;AAAA,MAC5C,WAAW;AAAA,MACX,YAAY,CAAC,MAAM;AAAA,MACnB,WAAW,CA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BAA8B;AAAA,MACnD,gBAAgB,aAAa;AAAA,IAC/B,CAAC;AAAA,EACH;AAEA,QAAM,sBAAsB,MAAM,oBAAoB,aAAa,EAAE;AAErE,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/services/organization.service.ts"],"sourcesContent":["import type {\n Organization,\n OrganizationCreationData,\n OrganizationDocument,\n} from '@/types/organization.types';\nimport type { Plan, PlanDocument } from '@/types/plan.types';\nimport { OrganizationModel } from '@models/organization.model';\nimport { GenericError } from '@utils/errors';\nimport type { OrganizationFilters } from '@utils/filtersAndPagination/getOrganizationFiltersAndPagination';\nimport {\n type OrganizationFields,\n validateOrganization,\n} from '@utils/validation/validateOrganization';\nimport type { Types } from 'mongoose';\n\n/**\n * Finds organizations based on filters and pagination options.\n * @param filters - MongoDB filter query.\n * @param skip - Number of documents to skip.\n * @param limit - Number of documents to limit.\n * @returns List of organizations matching the filters.\n */\nexport const findOrganizations = async (\n filters: OrganizationFilters,\n skip: number,\n limit: number\n): Promise<OrganizationDocument[]> =>\n await OrganizationModel.find(filters).skip(skip).limit(limit);\n\n/**\n * Finds an organization by its ID.\n * @param organizationId - The ID of the organization to find.\n * @returns The organization matching the ID.\n */\nexport const getOrganizationById = async (\n organizationId: string | Types.ObjectId\n): Promise<OrganizationDocument> => {\n const organization = await OrganizationModel.findById(organizationId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', { organizationId });\n }\n\n return organization;\n};\n\n/**\n * Counts the total number of organizations that match the filters.\n * @param filters - MongoDB filter query.\n * @returns Total number of organizations.\n */\nexport const countOrganizations = async (\n filters: OrganizationFilters\n): Promise<number> => {\n const result = await OrganizationModel.countDocuments(filters);\n\n if (typeof result === 'undefined') {\n throw new GenericError('ORGANIZATION_COUNT_FAILED', { filters });\n }\n\n return result;\n};\n\n/**\n * Creates a new organization in the database.\n * @param organization - The organization data to create.\n * @returns The created organization.\n */\nexport const createOrganization = async (\n organization: OrganizationCreationData,\n userId: string | Types.ObjectId\n): Promise<OrganizationDocument> => {\n const errors = validateOrganization(organization, ['name']);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('ORGANIZATION_INVALID_FIELDS', { errors });\n }\n\n try {\n const result = await OrganizationModel.create({\n creatorId: userId,\n membersIds: [userId],\n adminsIds: [userId],\n ...organization,\n });\n\n return result;\n } catch (error) {\n throw new GenericError('ORGANIZATION_CREATION_FAILED', {\n error: (error as Error).message,\n });\n }\n};\n\n/**\n * Updates an existing organization in the database by its ID.\n * @param organizationId - The ID of the organization to update.\n * @param organization - The updated organization data.\n * @returns The updated organization.\n */\nexport const updateOrganizationById = async (\n organizationId: string | Types.ObjectId,\n organization: Partial<Organization>\n): Promise<OrganizationDocument> => {\n const updatedKeys = Object.keys(organization) as OrganizationFields;\n const errors = validateOrganization(organization, updatedKeys);\n\n if (Object.keys(errors).length > 0) {\n throw new GenericError('ORGANIZATION_INVALID_FIELDS', {\n organizationId,\n errors,\n });\n }\n\n const result = await OrganizationModel.updateOne(\n { _id: organizationId },\n organization\n );\n\n if (result.matchedCount === 0) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', { organizationId });\n }\n\n return await getOrganizationById(organizationId);\n};\n\n/**\n * Deletes an organization from the database by its ID.\n * @param organizationId - The ID of the organization to delete.\n * @returns The result of the deletion operation.\n */\nexport const deleteOrganizationById = async (\n organizationId: string | Types.ObjectId\n): Promise<OrganizationDocument> => {\n const organization =\n await OrganizationModel.findByIdAndDelete(organizationId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', { organizationId });\n }\n\n return organization;\n};\n\n/**\n * Updates an existing plan in the database by its ID.\n * @param planId - The ID of the plan to update.\n * @param plan - The updated plan data.\n * @returns The updated plan.\n */\nexport const updatePlan = async (\n organization: Organization | OrganizationDocument,\n plan: Partial<Plan>\n): Promise<OrganizationDocument | null> => {\n let prevPlan = organization.plan ?? {};\n\n if (typeof (prevPlan as PlanDocument)?.toObject === 'function') {\n prevPlan = (prevPlan as PlanDocument).toObject();\n }\n\n const updateOrganizationResult = await OrganizationModel.updateOne(\n { _id: organization.id },\n { $set: { plan: { ...prevPlan, ...plan } } }\n );\n\n if (updateOrganizationResult.matchedCount === 0) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization.id,\n });\n }\n\n const updatedOrganization = await getOrganizationById(organization.id);\n\n return updatedOrganization;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAkC;AAClC,oBAA6B;AAE7B,kCAGO;AAUA,MAAM,oBAAoB,OAC/B,SACA,MACA,UAEA,MAAM,sCAAkB,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,KAAK;AAOvD,MAAM,sBAAsB,OACjC,mBACkC;AAClC,QAAM,eAAe,MAAM,sCAAkB,SAAS,cAAc;AAEpE,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,2BAAa,0BAA0B,EAAE,eAAe,CAAC;AAAA,EACrE;AAEA,SAAO;AACT;AAOO,MAAM,qBAAqB,OAChC,YACoB;AACpB,QAAM,SAAS,MAAM,sCAAkB,eAAe,OAAO;AAE7D,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,2BAAa,6BAA6B,EAAE,QAAQ,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAOO,MAAM,qBAAqB,OAChC,cACA,WACkC;AAClC,QAAM,aAAS,kDAAqB,cAAc,CAAC,MAAM,CAAC;AAE1D,MAAI,OAAO,KAAK,MAAM,EAAE,SAAS,GAAG;AAClC,UAAM,IAAI,2BAAa,+BAA+B,EAAE,OAAO,CAAC;AAAA,EAClE;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,sCAAkB,OAAO;AAAA,MAC5C,WAAW;AAAA,MACX,YAAY,CAAC,MAAM;AAAA,MACnB,WAAW,CAAC,MAAM;AAAA,MAClB,GAAG;AAAA,IACL,CAAC;AAED,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AAsB,MAAM,oBAAoB,aAAa,EAAE;AAErE,SAAO;AACT;","names":[]}
@@ -81,7 +81,7 @@ const getModel = (provider, userApiKey, userModel, defaultModel) => {
81
81
  return fallBackModel;
82
82
  };
83
83
  const DEFAULT_PROVIDER = "openai" /* OPENAI */;
84
- const DEFAULT_TEMPERATURE = 0.1;
84
+ const DEFAULT_TEMPERATURE = 1;
85
85
  const getAIConfig = async (res, options) => {
86
86
  const {
87
87
  userOptions,
@@ -147,7 +147,6 @@ const getAIConfig = async (res, options) => {
147
147
  }
148
148
  return {
149
149
  model: languageModel,
150
- maxTokens: protectedOptions.maxTokens,
151
150
  temperature: protectedOptions.temperature
152
151
  };
153
152
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/AI/aiSdk.ts"],"sourcesContent":["import { anthropic, createAnthropic } from '@ai-sdk/anthropic';\nimport { createDeepSeek, deepseek } from '@ai-sdk/deepseek';\nimport { createGoogleGenerativeAI, google } from '@ai-sdk/google';\nimport { createMistral, mistral } from '@ai-sdk/mistral';\nimport { createOpenAI, openai } from '@ai-sdk/openai';\nimport { CoreMessage, generateText } from 'ai';\nimport { Response } from 'express';\n\ntype AnthropicModel = Parameters<typeof anthropic>[0];\ntype DeepSeekModel = Parameters<typeof deepseek>[0];\ntype MistralModel = Parameters<typeof mistral>[0];\ntype OpenAIModel = Parameters<typeof openai>[0];\ntype GoogleModel = Parameters<typeof google>[0];\n\nexport type Messages = CoreMessage[];\n\n/**\n * Supported AI models\n */\nexport type Model =\n | AnthropicModel\n | DeepSeekModel\n | MistralModel\n | OpenAIModel\n | GoogleModel\n | (string & {});\n\n/**\n * Supported AI SDK providers\n */\nexport enum AIProvider {\n OPENAI = 'openai',\n ANTHROPIC = 'anthropic',\n MISTRAL = 'mistral',\n DEEPSEEK = 'deepseek',\n GEMINI = 'gemini',\n}\n\n/**\n * Common options for all AI providers\n */\nexport type AIOptions = {\n provider?: AIProvider;\n model?: Model;\n temperature?: number;\n apiKey?: string;\n applicationContext?: string;\n maxTokens?: number;\n};\n\n// Define the structure of messages used in chat completions\nexport type ChatCompletionRequestMessage = {\n role: 'system' | 'user' | 'assistant'; // The role of the message sender\n content: string; // The text content of the message\n timestamp?: Date; // The timestamp of the message\n};\n\ntype AccessType = 'apiKey' | 'registered_user' | 'premium_user' | 'public';\n\nconst getAPIKey = (\n res: Response,\n accessType: AccessType[],\n aiOptions?: AIOptions\n) => {\n const defaultApiKey = process.env.OPENAI_API_KEY;\n\n if (accessType.includes('public')) {\n return aiOptions?.apiKey ?? defaultApiKey;\n }\n\n if (accessType.includes('apiKey') && aiOptions?.apiKey) {\n return aiOptions?.apiKey;\n }\n\n if (accessType.includes('registered_user') && res.locals.user) {\n return aiOptions?.apiKey ?? defaultApiKey;\n }\n\n // TODO: Implement premium user access\n if (accessType.includes('premium_user') && res.locals.user) {\n return aiOptions?.apiKey ?? defaultApiKey;\n }\n\n return undefined;\n};\n\nconst getModel = (\n provider: AIProvider,\n userApiKey: string,\n userModel?: Model,\n defaultModel?: Model\n): Model => {\n // Set default models based on provider\n let fallBackModel: Model = defaultModel ?? 'chatgpt-4o-latest';\n\n switch (provider) {\n case AIProvider.OPENAI:\n defaultModel = 'chatgpt-4o-latest';\n break;\n case AIProvider.ANTHROPIC:\n defaultModel = 'claude-3-haiku-20240307';\n break;\n case AIProvider.MISTRAL:\n defaultModel = 'mistral-large-latest';\n break;\n case AIProvider.DEEPSEEK:\n defaultModel = 'deepseek-coder';\n break;\n case AIProvider.GEMINI:\n defaultModel = 'gemini-1.5-pro';\n break;\n }\n\n // If the user use his own API, let him use the model he wants\n if (Boolean(userApiKey) && Boolean(userModel)) {\n return userModel!;\n }\n\n if (Boolean(userModel)) {\n throw new Error(\n 'The user should use his own API key to use a custom model'\n );\n }\n\n return fallBackModel;\n};\n\nexport type AIConfig = Parameters<typeof generateText>[0];\n\nconst DEFAULT_PROVIDER: AIProvider = AIProvider.OPENAI as AIProvider;\nconst DEFAULT_TEMPERATURE: number = 0.1;\n\nexport type AIConfigOptions = {\n userOptions?: AIOptions;\n defaultOptions?: AIOptions;\n accessType?: AccessType[];\n};\n\n/**\n * Get AI model configuration based on the selected provider and options\n * This function handles the configuration for different AI providers\n *\n * @param options Configuration options including provider, API keys, models and temperature\n * @returns Configured AI model ready to use with generateText\n */\nexport const getAIConfig = async (\n res: Response,\n options: AIConfigOptions\n): Promise<AIConfig> => {\n const {\n userOptions,\n defaultOptions,\n accessType = ['registered_user'],\n } = options;\n\n const aiOptions = {\n provider: DEFAULT_PROVIDER,\n temperature: DEFAULT_TEMPERATURE,\n ...defaultOptions,\n ...userOptions,\n } satisfies AIOptions;\n\n const apiKey = getAPIKey(res, accessType, aiOptions);\n\n // Check if API key is provided\n if (!apiKey) {\n throw new Error(`API key for ${aiOptions.provider} is missing`);\n }\n\n const selectedModel = getModel(\n aiOptions.provider,\n apiKey,\n aiOptions.model,\n defaultOptions?.model\n );\n\n const protectedOptions = {\n ...aiOptions,\n apiKey,\n model: selectedModel,\n } satisfies AIOptions;\n\n let languageModel: AIConfig['model'];\n\n switch (protectedOptions.provider) {\n case AIProvider.OPENAI: {\n languageModel = createOpenAI({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.ANTHROPIC: {\n languageModel = createAnthropic({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.MISTRAL: {\n languageModel = createMistral({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.DEEPSEEK: {\n languageModel = createDeepSeek({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.GEMINI: {\n languageModel = createGoogleGenerativeAI({\n apiKey,\n })(selectedModel);\n break;\n }\n\n default: {\n throw new Error(`Provider ${protectedOptions.provider} not supported`);\n }\n }\n\n return {\n model: languageModel,\n maxTokens: protectedOptions.maxTokens,\n temperature: protectedOptions.temperature,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2C;AAC3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
1
+ {"version":3,"sources":["../../../../src/utils/AI/aiSdk.ts"],"sourcesContent":["import { anthropic, createAnthropic } from '@ai-sdk/anthropic';\nimport { createDeepSeek, deepseek } from '@ai-sdk/deepseek';\nimport { createGoogleGenerativeAI, google } from '@ai-sdk/google';\nimport { createMistral, mistral } from '@ai-sdk/mistral';\nimport { createOpenAI, openai } from '@ai-sdk/openai';\nimport {\n AssistantModelMessage,\n generateText,\n SystemModelMessage,\n ToolModelMessage,\n UserModelMessage,\n} from 'ai';\nimport { Response } from 'express';\n\ntype AnthropicModel = Parameters<typeof anthropic>[0];\ntype DeepSeekModel = Parameters<typeof deepseek>[0];\ntype MistralModel = Parameters<typeof mistral>[0];\ntype OpenAIModel = Parameters<typeof openai>[0];\ntype GoogleModel = Parameters<typeof google>[0];\n\nexport type Messages = (\n | SystemModelMessage\n | UserModelMessage\n | AssistantModelMessage\n | ToolModelMessage\n)[];\n\n/**\n * Supported AI models\n */\nexport type Model =\n | AnthropicModel\n | DeepSeekModel\n | MistralModel\n | OpenAIModel\n | GoogleModel\n | (string & {});\n\n/**\n * Supported AI SDK providers\n */\nexport enum AIProvider {\n OPENAI = 'openai',\n ANTHROPIC = 'anthropic',\n MISTRAL = 'mistral',\n DEEPSEEK = 'deepseek',\n GEMINI = 'gemini',\n}\n\n/**\n * Common options for all AI providers\n */\nexport type AIOptions = {\n provider?: AIProvider;\n model?: Model;\n temperature?: number;\n apiKey?: string;\n applicationContext?: string;\n};\n\n// Define the structure of messages used in chat completions\nexport type ChatCompletionRequestMessage = {\n role: 'system' | 'user' | 'assistant'; // The role of the message sender\n content: string; // The text content of the message\n timestamp?: Date; // The timestamp of the message\n};\n\ntype AccessType = 'apiKey' | 'registered_user' | 'premium_user' | 'public';\n\nconst getAPIKey = (\n res: Response,\n accessType: AccessType[],\n aiOptions?: AIOptions\n) => {\n const defaultApiKey = process.env.OPENAI_API_KEY;\n\n if (accessType.includes('public')) {\n return aiOptions?.apiKey ?? defaultApiKey;\n }\n\n if (accessType.includes('apiKey') && aiOptions?.apiKey) {\n return aiOptions?.apiKey;\n }\n\n if (accessType.includes('registered_user') && res.locals.user) {\n return aiOptions?.apiKey ?? defaultApiKey;\n }\n\n // TODO: Implement premium user access\n if (accessType.includes('premium_user') && res.locals.user) {\n return aiOptions?.apiKey ?? defaultApiKey;\n }\n\n return undefined;\n};\n\nconst getModel = (\n provider: AIProvider,\n userApiKey: string,\n userModel?: Model,\n defaultModel?: Model\n): Model => {\n // Set default models based on provider\n let fallBackModel: Model = defaultModel ?? 'chatgpt-4o-latest';\n\n switch (provider) {\n case AIProvider.OPENAI:\n defaultModel = 'chatgpt-4o-latest';\n break;\n case AIProvider.ANTHROPIC:\n defaultModel = 'claude-3-haiku-20240307';\n break;\n case AIProvider.MISTRAL:\n defaultModel = 'mistral-large-latest';\n break;\n case AIProvider.DEEPSEEK:\n defaultModel = 'deepseek-coder';\n break;\n case AIProvider.GEMINI:\n defaultModel = 'gemini-1.5-pro';\n break;\n }\n\n // If the user use his own API, let him use the model he wants\n if (Boolean(userApiKey) && Boolean(userModel)) {\n return userModel!;\n }\n\n if (Boolean(userModel)) {\n throw new Error(\n 'The user should use his own API key to use a custom model'\n );\n }\n\n return fallBackModel;\n};\n\nexport type AIConfig = Parameters<typeof generateText>[0];\n\nconst DEFAULT_PROVIDER: AIProvider = AIProvider.OPENAI as AIProvider;\nconst DEFAULT_TEMPERATURE: number = 1; // ChatGPT 5 accept only temperature 1\n\nexport type AIConfigOptions = {\n userOptions?: AIOptions;\n defaultOptions?: AIOptions;\n accessType?: AccessType[];\n};\n\n/**\n * Get AI model configuration based on the selected provider and options\n * This function handles the configuration for different AI providers\n *\n * @param options Configuration options including provider, API keys, models and temperature\n * @returns Configured AI model ready to use with generateText\n */\nexport const getAIConfig = async (\n res: Response,\n options: AIConfigOptions\n): Promise<AIConfig> => {\n const {\n userOptions,\n defaultOptions,\n accessType = ['registered_user'],\n } = options;\n\n const aiOptions = {\n provider: DEFAULT_PROVIDER,\n temperature: DEFAULT_TEMPERATURE,\n ...defaultOptions,\n ...userOptions,\n } satisfies AIOptions;\n\n const apiKey = getAPIKey(res, accessType, aiOptions);\n\n // Check if API key is provided\n if (!apiKey) {\n throw new Error(`API key for ${aiOptions.provider} is missing`);\n }\n\n const selectedModel = getModel(\n aiOptions.provider,\n apiKey,\n aiOptions.model,\n defaultOptions?.model\n );\n\n const protectedOptions = {\n ...aiOptions,\n apiKey,\n model: selectedModel,\n } satisfies AIOptions;\n\n let languageModel: AIConfig['model'];\n\n switch (protectedOptions.provider) {\n case AIProvider.OPENAI: {\n languageModel = createOpenAI({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.ANTHROPIC: {\n languageModel = createAnthropic({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.MISTRAL: {\n languageModel = createMistral({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.DEEPSEEK: {\n languageModel = createDeepSeek({\n apiKey,\n })(selectedModel);\n break;\n }\n\n case AIProvider.GEMINI: {\n languageModel = createGoogleGenerativeAI({\n apiKey,\n })(selectedModel);\n break;\n }\n\n default: {\n throw new Error(`Provider ${protectedOptions.provider} not supported`);\n }\n }\n\n return {\n model: languageModel,\n temperature: protectedOptions.temperature,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA2C;AAC3C,sBAAyC;AACzC,oBAAiD;AACjD,qBAAuC;AACvC,oBAAqC;AAqC9B,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,YAAS;AACT,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,YAAS;AALC,SAAAA;AAAA,GAAA;AA4BZ,MAAM,YAAY,CAChB,KACA,YACA,cACG;AACH,QAAM,gBAAgB,QAAQ,IAAI;AAElC,MAAI,WAAW,SAAS,QAAQ,GAAG;AACjC,WAAO,W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