@autofleet/sadot 1.1.15 → 1.2.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/v1/definition/index.cjs +1 -1
- package/dist/api/v1/definition/index.cjs.map +1 -1
- package/dist/api/v1/definition/index.js +1 -1
- package/dist/api/v1/definition/index.js.map +1 -1
- package/dist/api/v1/definition/validations.cjs +1 -1
- package/dist/api/v1/definition/validations.cjs.map +1 -1
- package/dist/api/v1/definition/validations.js +1 -1
- package/dist/api/v1/definition/validations.js.map +1 -1
- package/dist/hooks/enrich.cjs +1 -1
- package/dist/hooks/enrich.cjs.map +1 -1
- package/dist/hooks/enrich.js +1 -1
- package/dist/hooks/enrich.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models/CustomFieldDefinition.cjs +1 -1
- package/dist/models/CustomFieldDefinition.cjs.map +1 -1
- package/dist/models/CustomFieldDefinition.d.cts +4 -0
- package/dist/models/CustomFieldDefinition.d.ts +4 -0
- package/dist/models/CustomFieldDefinition.js +1 -1
- package/dist/models/CustomFieldDefinition.js.map +1 -1
- package/dist/models/CustomFieldEntries.cjs +1 -1
- package/dist/models/CustomFieldEntries.cjs.map +1 -1
- package/dist/models/CustomFieldEntries.js +1 -1
- package/dist/models/CustomFieldEntries.js.map +1 -1
- package/dist/models/CustomFieldModelTypeMap.cjs +2 -0
- package/dist/models/CustomFieldModelTypeMap.cjs.map +1 -0
- package/dist/models/CustomFieldModelTypeMap.d.cts +15 -0
- package/dist/models/CustomFieldModelTypeMap.d.ts +15 -0
- package/dist/models/CustomFieldModelTypeMap.js +2 -0
- package/dist/models/CustomFieldModelTypeMap.js.map +1 -0
- package/dist/models/CustomFieldValue.cjs +1 -1
- package/dist/models/CustomFieldValue.cjs.map +1 -1
- package/dist/models/CustomFieldValue.d.cts +1 -0
- package/dist/models/CustomFieldValue.d.ts +1 -0
- package/dist/models/CustomFieldValue.js +1 -1
- package/dist/models/CustomFieldValue.js.map +1 -1
- package/dist/models/CustomValidator.cjs +1 -1
- package/dist/models/CustomValidator.cjs.map +1 -1
- package/dist/models/CustomValidator.js +1 -1
- package/dist/models/CustomValidator.js.map +1 -1
- package/dist/models/index.cjs +1 -1
- package/dist/models/index.cjs.map +1 -1
- package/dist/models/index.d.cts +3 -2
- package/dist/models/index.d.ts +3 -2
- package/dist/models/index.js +1 -1
- package/dist/models/index.js.map +1 -1
- package/dist/models/tests/AssociatedTestModel.cjs +1 -1
- package/dist/models/tests/AssociatedTestModel.cjs.map +1 -1
- package/dist/models/tests/AssociatedTestModel.js +1 -1
- package/dist/models/tests/AssociatedTestModel.js.map +1 -1
- package/dist/models/tests/TestModel.cjs +1 -1
- package/dist/models/tests/TestModel.cjs.map +1 -1
- package/dist/models/tests/TestModel.js +1 -1
- package/dist/models/tests/TestModel.js.map +1 -1
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs +1 -1
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs.map +1 -1
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js +1 -1
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js.map +1 -1
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs +1 -1
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs.map +1 -1
- package/dist/models/tests/contextAwareModels/ContextTestModel.js +1 -1
- package/dist/models/tests/contextAwareModels/ContextTestModel.js.map +1 -1
- package/dist/repository/definition.cjs +1 -1
- package/dist/repository/definition.cjs.map +1 -1
- package/dist/repository/definition.js +1 -1
- package/dist/repository/definition.js.map +1 -1
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.ts +4 -1
- package/dist/utils/init.cjs +1 -1
- package/dist/utils/init.cjs.map +1 -1
- package/dist/utils/init.js +1 -1
- package/dist/utils/init.js.map +1 -1
- package/package.json +22 -22
- /package/dist/_virtual/{_@oxc-project_runtime@0.103.0 → _@oxc-project_runtime@0.97.0}/helpers/decorate.cjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.103.0 → _@oxc-project_runtime@0.97.0}/helpers/decorate.js +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.103.0 → _@oxc-project_runtime@0.97.0}/helpers/decorateMetadata.cjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.103.0 → _@oxc-project_runtime@0.97.0}/helpers/decorateMetadata.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../utils/logger/index.js";import{CustomFieldDefinitionType as t}from"../utils/constants/index.js";import{CustomValidationTypes as n}from"../utils/validations/validators/index.js";import{sendDimEvent as r}from"../events/index.js";import{InvalidValueError as i,UnsupportedCustomFieldTypeError as a,UnsupportedCustomValidationError as o}from"../errors/index.js";import{validateValue as s}from"../utils/validations/index.js";import{__decorateMetadata as c}from"../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import e from"../utils/logger/index.js";import{CustomFieldDefinitionType as t}from"../utils/constants/index.js";import{CustomValidationTypes as n}from"../utils/validations/validators/index.js";import{sendDimEvent as r}from"../events/index.js";import{InvalidValueError as i,UnsupportedCustomFieldTypeError as a,UnsupportedCustomValidationError as o}from"../errors/index.js";import{validateValue as s}from"../utils/validations/index.js";import{__decorateMetadata as c}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.js";import{__decorate as l}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.js";import u from"./CustomFieldValue.js";import"./index.js";import{AfterSave as d,BeforeCreate as f,Column as p,DataType as m,DefaultScope as h,HasMany as g,Is as _,Model as v,PrimaryKey as y,Table as b}from"sequelize-typescript";var x,S,C,w,T,E;let D=class extends v{static displayNameDefaultValue(e){if(e?.displayName||(e.displayName=e.name),![null,void 0].includes(e.defaultValue)){let t=s(e.defaultValue,e.fieldType,e.validation);if(t.error)throw new i(e.defaultValue,e.name,t.error)}}static afterSaveHandler(e,t){t.transaction?t.transaction.afterCommit(()=>r(e)):r(e)}};l([y,p({type:m.UUID,defaultValue:m.UUIDV4,allowNull:!1}),c(`design:type`,String)],D.prototype,`id`,void 0),l([p({type:m.STRING,allowNull:!1}),c(`design:type`,String)],D.prototype,`name`,void 0),l([p({type:m.STRING}),c(`design:type`,String)],D.prototype,`displayName`,void 0),l([_(`SupportedType`,e=>{if(!Object.values(t).includes(e))throw new a(`"${e}" is not a supported type.`)}),p({type:m.STRING,allowNull:!1}),c(`design:type`,typeof(x=t!==void 0&&t)==`function`?x:Object)],D.prototype,`fieldType`,void 0),l([p({type:m.JSONB}),c(`design:type`,Object)],D.prototype,`validation`,void 0),l([p({type:m.UUID,allowNull:!1}),c(`design:type`,String)],D.prototype,`entityId`,void 0),l([p({type:m.STRING,allowNull:!1}),c(`design:type`,String)],D.prototype,`entityType`,void 0),l([p({type:m.STRING,allowNull:!1}),c(`design:type`,String)],D.prototype,`modelType`,void 0),l([p({type:m.TEXT}),c(`design:type`,String)],D.prototype,`description`,void 0),l([p({type:m.BOOLEAN,defaultValue:!1}),c(`design:type`,Boolean)],D.prototype,`required`,void 0),l([p({type:m.BOOLEAN,defaultValue:!1}),c(`design:type`,Boolean)],D.prototype,`disabled`,void 0),l([p({type:m.JSONB,allowNull:!0}),c(`design:type`,Object)],D.prototype,`defaultValue`,void 0),l([p({type:m.DATE,allowNull:!1}),c(`design:type`,typeof(S=typeof Date<`u`&&Date)==`function`?S:Object)],D.prototype,`createdAt`,void 0),l([p({type:m.DATE,allowNull:!0}),c(`design:type`,typeof(C=typeof Date<`u`&&Date)==`function`?C:Object)],D.prototype,`updatedAt`,void 0),l([p({type:m.DATE,allowNull:!0}),c(`design:type`,typeof(w=typeof Date<`u`&&Date)==`function`?w:Object)],D.prototype,`deletedAt`,void 0),l([p({type:m.BOOLEAN,defaultValue:!1,allowNull:!1}),c(`design:type`,Boolean)],D.prototype,`blockEditingFromUI`,void 0),l([g(()=>u),c(`design:type`,Array)],D.prototype,`values`,void 0),l([f,c(`design:type`,Function),c(`design:paramtypes`,[typeof(T=D!==void 0&&D)==`function`?T:Object]),c(`design:returntype`,void 0)],D,`displayNameDefaultValue`,null),l([d,c(`design:type`,Function),c(`design:paramtypes`,[typeof(E=D!==void 0&&D)==`function`?E:Object,Object]),c(`design:returntype`,void 0)],D,`afterSaveHandler`,null),D=l([h(()=>({where:{disabled:!1}})),b({tableName:`custom_field_definitions`,modelName:`CustomFieldDefinition`,indexes:[{name:`unique_name_model_type`,fields:[`model_type`,`entity_id`,`name`],unique:!0}],timestamps:!0,validate:{validationByType(){if(!this.validation&&n[this.fieldType])throw e.error(`No custom validation for custom field type ${this.fieldType} found`),new o(`Validation provided for "${this.fieldType}" is not supported`)}}})],D);var O=D;export{O as default};
|
|
2
2
|
//# sourceMappingURL=CustomFieldDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldDefinition.js","names":["CustomFieldDefinition","CustomFieldValue"],"sources":["../../src/models/CustomFieldDefinition.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n DataType,\n HasMany,\n PrimaryKey,\n BeforeCreate,\n DefaultScope,\n AfterSave,\n Is,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { CustomFieldDefinitionType } from '../utils/constants';\nimport { CustomValidationTypes } from '../utils/validations/validators';\nimport CustomFieldValue from './
|
|
1
|
+
{"version":3,"file":"CustomFieldDefinition.js","names":["CustomFieldDefinition","CustomFieldValue"],"sources":["../../src/models/CustomFieldDefinition.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n DataType,\n HasMany,\n PrimaryKey,\n BeforeCreate,\n DefaultScope,\n AfterSave,\n Is,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { CustomFieldDefinitionType } from '../utils/constants';\nimport { CustomValidationTypes } from '../utils/validations/validators';\nimport { CustomFieldValue } from '.';\nimport CustomFieldModelTypeMap from './CustomFieldModelTypeMap';\nimport { sendDimEvent } from '../events';\nimport { InvalidValueError, UnsupportedCustomFieldTypeError, UnsupportedCustomValidationError } from '../errors';\nimport logger from '../utils/logger';\nimport { validateValue } from '../utils/validations';\n\n@DefaultScope(() => ({ where: { disabled: false } }))\n@Table({\n tableName: 'custom_field_definitions',\n modelName: 'CustomFieldDefinition',\n indexes: [\n {\n name: 'unique_name_model_type',\n fields: ['model_type', 'entity_id', 'name'],\n unique: true,\n },\n ],\n timestamps: true,\n validate: {\n validationByType(this: CustomFieldDefinition) {\n // Verify the validation is provided if needed\n if (!this.validation && CustomValidationTypes[this.fieldType as keyof typeof CustomValidationTypes]) {\n // TODO: enforce the validation-object schema based on the fieldType\n logger.error(`No custom validation for custom field type ${this.fieldType} found`);\n throw new UnsupportedCustomValidationError(`Validation provided for \"${this.fieldType}\" is not supported`);\n }\n },\n },\n})\nclass CustomFieldDefinition extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUIDV4,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n name!: string;\n\n @Column({\n type: DataType.STRING,\n })\n displayName?: string; // Defaulted to name with beforeCreate hook\n\n @Is('SupportedType', (value) => {\n if (!Object.values(CustomFieldDefinitionType).includes(value as CustomFieldDefinitionType)) {\n throw new UnsupportedCustomFieldTypeError(`\"${value}\" is not a supported type.`);\n }\n })\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n fieldType!: CustomFieldDefinitionType;\n\n @Column({\n type: DataType.JSONB,\n })\n validation?: any;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n entityId!: string; /** Client association entity id */\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n entityType!: string; /** Client association entity type (demand source / fleet / etc.) */\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n modelType!: string; /** Model type. e.g. Vehicle / StopPoint / etc. */\n\n @Column({\n type: DataType.TEXT,\n })\n description?: string;\n\n @Column({\n type: DataType.BOOLEAN,\n defaultValue: false,\n })\n required?: boolean;\n\n @Column({\n type: DataType.BOOLEAN,\n defaultValue: false,\n })\n disabled?: boolean;\n\n @Column({\n type: DataType.JSONB,\n allowNull: true,\n })\n defaultValue?: any;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare deletedAt?: Date;\n\n @Column({\n type: DataType.BOOLEAN,\n defaultValue: false,\n allowNull: false,\n })\n blockEditingFromUI!: boolean;\n\n @HasMany(() => CustomFieldValue)\n declare values: CustomFieldValue[];\n\n // Association added programmatically when useModelTypeMapping is enabled\n declare modelTypeMappings?: CustomFieldModelTypeMap[];\n\n // Virtual property added by enrichWithModelTypeIds\n declare modelTypeIds?: string[];\n\n @BeforeCreate\n static displayNameDefaultValue(instance: CustomFieldDefinition): void {\n if (!instance?.displayName) {\n instance.displayName = instance.name;\n }\n if (![null, undefined].includes(instance.defaultValue)) {\n const isValid = validateValue(instance.defaultValue, instance.fieldType, instance.validation);\n if (isValid.error) {\n throw new InvalidValueError(instance.defaultValue, instance.name, isValid.error);\n }\n }\n }\n\n @AfterSave\n static afterSaveHandler(instance: CustomFieldDefinition, options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance));\n } else {\n sendDimEvent(instance);\n }\n }\n}\n\nexport default CustomFieldDefinition;\n"],"mappings":"y2BAsBA,IAAA,EAAA,cAuBoC,CAAM,CA+GxC,OACO,wBAAwB,EAAuC,CAIpE,GAHK,GAAU,cACb,EAAS,YAAc,EAAS,MAE9B,CAAC,CAAC,KAAM,IAAA,GAAU,CAAC,SAAS,EAAS,aAAa,CAAE,CACtD,IAAM,EAAU,EAAc,EAAS,aAAc,EAAS,UAAW,EAAS,WAAW,CAC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AAC,aAAc,YAAa,OAAO,CAC3C,OAAQ,GACT,CACF,CACD,WAAY,GACZ,SAAU,CACR,kBAA8C,CAE5C,GAAI,CAAC,KAAK,YAAc,EAAsB,KAAK,WAGjD,MADA,EAAO,MAAM,8CAA8C,KAAK,UAAU,QAAQ,CAC5E,IAAI,EAAiC,4BAA4B,KAAK,UAAU,oBAAoB,EAG/G,CACF,CAAC,CAAA,CAAA,EAAA,CAuIF,IAAA,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../utils/validations/index.cjs`),r=require(`../
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../utils/validations/index.cjs`),r=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.cjs`),i=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.cjs`),a=require(`../repository/definition.cjs`);let o=require(`sequelize-typescript`);var s,c,l;let u=class extends o.Model{static afterSaveHandler(e,n){n.transaction?n.transaction.afterCommit(()=>t.sendDimEvent(e[0])):t.sendDimEvent(e[0])}};i.__decorate([o.PrimaryKey,(0,o.Column)({type:o.DataType.UUID,allowNull:!1}),r.__decorateMetadata(`design:type`,String)],u.prototype,`modelId`,void 0),i.__decorate([(0,o.Column)({type:o.DataType.UUID,allowNull:!1}),r.__decorateMetadata(`design:type`,String)],u.prototype,`entityId`,void 0),i.__decorate([(0,o.Column)({type:o.DataType.JSONB,allowNull:!1,defaultValue:{}}),r.__decorateMetadata(`design:type`,typeof(s=typeof Record<`u`&&Record)==`function`?s:Object)],u.prototype,`customFields`,void 0),i.__decorate([(0,o.Column)({type:o.DataType.STRING,allowNull:!1}),r.__decorateMetadata(`design:type`,String)],u.prototype,`modelType`,void 0),i.__decorate([(0,o.Column)({type:o.DataType.DATE,allowNull:!1}),r.__decorateMetadata(`design:type`,typeof(c=typeof Date<`u`&&Date)==`function`?c:Object)],u.prototype,`createdAt`,void 0),i.__decorate([(0,o.Column)({type:o.DataType.DATE,allowNull:!0}),r.__decorateMetadata(`design:type`,typeof(l=typeof Date<`u`&&Date)==`function`?l:Object)],u.prototype,`updatedAt`,void 0),i.__decorate([o.AfterUpsert,r.__decorateMetadata(`design:type`,Function),r.__decorateMetadata(`design:paramtypes`,[Array,Object]),r.__decorateMetadata(`design:returntype`,void 0)],u,`afterSaveHandler`,null),u=i.__decorate([(0,o.Table)({tableName:`custom_field_entries`,modelName:`CustomFieldEntries`,timestamps:!0,indexes:[{name:`idx_cfe_custom_fields`,using:`gin`,operator:`jsonb_path_ops`,fields:[`custom_fields`]}],validate:{async validationByType(){if(!Object.keys(this.customFields??{}).length)return;let e=await a.getCustomFieldDefinitionsDictionary([this]);n.validateInstanceCustomFieldEntries(this,e)}}})],u);var d=u;exports.default=d;
|
|
2
2
|
//# sourceMappingURL=CustomFieldEntries.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldEntries.cjs","names":["CustomFieldEntries","Model","sendDimEvent","PrimaryKey","DataType","AfterUpsert"],"sources":["../../src/models/CustomFieldEntries.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n AfterUpsert,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport * as CustomFieldDefinitionRepo from '../repository/definition';\nimport { validateInstanceCustomFieldEntries } from '../utils/validations';\n\n@Table({\n tableName: 'custom_field_entries',\n modelName: 'CustomFieldEntries',\n timestamps: true,\n indexes: [\n {\n name: 'idx_cfe_custom_fields',\n using: 'gin',\n operator: 'jsonb_path_ops',\n fields: ['custom_fields'],\n },\n ],\n validate: {\n async validationByType(this: CustomFieldEntries) {\n if (!Object.keys(this.customFields ?? {}).length) {\n return;\n }\n\n const definitionsByName = await CustomFieldDefinitionRepo.getCustomFieldDefinitionsDictionary([this]);\n validateInstanceCustomFieldEntries(this, definitionsByName);\n },\n },\n})\nclass CustomFieldEntries extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the model of which this row hold the custom field entries of, e.g. vehicleId / stopPointId / etc. */\n modelId!: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity of which this row hold the custom field entries of, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n defaultValue: {},\n })\n /** A dictionary of customFields and values with the following structure: `{ customFieldName: 'CustomFieldValue' }` */\n customFields!: Record<string, any>;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model which this custom field entry represents. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomFieldEntries[], options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance[0]));\n } else {\n sendDimEvent(instance[0]);\n }\n }\n}\n\nexport default CustomFieldEntries;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomFieldEntries.cjs","names":["CustomFieldEntries","Model","sendDimEvent","PrimaryKey","DataType","AfterUpsert"],"sources":["../../src/models/CustomFieldEntries.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n AfterUpsert,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport * as CustomFieldDefinitionRepo from '../repository/definition';\nimport { validateInstanceCustomFieldEntries } from '../utils/validations';\n\n@Table({\n tableName: 'custom_field_entries',\n modelName: 'CustomFieldEntries',\n timestamps: true,\n indexes: [\n {\n name: 'idx_cfe_custom_fields',\n using: 'gin',\n operator: 'jsonb_path_ops',\n fields: ['custom_fields'],\n },\n ],\n validate: {\n async validationByType(this: CustomFieldEntries) {\n if (!Object.keys(this.customFields ?? {}).length) {\n return;\n }\n\n const definitionsByName = await CustomFieldDefinitionRepo.getCustomFieldDefinitionsDictionary([this]);\n validateInstanceCustomFieldEntries(this, definitionsByName);\n },\n },\n})\nclass CustomFieldEntries extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the model of which this row hold the custom field entries of, e.g. vehicleId / stopPointId / etc. */\n modelId!: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity of which this row hold the custom field entries of, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n defaultValue: {},\n })\n /** A dictionary of customFields and values with the following structure: `{ customFieldName: 'CustomFieldValue' }` */\n customFields!: Record<string, any>;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model which this custom field entry represents. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomFieldEntries[], options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance[0]));\n } else {\n sendDimEvent(instance[0]);\n }\n }\n}\n\nexport default CustomFieldEntries;\n"],"mappings":"yXAaA,IAAA,EAAA,cAuBiCC,EAAAA,KAAM,CA2CrC,OACO,iBAAiB,EAAgC,EAA8B,CAChF,EAAQ,YACV,EAAQ,YAAY,gBAAkBC,EAAAA,aAAa,EAAS,GAAG,CAAC,CAEhE,EAAA,aAAa,EAAS,GAAG,iBA/C5BC,EAAAA,wBACO,CACN,KAAMC,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,sGAIM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EA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validations/index.js";import{
|
|
1
|
+
import{sendDimEvent as e}from"../events/index.js";import{validateInstanceCustomFieldEntries as t}from"../utils/validations/index.js";import{__decorateMetadata as n}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.js";import{__decorate as r}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.js";import{getCustomFieldDefinitionsDictionary as i}from"../repository/definition.js";import{AfterUpsert as a,Column as o,DataType as s,Model as c,PrimaryKey as l,Table as u}from"sequelize-typescript";var d,f,p;let m=class extends c{static afterSaveHandler(t,n){n.transaction?n.transaction.afterCommit(()=>e(t[0])):e(t[0])}};r([l,o({type:s.UUID,allowNull:!1}),n(`design:type`,String)],m.prototype,`modelId`,void 0),r([o({type:s.UUID,allowNull:!1}),n(`design:type`,String)],m.prototype,`entityId`,void 0),r([o({type:s.JSONB,allowNull:!1,defaultValue:{}}),n(`design:type`,typeof(d=typeof Record<`u`&&Record)==`function`?d:Object)],m.prototype,`customFields`,void 0),r([o({type:s.STRING,allowNull:!1}),n(`design:type`,String)],m.prototype,`modelType`,void 0),r([o({type:s.DATE,allowNull:!1}),n(`design:type`,typeof(f=typeof Date<`u`&&Date)==`function`?f:Object)],m.prototype,`createdAt`,void 0),r([o({type:s.DATE,allowNull:!0}),n(`design:type`,typeof(p=typeof Date<`u`&&Date)==`function`?p:Object)],m.prototype,`updatedAt`,void 0),r([a,n(`design:type`,Function),n(`design:paramtypes`,[Array,Object]),n(`design:returntype`,void 0)],m,`afterSaveHandler`,null),m=r([u({tableName:`custom_field_entries`,modelName:`CustomFieldEntries`,timestamps:!0,indexes:[{name:`idx_cfe_custom_fields`,using:`gin`,operator:`jsonb_path_ops`,fields:[`custom_fields`]}],validate:{async validationByType(){if(!Object.keys(this.customFields??{}).length)return;let e=await i([this]);t(this,e)}}})],m);var h=m;export{h as default};
|
|
2
2
|
//# sourceMappingURL=CustomFieldEntries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldEntries.js","names":["CustomFieldEntries","CustomFieldDefinitionRepo.getCustomFieldDefinitionsDictionary"],"sources":["../../src/models/CustomFieldEntries.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n AfterUpsert,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport * as CustomFieldDefinitionRepo from '../repository/definition';\nimport { validateInstanceCustomFieldEntries } from '../utils/validations';\n\n@Table({\n tableName: 'custom_field_entries',\n modelName: 'CustomFieldEntries',\n timestamps: true,\n indexes: [\n {\n name: 'idx_cfe_custom_fields',\n using: 'gin',\n operator: 'jsonb_path_ops',\n fields: ['custom_fields'],\n },\n ],\n validate: {\n async validationByType(this: CustomFieldEntries) {\n if (!Object.keys(this.customFields ?? {}).length) {\n return;\n }\n\n const definitionsByName = await CustomFieldDefinitionRepo.getCustomFieldDefinitionsDictionary([this]);\n validateInstanceCustomFieldEntries(this, definitionsByName);\n },\n },\n})\nclass CustomFieldEntries extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the model of which this row hold the custom field entries of, e.g. vehicleId / stopPointId / etc. */\n modelId!: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity of which this row hold the custom field entries of, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n defaultValue: {},\n })\n /** A dictionary of customFields and values with the following structure: `{ customFieldName: 'CustomFieldValue' }` */\n customFields!: Record<string, any>;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model which this custom field entry represents. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomFieldEntries[], options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance[0]));\n } else {\n sendDimEvent(instance[0]);\n }\n }\n}\n\nexport default CustomFieldEntries;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomFieldEntries.js","names":["CustomFieldEntries","CustomFieldDefinitionRepo.getCustomFieldDefinitionsDictionary"],"sources":["../../src/models/CustomFieldEntries.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n AfterUpsert,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport * as CustomFieldDefinitionRepo from '../repository/definition';\nimport { validateInstanceCustomFieldEntries } from '../utils/validations';\n\n@Table({\n tableName: 'custom_field_entries',\n modelName: 'CustomFieldEntries',\n timestamps: true,\n indexes: [\n {\n name: 'idx_cfe_custom_fields',\n using: 'gin',\n operator: 'jsonb_path_ops',\n fields: ['custom_fields'],\n },\n ],\n validate: {\n async validationByType(this: CustomFieldEntries) {\n if (!Object.keys(this.customFields ?? {}).length) {\n return;\n }\n\n const definitionsByName = await CustomFieldDefinitionRepo.getCustomFieldDefinitionsDictionary([this]);\n validateInstanceCustomFieldEntries(this, definitionsByName);\n },\n },\n})\nclass CustomFieldEntries extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the model of which this row hold the custom field entries of, e.g. vehicleId / stopPointId / etc. */\n modelId!: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity of which this row hold the custom field entries of, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n defaultValue: {},\n })\n /** A dictionary of customFields and values with the following structure: `{ customFieldName: 'CustomFieldValue' }` */\n customFields!: Record<string, any>;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model which this custom field entry represents. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomFieldEntries[], options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance[0]));\n } else {\n sendDimEvent(instance[0]);\n }\n }\n}\n\nexport default CustomFieldEntries;\n"],"mappings":"whBAaA,IAAA,EAAA,cAuBiC,CAAM,CA2CrC,OACO,iBAAiB,EAAgC,EAA8B,CAChF,EAAQ,YACV,EAAQ,YAAY,gBAAkB,EAAa,EAAS,GAAG,CAAC,CAEhE,EAAa,EAAS,GAAG,MA/C5B,EACA,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,2DAID,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,WAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,MACf,UAAW,GACX,aAAc,EAAE,CACjB,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,OAAA,KAAA,SAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,eAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,OACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAGD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAGD,iIAlEF,EAAM,CACL,UAAW,uBACX,UAAW,qBACX,WAAY,GACZ,QAAS,CACP,CACE,KAAM,wBACN,MAAO,MACP,SAAU,iBACV,OAAQ,CAAC,gBAAgB,CAC1B,CACF,CACD,SAAU,CACR,MAAM,kBAA2C,CAC/C,GAAI,CAAC,OAAO,KAAK,KAAK,cAAgB,EAAE,CAAC,CAAC,OACxC,OAGF,IAAM,EAAoB,MAAMC,EAA8D,CAAC,KAAK,CAAC,CACrG,EAAmC,KAAM,EAAkB,EAE9D,CACF,CAAC,CAAA,CAAA,EAAA,CAsDF,IAAA,EAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.cjs`),n=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.cjs`),r=require(`./CustomFieldDefinition.cjs`);let i=require(`sequelize-typescript`);var a,o;let s=class extends i.Model{};n.__decorate([i.PrimaryKey,(0,i.Column)({type:i.DataType.UUID,defaultValue:i.DataType.UUIDV4,allowNull:!1}),t.__decorateMetadata(`design:type`,String)],s.prototype,`id`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.UUID,allowNull:!1}),t.__decorateMetadata(`design:type`,String)],s.prototype,`modelTypeId`,void 0),n.__decorate([(0,i.ForeignKey)(()=>r.default),(0,i.Column)({type:i.DataType.UUID,allowNull:!1}),t.__decorateMetadata(`design:type`,String)],s.prototype,`customFieldDefinitionId`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.DATE,allowNull:!1}),t.__decorateMetadata(`design:type`,typeof(a=typeof Date<`u`&&Date)==`function`?a:Object)],s.prototype,`createdAt`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.DATE,allowNull:!1}),t.__decorateMetadata(`design:type`,typeof(o=typeof Date<`u`&&Date)==`function`?o:Object)],s.prototype,`updatedAt`,void 0),s=n.__decorate([(0,i.Table)({tableName:`custom_field_model_type_map`,modelName:`CustomFieldModelTypeMap`,indexes:[{name:`unique_model_type_custom_field`,fields:[`model_type_id`,`custom_field_definition_id`],unique:!0},{name:`idx_custom_field_model_type_map_definition_id`,fields:[`custom_field_definition_id`]},{name:`idx_custom_field_model_type_map_type_id`,fields:[`model_type_id`]}],timestamps:!0})],s);var c=s;exports.default=c;
|
|
2
|
+
//# sourceMappingURL=CustomFieldModelTypeMap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomFieldModelTypeMap.cjs","names":["CustomFieldModelTypeMap","Model","PrimaryKey","DataType","CustomFieldDefinition"],"sources":["../../src/models/CustomFieldModelTypeMap.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n DataType,\n PrimaryKey,\n ForeignKey,\n} from 'sequelize-typescript';\nimport CustomFieldDefinition from './CustomFieldDefinition';\n\n@Table({\n tableName: 'custom_field_model_type_map',\n modelName: 'CustomFieldModelTypeMap',\n indexes: [\n {\n name: 'unique_model_type_custom_field',\n fields: ['model_type_id', 'custom_field_definition_id'],\n unique: true,\n },\n {\n name: 'idx_custom_field_model_type_map_definition_id',\n fields: ['custom_field_definition_id'],\n },\n {\n name: 'idx_custom_field_model_type_map_type_id',\n fields: ['model_type_id'],\n },\n ],\n timestamps: true,\n})\nclass CustomFieldModelTypeMap extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUIDV4,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n modelTypeId!: string;\n\n @ForeignKey(() => CustomFieldDefinition)\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n customFieldDefinitionId!: string;\n\n // Association added programmatically in initTables\n declare customFieldDefinition: CustomFieldDefinition;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare updatedAt?: Date;\n}\n\nexport default CustomFieldModelTypeMap;\n"],"mappings":"ySAUA,IAAA,EAAA,cAoBsCC,EAAAA,KAAM,iBACzCC,EAAAA,wBACO,CACN,KAAMC,EAAAA,SAAS,KACf,aAAcA,EAAAA,SAAS,OACvB,UAAW,GACZ,CAAC,iGAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,oCAGgBC,EAAAA,QAAsB,cAChC,CACN,KAAMD,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,sHAMM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,6BAtDG,CACL,UAAW,8BACX,UAAW,0BACX,QAAS,CACP,CACE,KAAM,iCACN,OAAQ,CAAC,gBAAiB,6BAA6B,CACvD,OAAQ,GACT,CACD,CACE,KAAM,gDACN,OAAQ,CAAC,6BAA6B,CACvC,CACD,CACE,KAAM,0CACN,OAAQ,CAAC,gBAAgB,CAC1B,CACF,CACD,WAAY,GACb,CAAC,CAAA,CAAA,EAAA,CAuCF,IAAA,EAAe"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CustomFieldDefinition } from "./CustomFieldDefinition.cjs";
|
|
2
|
+
import { Model } from "sequelize-typescript";
|
|
3
|
+
|
|
4
|
+
//#region src/models/CustomFieldModelTypeMap.d.ts
|
|
5
|
+
declare class CustomFieldModelTypeMap extends Model {
|
|
6
|
+
id: string;
|
|
7
|
+
modelTypeId: string;
|
|
8
|
+
customFieldDefinitionId: string;
|
|
9
|
+
customFieldDefinition: CustomFieldDefinition;
|
|
10
|
+
createdAt?: Date;
|
|
11
|
+
updatedAt?: Date;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CustomFieldModelTypeMap };
|
|
15
|
+
//# sourceMappingURL=CustomFieldModelTypeMap.d.cts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CustomFieldDefinition } from "./CustomFieldDefinition.js";
|
|
2
|
+
import { Model } from "sequelize-typescript";
|
|
3
|
+
|
|
4
|
+
//#region src/models/CustomFieldModelTypeMap.d.ts
|
|
5
|
+
declare class CustomFieldModelTypeMap extends Model {
|
|
6
|
+
id: string;
|
|
7
|
+
modelTypeId: string;
|
|
8
|
+
customFieldDefinitionId: string;
|
|
9
|
+
customFieldDefinition: CustomFieldDefinition;
|
|
10
|
+
createdAt?: Date;
|
|
11
|
+
updatedAt?: Date;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CustomFieldModelTypeMap };
|
|
15
|
+
//# sourceMappingURL=CustomFieldModelTypeMap.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.js";import{__decorate as t}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.js";import n from"./CustomFieldDefinition.js";import{Column as r,DataType as i,ForeignKey as a,Model as o,PrimaryKey as s,Table as c}from"sequelize-typescript";var l,u;let d=class extends o{};t([s,r({type:i.UUID,defaultValue:i.UUIDV4,allowNull:!1}),e(`design:type`,String)],d.prototype,`id`,void 0),t([r({type:i.UUID,allowNull:!1}),e(`design:type`,String)],d.prototype,`modelTypeId`,void 0),t([a(()=>n),r({type:i.UUID,allowNull:!1}),e(`design:type`,String)],d.prototype,`customFieldDefinitionId`,void 0),t([r({type:i.DATE,allowNull:!1}),e(`design:type`,typeof(l=typeof Date<`u`&&Date)==`function`?l:Object)],d.prototype,`createdAt`,void 0),t([r({type:i.DATE,allowNull:!1}),e(`design:type`,typeof(u=typeof Date<`u`&&Date)==`function`?u:Object)],d.prototype,`updatedAt`,void 0),d=t([c({tableName:`custom_field_model_type_map`,modelName:`CustomFieldModelTypeMap`,indexes:[{name:`unique_model_type_custom_field`,fields:[`model_type_id`,`custom_field_definition_id`],unique:!0},{name:`idx_custom_field_model_type_map_definition_id`,fields:[`custom_field_definition_id`]},{name:`idx_custom_field_model_type_map_type_id`,fields:[`model_type_id`]}],timestamps:!0})],d);var f=d;export{f as default};
|
|
2
|
+
//# sourceMappingURL=CustomFieldModelTypeMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomFieldModelTypeMap.js","names":["CustomFieldModelTypeMap","CustomFieldDefinition"],"sources":["../../src/models/CustomFieldModelTypeMap.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n DataType,\n PrimaryKey,\n ForeignKey,\n} from 'sequelize-typescript';\nimport CustomFieldDefinition from './CustomFieldDefinition';\n\n@Table({\n tableName: 'custom_field_model_type_map',\n modelName: 'CustomFieldModelTypeMap',\n indexes: [\n {\n name: 'unique_model_type_custom_field',\n fields: ['model_type_id', 'custom_field_definition_id'],\n unique: true,\n },\n {\n name: 'idx_custom_field_model_type_map_definition_id',\n fields: ['custom_field_definition_id'],\n },\n {\n name: 'idx_custom_field_model_type_map_type_id',\n fields: ['model_type_id'],\n },\n ],\n timestamps: true,\n})\nclass CustomFieldModelTypeMap extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n defaultValue: DataType.UUIDV4,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n modelTypeId!: string;\n\n @ForeignKey(() => CustomFieldDefinition)\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n customFieldDefinitionId!: string;\n\n // Association added programmatically in initTables\n declare customFieldDefinition: CustomFieldDefinition;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare updatedAt?: Date;\n}\n\nexport default CustomFieldModelTypeMap;\n"],"mappings":"wWAUA,IAAA,EAAA,cAoBsC,CAAM,MACzC,EACA,EAAO,CACN,KAAM,EAAS,KACf,aAAc,EAAS,OACvB,UAAW,GACZ,CAAC,sDAGD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,IAGD,MAAiBC,EAAsB,CACvC,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,2EAMD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAGD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,MAtDH,EAAM,CACL,UAAW,8BACX,UAAW,0BACX,QAAS,CACP,CACE,KAAM,iCACN,OAAQ,CAAC,gBAAiB,6BAA6B,CACvD,OAAQ,GACT,CACD,CACE,KAAM,gDACN,OAAQ,CAAC,6BAA6B,CACvC,CACD,CACE,KAAM,0CACN,OAAQ,CAAC,gBAAgB,CAC1B,CACF,CACD,WAAY,GACb,CAAC,CAAA,CAAA,EAAA,CAuCF,IAAA,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../errors/index.cjs`),r=require(`../utils/validations/index.cjs`),i=require(`../
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../errors/index.cjs`),r=require(`../utils/validations/index.cjs`),i=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.cjs`),a=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.cjs`),o=require(`./CustomFieldDefinition.cjs`),s=require(`../repository/definition.cjs`);require(`./index.cjs`);let c=require(`sequelize-typescript`);var l,u,d,f,p;let m=class extends c.Model{static validateValueAgainstDefinition(e,t){let{validation:i,fieldType:a,name:o}=t;if(!r.validateFieldType(a))throw new n.InvalidFieldTypeError(a);if(e.value===null)return;let s=r.validateValue(e.value,a,i);if(s.error)throw new n.InvalidValueError(e.value,o,s.error)}static async validateCustomFieldValues(e){let t=e.map(e=>e.customFieldDefinitionId),n=[...new Set(t)],r=await s.findByIds(n,{withDisabled:!0});if(!r||r.length!==n.length)throw Error(`Definitions not found`);e.forEach(e=>{let t=r.find(t=>t.id===e.customFieldDefinitionId);t&&this.validateValueAgainstDefinition(e,t)})}static async validateCustomFieldValue(e){let{customFieldDefinitionId:t}=e,n=await s.findById(t,{withDisabled:!0});this.validateValueAgainstDefinition(e,n)}static afterSaveHandler(e,n){n.transaction?n.transaction.afterCommit(()=>t.sendDimEvent(e[0])):t.sendDimEvent(e[0])}};a.__decorate([c.PrimaryKey,(0,c.Column)({type:c.DataType.UUID,allowNull:!1}),i.__decorateMetadata(`design:type`,String)],m.prototype,`modelId`,void 0),a.__decorate([c.PrimaryKey,(0,c.ForeignKey)(()=>o.default),(0,c.Column)({type:c.DataType.UUID,allowNull:!1}),i.__decorateMetadata(`design:type`,String)],m.prototype,`customFieldDefinitionId`,void 0),a.__decorate([(0,c.Column)({type:c.DataType.JSONB,allowNull:!0}),i.__decorateMetadata(`design:type`,Object)],m.prototype,`value`,void 0),a.__decorate([(0,c.Column)({type:c.DataType.DATE,allowNull:!1}),i.__decorateMetadata(`design:type`,typeof(l=typeof Date<`u`&&Date)==`function`?l:Object)],m.prototype,`createdAt`,void 0),a.__decorate([(0,c.Column)({type:c.DataType.DATE,allowNull:!0}),i.__decorateMetadata(`design:type`,typeof(u=typeof Date<`u`&&Date)==`function`?u:Object)],m.prototype,`updatedAt`,void 0),a.__decorate([(0,c.Column)({type:c.DataType.DATE,allowNull:!0}),i.__decorateMetadata(`design:type`,typeof(d=typeof Date<`u`&&Date)==`function`?d:Object)],m.prototype,`deletedAt`,void 0),a.__decorate([(0,c.BelongsTo)(()=>o.default,{scope:{disabled:!1}}),i.__decorateMetadata(`design:type`,typeof(f=o.default!==void 0&&o.default)==`function`?f:Object)],m.prototype,`customFieldDefinition`,void 0),a.__decorate([c.BeforeBulkCreate,c.BeforeBulkUpdate,i.__decorateMetadata(`design:type`,Function),i.__decorateMetadata(`design:paramtypes`,[Array]),i.__decorateMetadata(`design:returntype`,Promise)],m,`validateCustomFieldValues`,null),a.__decorate([c.BeforeUpdate,c.BeforeCreate,c.BeforeUpsert,i.__decorateMetadata(`design:type`,Function),i.__decorateMetadata(`design:paramtypes`,[typeof(p=m!==void 0&&m)==`function`?p:Object]),i.__decorateMetadata(`design:returntype`,Promise)],m,`validateCustomFieldValue`,null),a.__decorate([c.AfterUpsert,i.__decorateMetadata(`design:type`,Function),i.__decorateMetadata(`design:paramtypes`,[Array,Object]),i.__decorateMetadata(`design:returntype`,void 0)],m,`afterSaveHandler`,null),m=a.__decorate([(0,c.Table)({tableName:`custom_field_values`,modelName:`CustomFieldValue`,timestamps:!0})],m);var h=m;exports.default=h;
|
|
2
2
|
//# sourceMappingURL=CustomFieldValue.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldValue.cjs","names":["CustomFieldValue","Model","validateFieldType","InvalidFieldTypeError","validateValue","InvalidValueError","sendDimEvent","PrimaryKey","DataType","CustomFieldDefinition","BeforeBulkCreate","BeforeBulkUpdate","BeforeUpdate","BeforeCreate","BeforeUpsert","AfterUpsert"],"sources":["../../src/models/CustomFieldValue.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n BelongsTo,\n ForeignKey,\n BeforeCreate,\n BeforeUpsert,\n AfterUpsert,\n BeforeUpdate,\n BeforeBulkCreate,\n BeforeBulkUpdate,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport CustomFieldDefinition from '
|
|
1
|
+
{"version":3,"file":"CustomFieldValue.cjs","names":["CustomFieldValue","Model","validateFieldType","InvalidFieldTypeError","validateValue","InvalidValueError","sendDimEvent","PrimaryKey","DataType","CustomFieldDefinition","BeforeBulkCreate","BeforeBulkUpdate","BeforeUpdate","BeforeCreate","BeforeUpsert","AfterUpsert"],"sources":["../../src/models/CustomFieldValue.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n BelongsTo,\n ForeignKey,\n BeforeCreate,\n BeforeUpsert,\n AfterUpsert,\n BeforeUpdate,\n BeforeBulkCreate,\n BeforeBulkUpdate,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport { CustomFieldDefinition } from '.';\nimport { validateFieldType, validateValue } from '../utils/validations';\nimport * as CustomFieldDefinitionRepo from '../repository/definition';\nimport { InvalidFieldTypeError, InvalidValueError } from '../errors';\n\n@Table({\n tableName: 'custom_field_values',\n modelName: 'CustomFieldValue',\n timestamps: true,\n})\nclass CustomFieldValue extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n modelId!: string;\n\n @PrimaryKey\n @ForeignKey(() => CustomFieldDefinition)\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n customFieldDefinitionId!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: true,\n })\n value!: any;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare deletedAt?: Date;\n\n @BelongsTo(() => CustomFieldDefinition, { scope: { disabled: false } })\n declare customFieldDefinition: CustomFieldDefinition;\n\n private static validateValueAgainstDefinition(\n instance: CustomFieldValue,\n definition: CustomFieldDefinition,\n ): void {\n const { validation, fieldType, name } = definition;\n const isValidFieldType = validateFieldType(fieldType);\n if (!isValidFieldType) {\n throw new InvalidFieldTypeError(fieldType);\n }\n // Always allow null values\n if (instance.value === null) return;\n const validateValueResponse = validateValue(instance.value, fieldType, validation);\n if (validateValueResponse.error) {\n throw new InvalidValueError(instance.value, name, validateValueResponse.error);\n }\n }\n\n @BeforeBulkCreate\n @BeforeBulkUpdate\n static async validateCustomFieldValues(instances: CustomFieldValue[]): Promise<void> {\n const ids = instances.map(instance => instance.customFieldDefinitionId);\n const uniqueIds = [...new Set(ids)];\n const definitions = await CustomFieldDefinitionRepo.findByIds(\n uniqueIds,\n { withDisabled: true },\n );\n\n if (!definitions || definitions.length !== uniqueIds.length) {\n throw new Error('Definitions not found');\n }\n\n instances.forEach((instance) => {\n const definition = definitions.find(d => d.id === instance.customFieldDefinitionId);\n if (definition) {\n this.validateValueAgainstDefinition(instance, definition);\n }\n });\n }\n\n @BeforeUpdate\n @BeforeCreate\n @BeforeUpsert\n static async validateCustomFieldValue(instance: CustomFieldValue): Promise<void> {\n const { customFieldDefinitionId } = instance;\n const cfd = await CustomFieldDefinitionRepo.findById(customFieldDefinitionId, { withDisabled: true });\n this.validateValueAgainstDefinition(instance, cfd!);\n }\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomFieldValue[], options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance[0]));\n } else {\n sendDimEvent(instance[0]);\n }\n }\n}\n\nexport default CustomFieldValue;\n"],"mappings":"8dAsBA,IAAA,EAAA,cAK+BC,EAAAA,KAAM,CA2CnC,OAAe,+BACb,EACA,EACM,CACN,GAAM,CAAE,aAAY,YAAW,Q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,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,mCAGeC,EAAAA,QAAuB,CAAE,MAAO,CAAE,SAAU,GAAO,CAAE,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,EAAA,UAAA,QAAA,EAAA,UAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,wBAAA,IAAA,GAAA,eAoBtEC,EAAAA,iBACAC,EAAAA,qNAqBAC,EAAAA,aACAC,EAAAA,aACAC,EAAAA,uPAOAC,EAAAA,2NAhGI,CACL,UAAW,sBACX,UAAW,mBACX,WAAY,GACb,CAAC,CAAA,CAAA,EAAA,CAsGF,IAAA,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{sendDimEvent as e}from"../events/index.js";import{InvalidFieldTypeError as t,InvalidValueError as n}from"../errors/index.js";import{validateFieldType as r,validateValue as i}from"../utils/validations/index.js";import{
|
|
1
|
+
import{sendDimEvent as e}from"../events/index.js";import{InvalidFieldTypeError as t,InvalidValueError as n}from"../errors/index.js";import{validateFieldType as r,validateValue as i}from"../utils/validations/index.js";import{__decorateMetadata as a}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.js";import{__decorate as o}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.js";import s from"./CustomFieldDefinition.js";import{findById as c,findByIds as l}from"../repository/definition.js";import"./index.js";import{AfterUpsert as u,BeforeBulkCreate as d,BeforeBulkUpdate as f,BeforeCreate as p,BeforeUpdate as m,BeforeUpsert as h,BelongsTo as g,Column as _,DataType as v,ForeignKey as y,Model as b,PrimaryKey as x,Table as S}from"sequelize-typescript";var C,w,T,E,D;let O=class extends b{static validateValueAgainstDefinition(e,a){let{validation:o,fieldType:s,name:c}=a;if(!r(s))throw new t(s);if(e.value===null)return;let l=i(e.value,s,o);if(l.error)throw new n(e.value,c,l.error)}static async validateCustomFieldValues(e){let t=e.map(e=>e.customFieldDefinitionId),n=[...new Set(t)],r=await l(n,{withDisabled:!0});if(!r||r.length!==n.length)throw Error(`Definitions not found`);e.forEach(e=>{let t=r.find(t=>t.id===e.customFieldDefinitionId);t&&this.validateValueAgainstDefinition(e,t)})}static async validateCustomFieldValue(e){let{customFieldDefinitionId:t}=e,n=await c(t,{withDisabled:!0});this.validateValueAgainstDefinition(e,n)}static afterSaveHandler(t,n){n.transaction?n.transaction.afterCommit(()=>e(t[0])):e(t[0])}};o([x,_({type:v.UUID,allowNull:!1}),a(`design:type`,String)],O.prototype,`modelId`,void 0),o([x,y(()=>s),_({type:v.UUID,allowNull:!1}),a(`design:type`,String)],O.prototype,`customFieldDefinitionId`,void 0),o([_({type:v.JSONB,allowNull:!0}),a(`design:type`,Object)],O.prototype,`value`,void 0),o([_({type:v.DATE,allowNull:!1}),a(`design:type`,typeof(C=typeof Date<`u`&&Date)==`function`?C:Object)],O.prototype,`createdAt`,void 0),o([_({type:v.DATE,allowNull:!0}),a(`design:type`,typeof(w=typeof Date<`u`&&Date)==`function`?w:Object)],O.prototype,`updatedAt`,void 0),o([_({type:v.DATE,allowNull:!0}),a(`design:type`,typeof(T=typeof Date<`u`&&Date)==`function`?T:Object)],O.prototype,`deletedAt`,void 0),o([g(()=>s,{scope:{disabled:!1}}),a(`design:type`,typeof(E=s!==void 0&&s)==`function`?E:Object)],O.prototype,`customFieldDefinition`,void 0),o([d,f,a(`design:type`,Function),a(`design:paramtypes`,[Array]),a(`design:returntype`,Promise)],O,`validateCustomFieldValues`,null),o([m,p,h,a(`design:type`,Function),a(`design:paramtypes`,[typeof(D=O!==void 0&&O)==`function`?D:Object]),a(`design:returntype`,Promise)],O,`validateCustomFieldValue`,null),o([u,a(`design:type`,Function),a(`design:paramtypes`,[Array,Object]),a(`design:returntype`,void 0)],O,`afterSaveHandler`,null),O=o([S({tableName:`custom_field_values`,modelName:`CustomFieldValue`,timestamps:!0})],O);var k=O;export{k as default};
|
|
2
2
|
//# sourceMappingURL=CustomFieldValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldValue.js","names":["CustomFieldValue","CustomFieldDefinitionRepo.findByIds","CustomFieldDefinitionRepo.findById","CustomFieldDefinition"],"sources":["../../src/models/CustomFieldValue.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n BelongsTo,\n ForeignKey,\n BeforeCreate,\n BeforeUpsert,\n AfterUpsert,\n BeforeUpdate,\n BeforeBulkCreate,\n BeforeBulkUpdate,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport CustomFieldDefinition from '
|
|
1
|
+
{"version":3,"file":"CustomFieldValue.js","names":["CustomFieldValue","CustomFieldDefinitionRepo.findByIds","CustomFieldDefinitionRepo.findById","CustomFieldDefinition"],"sources":["../../src/models/CustomFieldValue.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n BelongsTo,\n ForeignKey,\n BeforeCreate,\n BeforeUpsert,\n AfterUpsert,\n BeforeUpdate,\n BeforeBulkCreate,\n BeforeBulkUpdate,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { sendDimEvent } from '../events';\nimport { CustomFieldDefinition } from '.';\nimport { validateFieldType, validateValue } from '../utils/validations';\nimport * as CustomFieldDefinitionRepo from '../repository/definition';\nimport { InvalidFieldTypeError, InvalidValueError } from '../errors';\n\n@Table({\n tableName: 'custom_field_values',\n modelName: 'CustomFieldValue',\n timestamps: true,\n})\nclass CustomFieldValue extends Model {\n @PrimaryKey\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n modelId!: string;\n\n @PrimaryKey\n @ForeignKey(() => CustomFieldDefinition)\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n customFieldDefinitionId!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: true,\n })\n value!: any;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare deletedAt?: Date;\n\n @BelongsTo(() => CustomFieldDefinition, { scope: { disabled: false } })\n declare customFieldDefinition: CustomFieldDefinition;\n\n private static validateValueAgainstDefinition(\n instance: CustomFieldValue,\n definition: CustomFieldDefinition,\n ): void {\n const { validation, fieldType, name } = definition;\n const isValidFieldType = validateFieldType(fieldType);\n if (!isValidFieldType) {\n throw new InvalidFieldTypeError(fieldType);\n }\n // Always allow null values\n if (instance.value === null) return;\n const validateValueResponse = validateValue(instance.value, fieldType, validation);\n if (validateValueResponse.error) {\n throw new InvalidValueError(instance.value, name, validateValueResponse.error);\n }\n }\n\n @BeforeBulkCreate\n @BeforeBulkUpdate\n static async validateCustomFieldValues(instances: CustomFieldValue[]): Promise<void> {\n const ids = instances.map(instance => instance.customFieldDefinitionId);\n const uniqueIds = [...new Set(ids)];\n const definitions = await CustomFieldDefinitionRepo.findByIds(\n uniqueIds,\n { withDisabled: true },\n );\n\n if (!definitions || definitions.length !== uniqueIds.length) {\n throw new Error('Definitions not found');\n }\n\n instances.forEach((instance) => {\n const definition = definitions.find(d => d.id === instance.customFieldDefinitionId);\n if (definition) {\n this.validateValueAgainstDefinition(instance, definition);\n }\n });\n }\n\n @BeforeUpdate\n @BeforeCreate\n @BeforeUpsert\n static async validateCustomFieldValue(instance: CustomFieldValue): Promise<void> {\n const { customFieldDefinitionId } = instance;\n const cfd = await CustomFieldDefinitionRepo.findById(customFieldDefinitionId, { withDisabled: true });\n this.validateValueAgainstDefinition(instance, cfd!);\n }\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomFieldValue[], options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance[0]));\n } else {\n sendDimEvent(instance[0]);\n }\n }\n}\n\nexport default CustomFieldValue;\n"],"mappings":"kyBAsBA,IAAA,EAAA,cAK+B,CAAM,CA2CnC,OAAe,+BACb,EACA,EACM,CACN,GAAM,CAAE,aAAY,YAAW,QAAS,EAExC,GAAI,CADqB,EAAkB,EAAU,CAEnD,MAAM,IAAI,EAAsB,EAAU,CAG5C,GAAI,EAAS,QAAU,KAAM,OAC7B,IAAM,EAAwB,EAAc,EAAS,MAAO,EAAW,EAAW,CAClF,GAAI,EAAsB,MACxB,MAAM,IAAI,EAAkB,EAAS,MAAO,EAAM,EAAsB,MAAM,CAIlF,aAEa,0BAA0B,EAA8C,CACnF,IAAM,EAAM,EAAU,IAAI,GAAY,EAAS,wBAAwB,CACjE,EAAY,CAAC,GAAG,IAAI,IAAI,EAAI,CAAC,CAC7B,EAAc,MAAMC,EACxB,EACA,CAAE,aAAc,GAAM,CACvB,CAED,GAAI,CAAC,GAAe,EAAY,SAAW,EAAU,OACnD,MAAU,MAAM,wBAAwB,CAG1C,EAAU,QAAS,GAAa,CAC9B,IAAM,EAAa,EAAY,KAAK,GAAK,EAAE,KAAO,EAAS,wBAAwB,CAC/E,GACF,KAAK,+BAA+B,EAAU,EAAW,EAE3D,CAGJ,aAGa,yBAAyB,EAA2C,CAC/E,GAAM,CAAE,2BAA4B,EAC9B,EAAM,MAAMC,EAAmC,EAAy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sGF,IAAA,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.cjs`),r=require(`../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.cjs`);let i=require(`sequelize-typescript`),a=require(`node:crypto`);var o,s,c;let l=class extends i.Model{static afterSaveHandler(e,n){n.transaction?n.transaction.afterCommit(()=>t.sendDimEvent(e)):t.sendDimEvent(e)}};r.__decorate([i.PrimaryKey,(0,i.Default)(()=>(0,a.randomUUID)()),(0,i.Column)({type:i.DataType.UUID,allowNull:!1}),n.__decorateMetadata(`design:type`,String)],l.prototype,`id`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.UUID,allowNull:!1}),n.__decorateMetadata(`design:type`,String)],l.prototype,`entityId`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.STRING,allowNull:!1}),n.__decorateMetadata(`design:type`,String)],l.prototype,`entityType`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.STRING,allowNull:!1}),n.__decorateMetadata(`design:type`,String)],l.prototype,`modelType`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.JSONB,allowNull:!1}),n.__decorateMetadata(`design:type`,Object)],l.prototype,`schema`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.BOOLEAN,allowNull:!1,defaultValue:!1}),n.__decorateMetadata(`design:type`,Boolean)],l.prototype,`disabled`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.DATE,allowNull:!1}),n.__decorateMetadata(`design:type`,typeof(o=typeof Date<`u`&&Date)==`function`?o:Object)],l.prototype,`createdAt`,void 0),r.__decorate([(0,i.Column)({type:i.DataType.DATE,allowNull:!0}),n.__decorateMetadata(`design:type`,typeof(s=typeof Date<`u`&&Date)==`function`?s:Object)],l.prototype,`updatedAt`,void 0),r.__decorate([i.AfterUpsert,n.__decorateMetadata(`design:type`,Function),n.__decorateMetadata(`design:paramtypes`,[typeof(c=l!==void 0&&l)==`function`?c:Object,Object]),n.__decorateMetadata(`design:returntype`,void 0)],l,`afterSaveHandler`,null),l=r.__decorate([(0,i.DefaultScope)(()=>({where:{disabled:!1}})),(0,i.Table)({tableName:`custom_validators`,modelName:`CustomValidator`,timestamps:!0})],l);var u=l;exports.default=u;
|
|
2
2
|
//# sourceMappingURL=CustomValidator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomValidator.cjs","names":["CustomValidator","Model","sendDimEvent","PrimaryKey","DataType","AfterUpsert"],"sources":["../../src/models/CustomValidator.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n Default,\n AfterUpsert,\n DefaultScope,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { randomUUID } from 'node:crypto';\nimport { sendDimEvent } from '../events';\nimport type { SchemaObject } from '../api/v1/validator/validations';\n\n@DefaultScope(() => ({ where: { disabled: false } }))\n@Table({\n tableName: 'custom_validators',\n modelName: 'CustomValidator',\n timestamps: true,\n})\nclass CustomValidator extends Model {\n @PrimaryKey\n @Default(() => randomUUID())\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity for which this validator is defined, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of entity (fleet, businessModel, etc). */\n entityType!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model this validator applies to. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n })\n /** JSON Schema to validate models against */\n schema!: SchemaObject;\n\n @Column({\n type: DataType.BOOLEAN,\n allowNull: false,\n defaultValue: false,\n })\n disabled!: boolean;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomValidator, options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance));\n } else {\n sendDimEvent(instance);\n }\n }\n}\n\nexport default CustomValidator;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomValidator.cjs","names":["CustomValidator","Model","sendDimEvent","PrimaryKey","DataType","AfterUpsert"],"sources":["../../src/models/CustomValidator.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n Default,\n AfterUpsert,\n DefaultScope,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { randomUUID } from 'node:crypto';\nimport { sendDimEvent } from '../events';\nimport type { SchemaObject } from '../api/v1/validator/validations';\n\n@DefaultScope(() => ({ where: { disabled: false } }))\n@Table({\n tableName: 'custom_validators',\n modelName: 'CustomValidator',\n timestamps: true,\n})\nclass CustomValidator extends Model {\n @PrimaryKey\n @Default(() => randomUUID())\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity for which this validator is defined, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of entity (fleet, businessModel, etc). */\n entityType!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model this validator applies to. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n })\n /** JSON Schema to validate models against */\n schema!: SchemaObject;\n\n @Column({\n type: DataType.BOOLEAN,\n allowNull: false,\n defaultValue: false,\n })\n disabled!: boolean;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomValidator, options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance));\n } else {\n sendDimEvent(instance);\n }\n }\n}\n\nexport default CustomValidator;\n"],"mappings":"4TAeA,IAAA,EAAA,cAM8BC,EAAAA,KAAM,CAwDlC,OACO,iBAAiB,EAA2B,EAA8B,CAC3E,EAAQ,YACV,EAAQ,YAAY,gBAAkBC,EAAAA,aAAa,EAAS,CAAC,CAE7D,EAAA,aAAa,EAAS,iBA5DzBC,EAAAA,+CAC0B,CAAC,cACpB,CACN,KAAMC,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,iGAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,WAAA,IAAA,GAAA,4BAIM,CACN,KAAMA,EAAAA,SAAS,OACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,aAAA,IAAA,GAAA,4BAIM,CACN,KAAMA,EAAAA,SAAS,OACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,4BAIM,CACN,KAAMA,EAAAA,SAAS,MACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,4BAIM,CACN,KAAMA,EAAAA,SAAS,QACf,UAAW,GACX,aAAc,GACf,CAAC,CAAA,EAAA,mBAAA,cAAA,QAAA,CAAA,CAAA,EAAA,UAAA,WAAA,IAAA,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,eAGDC,EAAAA,8QA9DkB,CAAE,MAAO,CAAE,SAAU,GAAO,CAAE,EAAE,EAAA,EAAA,EAAA,OAC9C,CACL,UAAW,oBACX,UAAW,kBACX,WAAY,GACb,CAAC,CAAA,CAAA,EAAA,CAmEF,IAAA,EAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{sendDimEvent as e}from"../events/index.js";import{__decorateMetadata as t}from"../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import{sendDimEvent as e}from"../events/index.js";import{__decorateMetadata as t}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.js";import{__decorate as n}from"../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.js";import{AfterUpsert as r,Column as i,DataType as a,Default as o,DefaultScope as s,Model as c,PrimaryKey as l,Table as u}from"sequelize-typescript";import{randomUUID as d}from"node:crypto";var f,p,m;let h=class extends c{static afterSaveHandler(t,n){n.transaction?n.transaction.afterCommit(()=>e(t)):e(t)}};n([l,o(()=>d()),i({type:a.UUID,allowNull:!1}),t(`design:type`,String)],h.prototype,`id`,void 0),n([i({type:a.UUID,allowNull:!1}),t(`design:type`,String)],h.prototype,`entityId`,void 0),n([i({type:a.STRING,allowNull:!1}),t(`design:type`,String)],h.prototype,`entityType`,void 0),n([i({type:a.STRING,allowNull:!1}),t(`design:type`,String)],h.prototype,`modelType`,void 0),n([i({type:a.JSONB,allowNull:!1}),t(`design:type`,Object)],h.prototype,`schema`,void 0),n([i({type:a.BOOLEAN,allowNull:!1,defaultValue:!1}),t(`design:type`,Boolean)],h.prototype,`disabled`,void 0),n([i({type:a.DATE,allowNull:!1}),t(`design:type`,typeof(f=typeof Date<`u`&&Date)==`function`?f:Object)],h.prototype,`createdAt`,void 0),n([i({type:a.DATE,allowNull:!0}),t(`design:type`,typeof(p=typeof Date<`u`&&Date)==`function`?p:Object)],h.prototype,`updatedAt`,void 0),n([r,t(`design:type`,Function),t(`design:paramtypes`,[typeof(m=h!==void 0&&h)==`function`?m:Object,Object]),t(`design:returntype`,void 0)],h,`afterSaveHandler`,null),h=n([s(()=>({where:{disabled:!1}})),u({tableName:`custom_validators`,modelName:`CustomValidator`,timestamps:!0})],h);var g=h;export{g as default};
|
|
2
2
|
//# sourceMappingURL=CustomValidator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomValidator.js","names":["CustomValidator"],"sources":["../../src/models/CustomValidator.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n Default,\n AfterUpsert,\n DefaultScope,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { randomUUID } from 'node:crypto';\nimport { sendDimEvent } from '../events';\nimport type { SchemaObject } from '../api/v1/validator/validations';\n\n@DefaultScope(() => ({ where: { disabled: false } }))\n@Table({\n tableName: 'custom_validators',\n modelName: 'CustomValidator',\n timestamps: true,\n})\nclass CustomValidator extends Model {\n @PrimaryKey\n @Default(() => randomUUID())\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity for which this validator is defined, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of entity (fleet, businessModel, etc). */\n entityType!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model this validator applies to. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n })\n /** JSON Schema to validate models against */\n schema!: SchemaObject;\n\n @Column({\n type: DataType.BOOLEAN,\n allowNull: false,\n defaultValue: false,\n })\n disabled!: boolean;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomValidator, options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance));\n } else {\n sendDimEvent(instance);\n }\n }\n}\n\nexport default CustomValidator;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomValidator.js","names":["CustomValidator"],"sources":["../../src/models/CustomValidator.ts"],"sourcesContent":["import {\n Table,\n Column,\n Model,\n PrimaryKey,\n DataType,\n Default,\n AfterUpsert,\n DefaultScope,\n} from 'sequelize-typescript';\nimport type { CreateOptions } from 'sequelize';\nimport { randomUUID } from 'node:crypto';\nimport { sendDimEvent } from '../events';\nimport type { SchemaObject } from '../api/v1/validator/validations';\n\n@DefaultScope(() => ({ where: { disabled: false } }))\n@Table({\n tableName: 'custom_validators',\n modelName: 'CustomValidator',\n timestamps: true,\n})\nclass CustomValidator extends Model {\n @PrimaryKey\n @Default(() => randomUUID())\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n declare id: string;\n\n @Column({\n type: DataType.UUID,\n allowNull: false,\n })\n /** The ID of the entity for which this validator is defined, e.g. fleetId / etc. */\n entityId!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of entity (fleet, businessModel, etc). */\n entityType!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false,\n })\n /** The type of model this validator applies to. e.g. Vehicle / StopPoint / etc. */\n modelType!: string;\n\n @Column({\n type: DataType.JSONB,\n allowNull: false,\n })\n /** JSON Schema to validate models against */\n schema!: SchemaObject;\n\n @Column({\n type: DataType.BOOLEAN,\n allowNull: false,\n defaultValue: false,\n })\n disabled!: boolean;\n\n @Column({\n type: DataType.DATE,\n allowNull: false,\n })\n declare createdAt?: Date;\n\n @Column({\n type: DataType.DATE,\n allowNull: true,\n })\n declare updatedAt?: Date;\n\n @AfterUpsert\n static afterSaveHandler(instance: CustomValidator, options: CreateOptions): void {\n if (options.transaction) {\n options.transaction.afterCommit(() => sendDimEvent(instance));\n } else {\n sendDimEvent(instance);\n }\n }\n}\n\nexport default CustomValidator;\n"],"mappings":"2bAeA,IAAA,EAAA,cAM8B,CAAM,CAwDlC,OACO,iBAAiB,EAA2B,EAA8B,CAC3E,EAAQ,YACV,EAAQ,YAAY,gBAAkB,EAAa,EAAS,CAAC,CAE7D,EAAa,EAAS,MA5DzB,EACA,MAAc,GAAY,CAAC,CAC3B,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,sDAGD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,WAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,OACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,aAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,OACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,MACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,IAID,EAAO,CACN,KAAM,EAAS,QACf,UAAW,GACX,aAAc,GACf,CAAC,CAAA,EAAA,cAAA,QAAA,CAAA,CAAA,EAAA,UAAA,WAAA,IAAA,GAAA,IAGD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAGD,EAAO,CACN,KAAM,EAAS,KACf,UAAW,GACZ,CAAC,CAAA,EAAA,cAAA,OAAA,EAAA,OAAA,KAAA,KAAA,OAAA,WAAA,EAAA,OAAA,CAAA,CAAA,EAAA,UAAA,YAAA,IAAA,GAAA,IAGD,wKA9DF,OAAoB,CAAE,MAAO,CAAE,SAAU,GAAO,CAAE,EAAE,CACpD,EAAM,CACL,UAAW,oBACX,UAAW,kBACX,WAAY,GACb,CAAC,CAAA,CAAA,EAAA,CAmEF,IAAA,EAAe"}
|
package/dist/models/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/logger/index.cjs`),n=require(`./
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/logger/index.cjs`),n=require(`./CustomFieldDefinition.cjs`),r=require(`./CustomFieldValue.cjs`),i=require(`./tests/AssociatedTestModel.cjs`),a=require(`./tests/TestModel.cjs`),o=require(`./tests/contextAwareModels/ContextTestModel.cjs`),s=require(`./tests/contextAwareModels/ContextAwareTestModel.cjs`),c=require(`./CustomFieldEntries.cjs`),l=require(`./CustomValidator.cjs`),u=require(`./CustomFieldModelTypeMap.cjs`);let d=require(`sequelize`);const f=[a.default,i.default,s.default,o.default],p=`sadot-migration`,m=`49c9dd1d-b1cc-445b-a911-fd349d783110`,h=async(e,i,{schemaPrefix:a=`sadot-migration`,schemaVersion:o=`49c9dd1d-b1cc-445b-a911-fd349d783110`,useCustomFieldsEntries:s=!1,useModelTypeMapping:f=!1}={})=>{let p=`${a}_${o}${s?`_withEntries`:``}${f?`_withTypeMapping`:``}`;if(t.default.info(`custom-fields: initialize custom-fields tables`),!e.addModels)throw Error(`sequelize instance must have addModels function`);let m=[n.default,r.default,l.default,...s?[c.default]:[],...f?[u.default]:[]];e.addModels(m),f&&(n.default.hasMany(u.default,{foreignKey:`customFieldDefinitionId`,as:`modelTypeMappings`}),u.default.belongsTo(n.default,{foreignKey:`customFieldDefinitionId`,as:`customFieldDefinition`})),n.default.addScope(`userScope`,()=>{let e=i();return e?.permissions?{where:{entityId:[...Object.keys(e.permissions.fleets),...Object.keys(e.permissions.businessModels),...Object.keys(e.permissions.demandSources)]}}:{}}),l.default.addScope(`userScope`,()=>{let e=i();return e?.permissions?{where:{entityId:[...Object.keys(e.permissions.fleets),...Object.keys(e.permissions.businessModels),...Object.keys(e.permissions.demandSources)]}}:{}}),t.default.info(`custom-fields: models added`);let h=e.define(`SequelizeMeta`,{name:{type:d.DataTypes.STRING,allowNull:!1,unique:!0,primaryKey:!0,autoIncrement:!1}},{tableName:`SequelizeMeta`,timestamps:!1,schema:`public`});t.default.info(`custom-fields: starting migrations`);let g=await h.findAll({where:{name:{[d.Op.like]:`${a}%`}},raw:!0}),_=g.at(-1),v=g.findIndex(e=>e.name===p);if(t.default.info(`custom-fields: migrations`,{migrations:g,currentSadotSchemaVersion:_,expectedSchemaVersionIndex:v}),(!_||_.name!==p)&&(t.default.info(`custom-fields: syncing models`),await n.default.sync({alter:!0}),await r.default.sync({alter:!0}),await l.default.sync({alter:!0}),s&&await c.default.sync({alter:!0}),f&&await u.default.sync({alter:!0}),v===-1&&await h.create({name:p}),t.default.info(`custom-fields: models synced`),g.length&&v!==-1&&v<g.length-1)){let e=g.slice(v+1);await h.destroy({where:{name:{[d.Op.in]:e.map(e=>e.name)}}})}},g=async e=>{if(t.default.info(`custom-fields: initialize custom-fields test models`),!e.addModels)throw Error(`sequelize instance must have addModels function`);e.addModels(f),await e.dropSchema(`custom-fields`,{logging:!1}),await e.createSchema(`custom-fields`,{logging:!1}),t.default.info(`custom-fields: test models added`),await a.default.sync({alter:!0}),await i.default.sync({alter:!0}),await o.default.sync({alter:!0}),await s.default.sync({alter:!0}),t.default.info(`custom-fields: test models synced`)};exports.initTables=h,exports.initTestModels=g;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["TestModel","AssociatedTestModel","ContextAwareTestModel","ContextTestModel","sequelize","productionModels: ProductionModel[]","CustomFieldDefinition","CustomFieldValue","CustomValidator","CustomFieldEntries","DataTypes","Op"],"sources":["../../src/models/index.ts"],"sourcesContent":["import { DataTypes, Op } from 'sequelize';\nimport type { Sequelize } from 'sequelize-typescript';\nimport logger from '../utils/logger';\nimport CustomFieldDefinition from './CustomFieldDefinition';\nimport CustomFieldValue from './CustomFieldValue';\nimport TestModel from './tests/TestModel';\nimport ContextAwareTestModel from './tests/contextAwareModels/ContextAwareTestModel';\nimport ContextTestModel from './tests/contextAwareModels/ContextTestModel';\nimport AssociatedTestModel from './tests/AssociatedTestModel';\nimport type { CustomFieldOptions } from '../types';\nimport CustomFieldEntries from './CustomFieldEntries';\nimport CustomValidator from './CustomValidator';\n\ntype ProductionModel = typeof CustomFieldDefinition | typeof CustomFieldValue | typeof CustomFieldEntries | typeof CustomValidator;\ninterface InitTablesOptions {\n schemaPrefix?: string;\n schemaVersion?: string;\n useCustomFieldsEntries?: boolean;\n}\n\nconst testModels = [TestModel, AssociatedTestModel, ContextAwareTestModel, ContextTestModel];\n\nconst SADOT_MIGRATION_PREFIX = 'sadot-migration';\nconst SCHEMA_VERSION = '49c9dd1d-b1cc-445b-a911-fd349d783110';\n\nconst initTables = async (\n sequelize: Sequelize,\n getUser: CustomFieldOptions['getUser'],\n {\n schemaPrefix = SADOT_MIGRATION_PREFIX,\n schemaVersion = SCHEMA_VERSION,\n useCustomFieldsEntries = false,\n }: InitTablesOptions = {},\n): Promise<void> => {\n const CUSTOM_FIELDS_SCHEMA_VERSION = `${schemaPrefix}_${schemaVersion}${useCustomFieldsEntries ? '_withEntries' : ''}`;\n logger.info('custom-fields: initialize custom-fields tables');\n // Detect models and import them to the orm\n if (!sequelize.addModels) {\n throw new Error('sequelize instance must have addModels function');\n }\n const productionModels: ProductionModel[] = [\n CustomFieldDefinition,\n CustomFieldValue,\n CustomValidator,\n ...(useCustomFieldsEntries ? [CustomFieldEntries] : []),\n ];\n\n sequelize.addModels(productionModels);\n\n CustomFieldDefinition.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n CustomValidator.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n logger.info('custom-fields: models added');\n\n const SequelizeMeta = sequelize.define(\n 'SequelizeMeta',\n {\n name: {\n type: DataTypes.STRING,\n allowNull: false,\n unique: true,\n primaryKey: true,\n autoIncrement: false,\n },\n },\n {\n tableName: 'SequelizeMeta',\n timestamps: false,\n schema: 'public',\n },\n );\n\n logger.info('custom-fields: starting migrations');\n const migrations = await SequelizeMeta.findAll({ where: { name: { [Op.like]: `${schemaPrefix}%` } }, raw: true });\n const currentSadotSchemaVersion = migrations.at(-1);\n const expectedSchemaVersionIndex = migrations.findIndex(m => (m as any).name === CUSTOM_FIELDS_SCHEMA_VERSION);\n\n logger.info('custom-fields: migrations', { migrations, currentSadotSchemaVersion, expectedSchemaVersionIndex });\n if (!currentSadotSchemaVersion || (currentSadotSchemaVersion as any).name !== CUSTOM_FIELDS_SCHEMA_VERSION) {\n logger.info('custom-fields: syncing models');\n await CustomFieldDefinition.sync({ alter: true });\n await CustomFieldValue.sync({ alter: true });\n // T.Y TODO: Remove the if statement once we're ready to add the new entries table for all MS\n if (useCustomFieldsEntries) {\n await CustomFieldEntries.sync({ alter: true });\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["TestModel","AssociatedTestModel","ContextAwareTestModel","ContextTestModel","sequelize","productionModels: ProductionModel[]","CustomFieldDefinition","CustomFieldValue","CustomValidator","CustomFieldEntries","CustomFieldModelTypeMap","DataTypes","Op"],"sources":["../../src/models/index.ts"],"sourcesContent":["import { DataTypes, Op } from 'sequelize';\nimport type { Sequelize } from 'sequelize-typescript';\nimport logger from '../utils/logger';\nimport CustomFieldDefinition from './CustomFieldDefinition';\nimport CustomFieldValue from './CustomFieldValue';\nimport TestModel from './tests/TestModel';\nimport ContextAwareTestModel from './tests/contextAwareModels/ContextAwareTestModel';\nimport ContextTestModel from './tests/contextAwareModels/ContextTestModel';\nimport AssociatedTestModel from './tests/AssociatedTestModel';\nimport type { CustomFieldOptions } from '../types';\nimport CustomFieldEntries from './CustomFieldEntries';\nimport CustomValidator from './CustomValidator';\nimport CustomFieldModelTypeMap from './CustomFieldModelTypeMap';\n\ntype ProductionModel = typeof CustomFieldDefinition | typeof CustomFieldValue | typeof CustomFieldEntries | typeof CustomValidator | typeof CustomFieldModelTypeMap;\ninterface InitTablesOptions {\n schemaPrefix?: string;\n schemaVersion?: string;\n useCustomFieldsEntries?: boolean;\n useModelTypeMapping?: boolean;\n}\n\nconst testModels = [TestModel, AssociatedTestModel, ContextAwareTestModel, ContextTestModel];\n\nconst SADOT_MIGRATION_PREFIX = 'sadot-migration';\nconst SCHEMA_VERSION = '49c9dd1d-b1cc-445b-a911-fd349d783110';\n\nconst initTables = async (\n sequelize: Sequelize,\n getUser: CustomFieldOptions['getUser'],\n {\n schemaPrefix = SADOT_MIGRATION_PREFIX,\n schemaVersion = SCHEMA_VERSION,\n useCustomFieldsEntries = false,\n useModelTypeMapping = false,\n }: InitTablesOptions = {},\n): Promise<void> => {\n const CUSTOM_FIELDS_SCHEMA_VERSION = `${schemaPrefix}_${schemaVersion}${useCustomFieldsEntries ? '_withEntries' : ''}${useModelTypeMapping ? '_withTypeMapping' : ''}`;\n logger.info('custom-fields: initialize custom-fields tables');\n // Detect models and import them to the orm\n if (!sequelize.addModels) {\n throw new Error('sequelize instance must have addModels function');\n }\n const productionModels: ProductionModel[] = [\n CustomFieldDefinition,\n CustomFieldValue,\n CustomValidator,\n ...(useCustomFieldsEntries ? [CustomFieldEntries] : []),\n ...(useModelTypeMapping ? [CustomFieldModelTypeMap] : []),\n ];\n\n sequelize.addModels(productionModels);\n\n // Add the association only when useModelTypeMapping is enabled\n if (useModelTypeMapping) {\n CustomFieldDefinition.hasMany(CustomFieldModelTypeMap, {\n foreignKey: 'customFieldDefinitionId',\n as: 'modelTypeMappings',\n });\n CustomFieldModelTypeMap.belongsTo(CustomFieldDefinition, {\n foreignKey: 'customFieldDefinitionId',\n as: 'customFieldDefinition',\n });\n }\n\n CustomFieldDefinition.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n CustomValidator.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n logger.info('custom-fields: models added');\n\n const SequelizeMeta = sequelize.define(\n 'SequelizeMeta',\n {\n name: {\n type: DataTypes.STRING,\n allowNull: false,\n unique: true,\n primaryKey: true,\n autoIncrement: false,\n },\n },\n {\n tableName: 'SequelizeMeta',\n timestamps: false,\n schema: 'public',\n },\n );\n\n logger.info('custom-fields: starting migrations');\n const migrations = await SequelizeMeta.findAll({ where: { name: { [Op.like]: `${schemaPrefix}%` } }, raw: true });\n const currentSadotSchemaVersion = migrations.at(-1);\n const expectedSchemaVersionIndex = migrations.findIndex(m => (m as any).name === CUSTOM_FIELDS_SCHEMA_VERSION);\n\n logger.info('custom-fields: migrations', { migrations, currentSadotSchemaVersion, expectedSchemaVersionIndex });\n if (!currentSadotSchemaVersion || (currentSadotSchemaVersion as any).name !== CUSTOM_FIELDS_SCHEMA_VERSION) {\n logger.info('custom-fields: syncing models');\n await CustomFieldDefinition.sync({ alter: true });\n await CustomFieldValue.sync({ alter: true });\n await CustomValidator.sync({ alter: true });\n\n // T.Y TODO: Remove the if statement once we're ready to add the new entries table for all MS\n if (useCustomFieldsEntries) {\n await CustomFieldEntries.sync({ alter: true });\n }\n\n if (useModelTypeMapping) {\n await CustomFieldModelTypeMap.sync({ alter: true });\n }\n\n if (expectedSchemaVersionIndex === -1) {\n await SequelizeMeta.create({ name: CUSTOM_FIELDS_SCHEMA_VERSION });\n }\n logger.info('custom-fields: models synced');\n if (migrations.length && expectedSchemaVersionIndex !== -1 && expectedSchemaVersionIndex < migrations.length - 1) {\n // We have existing migrations, and we are calling `sync`.\n // This means we are in a `down` migration, and hence we should delete newer migrations to ensure we can reapply them.\n const migrationsToDelete = migrations.slice(expectedSchemaVersionIndex + 1);\n await SequelizeMeta.destroy({ where: { name: { [Op.in]: migrationsToDelete.map(m => (m as any).name) } } });\n }\n }\n};\n\nconst initTestModels = async (sequelize: Sequelize): Promise<void> => {\n logger.info('custom-fields: initialize custom-fields test models');\n // Detect models and import them to the orm\n if (!sequelize.addModels) {\n throw new Error('sequelize instance must have addModels function');\n }\n\n sequelize.addModels(testModels);\n await sequelize.dropSchema('custom-fields', { logging: false });\n await sequelize.createSchema('custom-fields', { logging: false });\n\n logger.info('custom-fields: test models added');\n await TestModel.sync({ alter: true });\n await AssociatedTestModel.sync({ alter: true });\n await ContextTestModel.sync({ alter: true });\n await ContextAwareTestModel.sync({ alter: true });\n logger.info('custom-fields: test models synced');\n};\n\nexport {\n CustomFieldValue,\n CustomFieldDefinition,\n CustomFieldEntries,\n CustomValidator,\n CustomFieldModelTypeMap,\n TestModel,\n AssociatedTestModel,\n ContextAwareTestModel,\n ContextTestModel,\n initTables,\n initTestModels,\n};\n"],"mappings":"sgBAsBA,MAAM,EAAa,CAACA,EAAAA,QAAWC,EAAAA,QAAqBC,EAAAA,QAAuBC,EAAAA,QA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AwC,CAGpE,GAFA,EAAA,QAAO,KAAK,sDAAsD,CAE9D,CAACR,EAAU,UACb,MAAU,MAAM,kDAAkD,CAGpE,EAAU,UAAU,EAAW,CAC/B,MAAMA,EAAU,WAAW,gBAAiB,CAAE,QAAS,GAAO,CAAC,CAC/D,MAAMA,EAAU,aAAa,gBAAiB,CAAE,QAAS,GAAO,CAAC,CAEjE,EAAA,QAAO,KAAK,mCAAmC,CAC/C,MAAMJ,EAAAA,QAAU,KAAK,CAAE,MAAO,GAAM,CAAC,CACrC,MAAMC,EAAAA,QAAoB,KAAK,CAAE,MAAO,GAAM,CAAC,CAC/C,MAAME,EAAAA,QAAiB,KAAK,CAAE,MAAO,GAAM,CAAC,CAC5C,MAAMD,EAAAA,QAAsB,KAAK,CAAE,MAAO,GAAM,CAAC,CACjD,EAAA,QAAO,KAAK,oCAAoC"}
|
package/dist/models/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CustomFieldValue } from "./CustomFieldValue.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { CustomFieldEntries } from "./CustomFieldEntries.cjs";
|
|
3
3
|
import { CustomValidator } from "./CustomValidator.cjs";
|
|
4
|
+
import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.cjs";
|
|
5
|
+
import { CustomFieldDefinition } from "./CustomFieldDefinition.cjs";
|
|
4
6
|
import "../types/index.cjs";
|
|
5
|
-
import { CustomFieldEntries } from "./CustomFieldEntries.cjs";
|
|
6
7
|
import { Sequelize } from "sequelize-typescript";
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CustomFieldValue } from "./CustomFieldValue.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CustomFieldEntries } from "./CustomFieldEntries.js";
|
|
3
3
|
import { CustomValidator } from "./CustomValidator.js";
|
|
4
|
+
import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.js";
|
|
5
|
+
import { CustomFieldDefinition } from "./CustomFieldDefinition.js";
|
|
4
6
|
import "../types/index.js";
|
|
5
|
-
import { CustomFieldEntries } from "./CustomFieldEntries.js";
|
|
6
7
|
import { Sequelize } from "sequelize-typescript";
|
package/dist/models/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../utils/logger/index.js";import t from"./
|
|
1
|
+
import e from"../utils/logger/index.js";import t from"./CustomFieldDefinition.js";import n from"./CustomFieldValue.js";import r from"./tests/AssociatedTestModel.js";import i from"./tests/TestModel.js";import a from"./tests/contextAwareModels/ContextTestModel.js";import o from"./tests/contextAwareModels/ContextAwareTestModel.js";import s from"./CustomFieldEntries.js";import c from"./CustomValidator.js";import l from"./CustomFieldModelTypeMap.js";import{DataTypes as u,Op as d}from"sequelize";const f=[i,r,o,a],p=async(r,i,{schemaPrefix:a=`sadot-migration`,schemaVersion:o=`49c9dd1d-b1cc-445b-a911-fd349d783110`,useCustomFieldsEntries:f=!1,useModelTypeMapping:p=!1}={})=>{let m=`${a}_${o}${f?`_withEntries`:``}${p?`_withTypeMapping`:``}`;if(e.info(`custom-fields: initialize custom-fields tables`),!r.addModels)throw Error(`sequelize instance must have addModels function`);let h=[t,n,c,...f?[s]:[],...p?[l]:[]];r.addModels(h),p&&(t.hasMany(l,{foreignKey:`customFieldDefinitionId`,as:`modelTypeMappings`}),l.belongsTo(t,{foreignKey:`customFieldDefinitionId`,as:`customFieldDefinition`})),t.addScope(`userScope`,()=>{let e=i();return e?.permissions?{where:{entityId:[...Object.keys(e.permissions.fleets),...Object.keys(e.permissions.businessModels),...Object.keys(e.permissions.demandSources)]}}:{}}),c.addScope(`userScope`,()=>{let e=i();return e?.permissions?{where:{entityId:[...Object.keys(e.permissions.fleets),...Object.keys(e.permissions.businessModels),...Object.keys(e.permissions.demandSources)]}}:{}}),e.info(`custom-fields: models added`);let g=r.define(`SequelizeMeta`,{name:{type:u.STRING,allowNull:!1,unique:!0,primaryKey:!0,autoIncrement:!1}},{tableName:`SequelizeMeta`,timestamps:!1,schema:`public`});e.info(`custom-fields: starting migrations`);let _=await g.findAll({where:{name:{[d.like]:`${a}%`}},raw:!0}),v=_.at(-1),y=_.findIndex(e=>e.name===m);if(e.info(`custom-fields: migrations`,{migrations:_,currentSadotSchemaVersion:v,expectedSchemaVersionIndex:y}),(!v||v.name!==m)&&(e.info(`custom-fields: syncing models`),await t.sync({alter:!0}),await n.sync({alter:!0}),await c.sync({alter:!0}),f&&await s.sync({alter:!0}),p&&await l.sync({alter:!0}),y===-1&&await g.create({name:m}),e.info(`custom-fields: models synced`),_.length&&y!==-1&&y<_.length-1)){let e=_.slice(y+1);await g.destroy({where:{name:{[d.in]:e.map(e=>e.name)}}})}},m=async t=>{if(e.info(`custom-fields: initialize custom-fields test models`),!t.addModels)throw Error(`sequelize instance must have addModels function`);t.addModels(f),await t.dropSchema(`custom-fields`,{logging:!1}),await t.createSchema(`custom-fields`,{logging:!1}),e.info(`custom-fields: test models added`),await i.sync({alter:!0}),await r.sync({alter:!0}),await a.sync({alter:!0}),await o.sync({alter:!0}),e.info(`custom-fields: test models synced`)};export{p as initTables,m as initTestModels};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TestModel","AssociatedTestModel","ContextAwareTestModel","ContextTestModel","productionModels: ProductionModel[]","CustomFieldDefinition","CustomFieldValue","CustomValidator","CustomFieldEntries"],"sources":["../../src/models/index.ts"],"sourcesContent":["import { DataTypes, Op } from 'sequelize';\nimport type { Sequelize } from 'sequelize-typescript';\nimport logger from '../utils/logger';\nimport CustomFieldDefinition from './CustomFieldDefinition';\nimport CustomFieldValue from './CustomFieldValue';\nimport TestModel from './tests/TestModel';\nimport ContextAwareTestModel from './tests/contextAwareModels/ContextAwareTestModel';\nimport ContextTestModel from './tests/contextAwareModels/ContextTestModel';\nimport AssociatedTestModel from './tests/AssociatedTestModel';\nimport type { CustomFieldOptions } from '../types';\nimport CustomFieldEntries from './CustomFieldEntries';\nimport CustomValidator from './CustomValidator';\n\ntype ProductionModel = typeof CustomFieldDefinition | typeof CustomFieldValue | typeof CustomFieldEntries | typeof CustomValidator;\ninterface InitTablesOptions {\n schemaPrefix?: string;\n schemaVersion?: string;\n useCustomFieldsEntries?: boolean;\n}\n\nconst testModels = [TestModel, AssociatedTestModel, ContextAwareTestModel, ContextTestModel];\n\nconst SADOT_MIGRATION_PREFIX = 'sadot-migration';\nconst SCHEMA_VERSION = '49c9dd1d-b1cc-445b-a911-fd349d783110';\n\nconst initTables = async (\n sequelize: Sequelize,\n getUser: CustomFieldOptions['getUser'],\n {\n schemaPrefix = SADOT_MIGRATION_PREFIX,\n schemaVersion = SCHEMA_VERSION,\n useCustomFieldsEntries = false,\n }: InitTablesOptions = {},\n): Promise<void> => {\n const CUSTOM_FIELDS_SCHEMA_VERSION = `${schemaPrefix}_${schemaVersion}${useCustomFieldsEntries ? '_withEntries' : ''}`;\n logger.info('custom-fields: initialize custom-fields tables');\n // Detect models and import them to the orm\n if (!sequelize.addModels) {\n throw new Error('sequelize instance must have addModels function');\n }\n const productionModels: ProductionModel[] = [\n CustomFieldDefinition,\n CustomFieldValue,\n CustomValidator,\n ...(useCustomFieldsEntries ? [CustomFieldEntries] : []),\n ];\n\n sequelize.addModels(productionModels);\n\n CustomFieldDefinition.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n CustomValidator.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n logger.info('custom-fields: models added');\n\n const SequelizeMeta = sequelize.define(\n 'SequelizeMeta',\n {\n name: {\n type: DataTypes.STRING,\n allowNull: false,\n unique: true,\n primaryKey: true,\n autoIncrement: false,\n },\n },\n {\n tableName: 'SequelizeMeta',\n timestamps: false,\n schema: 'public',\n },\n );\n\n logger.info('custom-fields: starting migrations');\n const migrations = await SequelizeMeta.findAll({ where: { name: { [Op.like]: `${schemaPrefix}%` } }, raw: true });\n const currentSadotSchemaVersion = migrations.at(-1);\n const expectedSchemaVersionIndex = migrations.findIndex(m => (m as any).name === CUSTOM_FIELDS_SCHEMA_VERSION);\n\n logger.info('custom-fields: migrations', { migrations, currentSadotSchemaVersion, expectedSchemaVersionIndex });\n if (!currentSadotSchemaVersion || (currentSadotSchemaVersion as any).name !== CUSTOM_FIELDS_SCHEMA_VERSION) {\n logger.info('custom-fields: syncing models');\n await CustomFieldDefinition.sync({ alter: true });\n await CustomFieldValue.sync({ alter: true });\n // T.Y TODO: Remove the if statement once we're ready to add the new entries table for all MS\n if (useCustomFieldsEntries) {\n await CustomFieldEntries.sync({ alter: true });\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["TestModel","AssociatedTestModel","ContextAwareTestModel","ContextTestModel","productionModels: ProductionModel[]","CustomFieldDefinition","CustomFieldValue","CustomValidator","CustomFieldEntries","CustomFieldModelTypeMap"],"sources":["../../src/models/index.ts"],"sourcesContent":["import { DataTypes, Op } from 'sequelize';\nimport type { Sequelize } from 'sequelize-typescript';\nimport logger from '../utils/logger';\nimport CustomFieldDefinition from './CustomFieldDefinition';\nimport CustomFieldValue from './CustomFieldValue';\nimport TestModel from './tests/TestModel';\nimport ContextAwareTestModel from './tests/contextAwareModels/ContextAwareTestModel';\nimport ContextTestModel from './tests/contextAwareModels/ContextTestModel';\nimport AssociatedTestModel from './tests/AssociatedTestModel';\nimport type { CustomFieldOptions } from '../types';\nimport CustomFieldEntries from './CustomFieldEntries';\nimport CustomValidator from './CustomValidator';\nimport CustomFieldModelTypeMap from './CustomFieldModelTypeMap';\n\ntype ProductionModel = typeof CustomFieldDefinition | typeof CustomFieldValue | typeof CustomFieldEntries | typeof CustomValidator | typeof CustomFieldModelTypeMap;\ninterface InitTablesOptions {\n schemaPrefix?: string;\n schemaVersion?: string;\n useCustomFieldsEntries?: boolean;\n useModelTypeMapping?: boolean;\n}\n\nconst testModels = [TestModel, AssociatedTestModel, ContextAwareTestModel, ContextTestModel];\n\nconst SADOT_MIGRATION_PREFIX = 'sadot-migration';\nconst SCHEMA_VERSION = '49c9dd1d-b1cc-445b-a911-fd349d783110';\n\nconst initTables = async (\n sequelize: Sequelize,\n getUser: CustomFieldOptions['getUser'],\n {\n schemaPrefix = SADOT_MIGRATION_PREFIX,\n schemaVersion = SCHEMA_VERSION,\n useCustomFieldsEntries = false,\n useModelTypeMapping = false,\n }: InitTablesOptions = {},\n): Promise<void> => {\n const CUSTOM_FIELDS_SCHEMA_VERSION = `${schemaPrefix}_${schemaVersion}${useCustomFieldsEntries ? '_withEntries' : ''}${useModelTypeMapping ? '_withTypeMapping' : ''}`;\n logger.info('custom-fields: initialize custom-fields tables');\n // Detect models and import them to the orm\n if (!sequelize.addModels) {\n throw new Error('sequelize instance must have addModels function');\n }\n const productionModels: ProductionModel[] = [\n CustomFieldDefinition,\n CustomFieldValue,\n CustomValidator,\n ...(useCustomFieldsEntries ? [CustomFieldEntries] : []),\n ...(useModelTypeMapping ? [CustomFieldModelTypeMap] : []),\n ];\n\n sequelize.addModels(productionModels);\n\n // Add the association only when useModelTypeMapping is enabled\n if (useModelTypeMapping) {\n CustomFieldDefinition.hasMany(CustomFieldModelTypeMap, {\n foreignKey: 'customFieldDefinitionId',\n as: 'modelTypeMappings',\n });\n CustomFieldModelTypeMap.belongsTo(CustomFieldDefinition, {\n foreignKey: 'customFieldDefinitionId',\n as: 'customFieldDefinition',\n });\n }\n\n CustomFieldDefinition.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n CustomValidator.addScope('userScope', () => {\n const user = getUser();\n if (!user?.permissions) {\n return {};\n }\n return {\n where: {\n entityId: [\n ...Object.keys(user.permissions.fleets),\n ...Object.keys(user.permissions.businessModels),\n ...Object.keys(user.permissions.demandSources),\n ],\n },\n };\n });\n\n logger.info('custom-fields: models added');\n\n const SequelizeMeta = sequelize.define(\n 'SequelizeMeta',\n {\n name: {\n type: DataTypes.STRING,\n allowNull: false,\n unique: true,\n primaryKey: true,\n autoIncrement: false,\n },\n },\n {\n tableName: 'SequelizeMeta',\n timestamps: false,\n schema: 'public',\n },\n );\n\n logger.info('custom-fields: starting migrations');\n const migrations = await SequelizeMeta.findAll({ where: { name: { [Op.like]: `${schemaPrefix}%` } }, raw: true });\n const currentSadotSchemaVersion = migrations.at(-1);\n const expectedSchemaVersionIndex = migrations.findIndex(m => (m as any).name === CUSTOM_FIELDS_SCHEMA_VERSION);\n\n logger.info('custom-fields: migrations', { migrations, currentSadotSchemaVersion, expectedSchemaVersionIndex });\n if (!currentSadotSchemaVersion || (currentSadotSchemaVersion as any).name !== CUSTOM_FIELDS_SCHEMA_VERSION) {\n logger.info('custom-fields: syncing models');\n await CustomFieldDefinition.sync({ alter: true });\n await CustomFieldValue.sync({ alter: true });\n await CustomValidator.sync({ alter: true });\n\n // T.Y TODO: Remove the if statement once we're ready to add the new entries table for all MS\n if (useCustomFieldsEntries) {\n await CustomFieldEntries.sync({ alter: true });\n }\n\n if (useModelTypeMapping) {\n await CustomFieldModelTypeMap.sync({ alter: true });\n }\n\n if (expectedSchemaVersionIndex === -1) {\n await SequelizeMeta.create({ name: CUSTOM_FIELDS_SCHEMA_VERSION });\n }\n logger.info('custom-fields: models synced');\n if (migrations.length && expectedSchemaVersionIndex !== -1 && expectedSchemaVersionIndex < migrations.length - 1) {\n // We have existing migrations, and we are calling `sync`.\n // This means we are in a `down` migration, and hence we should delete newer migrations to ensure we can reapply them.\n const migrationsToDelete = migrations.slice(expectedSchemaVersionIndex + 1);\n await SequelizeMeta.destroy({ where: { name: { [Op.in]: migrationsToDelete.map(m => (m as any).name) } } });\n }\n }\n};\n\nconst initTestModels = async (sequelize: Sequelize): Promise<void> => {\n logger.info('custom-fields: initialize custom-fields test models');\n // Detect models and import them to the orm\n if (!sequelize.addModels) {\n throw new Error('sequelize instance must have addModels function');\n }\n\n sequelize.addModels(testModels);\n await sequelize.dropSchema('custom-fields', { logging: false });\n await sequelize.createSchema('custom-fields', { logging: false });\n\n logger.info('custom-fields: test models added');\n await TestModel.sync({ alter: true });\n await AssociatedTestModel.sync({ alter: true });\n await ContextTestModel.sync({ alter: true });\n await ContextAwareTestModel.sync({ alter: true });\n logger.info('custom-fields: test models synced');\n};\n\nexport {\n CustomFieldValue,\n CustomFieldDefinition,\n CustomFieldEntries,\n CustomValidator,\n CustomFieldModelTypeMap,\n TestModel,\n AssociatedTestModel,\n ContextAwareTestModel,\n ContextTestModel,\n initTables,\n initTestModels,\n};\n"],"mappings":"+eAsBA,MAAM,EAAa,CAACA,EAAWC,EAAqBC,EAAuBC,EAAiB,CAKtF,EAAa,MACjB,EACA,EACA,CACE,eAAe,kBACf,gBAAgB,uCAChB,yBAAyB,GACzB,sBAAsB,IACD,EAAE,GACP,CAClB,IAAM,EAA+B,GAAG,EAAa,GAAG,IAAgB,EAAyB,eAAiB,KAAK,EAAsB,mBAAqB,KAGlK,GAFA,EAAO,KAAK,iDAAiD,CAEzD,CAAC,EAAU,UACb,MAAU,MAAM,kDAAkD,CAEpE,IAAMC,EAAsC,CAC1CC,EACAC,EACAC,EACA,GAAI,EAAyB,CAACC,EAAmB,CAAG,EAAE,CACtD,GAAI,EAAsB,CAACC,EAAwB,CAAG,EAAE,CACzD,CAED,EAAU,UAAU,EAAiB,CAGjC,IACF,EAAsB,QAAQA,EAAyB,CACrD,WAAY,0BACZ,GAAI,oBACL,CAAC,CACF,EAAwB,UAAUJ,EAAuB,CACvD,WAAY,0BACZ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AAgB,KAAK,CAAE,MAAO,GAAM,CAAC,CAGvC,GACF,MAAMC,EAAmB,KAAK,CAAE,MAAO,GAAM,CAAC,CAG5C,GACF,MAAMC,EAAwB,KAAK,CAAE,MAAO,GAAM,CAAC,CAGjD,IAA+B,IACjC,MAAM,EAAc,OAAO,CAAE,KAAM,EAA8B,CAAC,CAEpE,EAAO,KAAK,+BAA+B,CACvC,EAAW,QAAU,IAA+B,IAAM,EAA6B,EAAW,OAAS,GAAG,CAGhH,IAAM,EAAqB,EAAW,MAAM,EAA6B,EAAE,CAC3E,MAAM,EAAc,QAAQ,CAAE,MAAO,CAAE,KAAM,EAAG,EAAG,IAAK,EAAmB,IAAI,GAAM,EAAU,KAAK,CAAE,CAAE,CAAE,CAAC,GAK3G,EAAiB,KAAO,IAAwC,CAGpE,GAFA,EAAO,KAAK,sDAAsD,CAE9D,CAAC,EAAU,UACb,MAAU,MAAM,kDAAkD,CAGpE,EAAU,UAAU,EAAW,CAC/B,MAAM,EAAU,WAAW,gBAAiB,CAAE,QAAS,GAAO,CAAC,CAC/D,MAAM,EAAU,aAAa,gBAAiB,CAAE,QAAS,GAAO,CAAC,CAEjE,EAAO,KAAK,mCAAmC,CAC/C,MAAMT,EAAU,KAAK,CAAE,MAAO,GAAM,CAAC,CACrC,MAAMC,EAAoB,KAAK,CAAE,MAAO,GAAM,CAAC,CAC/C,MAAME,EAAiB,KAAK,CAAE,MAAO,GAAM,CAAC,CAC5C,MAAMD,EAAsB,KAAK,CAAE,MAAO,GAAM,CAAC,CACjD,EAAO,KAAK,oCAAoC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`../../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorateMetadata.cjs`),n=require(`../../_virtual/_@oxc-project_runtime@0.97.0/helpers/decorate.cjs`),r=require(`./TestModel.cjs`);let i=require(`sequelize-typescript`);var a;let o=class extends i.Model{};n.__decorate([i.PrimaryKey,(0,i.Column)({type:i.DataType.UUID,defaultValue:i.DataType.UUIDV4,allowNull:!1}),t.__decorateMetadata(`design:type`,String)],o.prototype,`id`,void 0),n.__decorate([(0,i.ForeignKey)(()=>r.default),(0,i.Column)({type:i.DataType.UUID,allowNull:!1}),t.__decorateMetadata(`design:type`,String)],o.prototype,`testModelId`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.UUID,allowNull:!1}),t.__decorateMetadata(`design:type`,String)],o.prototype,`fleetId`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.UUID,allowNull:!0}),t.__decorateMetadata(`design:type`,String)],o.prototype,`businessModelId`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.UUID,allowNull:!0}),t.__decorateMetadata(`design:type`,String)],o.prototype,`demandSourceId`,void 0),n.__decorate([(0,i.Column)({type:i.DataType.BOOLEAN}),t.__decorateMetadata(`design:type`,Boolean)],o.prototype,`anotherAttribute`,void 0),n.__decorate([(0,i.BelongsTo)(()=>r.default),t.__decorateMetadata(`design:type`,typeof(a=r.default!==void 0&&r.default)==`function`?a:Object)],o.prototype,`testModel`,void 0),o=n.__decorate([(0,i.Table)({schema:`custom-fields`,tableName:`associated_test_models`,createdAt:!1,updatedAt:!1,modelName:`AssociatedTestModel`})],o);var s=o;exports.default=s;
|
|
2
2
|
//# sourceMappingURL=AssociatedTestModel.cjs.map
|