@autofleet/sadot 1.2.0-beta--1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/models/CustomFieldDefinition.cjs +1 -1
- package/dist/models/CustomFieldDefinition.cjs.map +1 -1
- package/dist/models/CustomFieldDefinition.d.cts +0 -1
- package/dist/models/CustomFieldDefinition.d.ts +0 -1
- 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 +1 -1
- package/dist/models/CustomFieldModelTypeMap.cjs.map +1 -1
- package/dist/models/CustomFieldModelTypeMap.js +1 -1
- package/dist/models/CustomFieldModelTypeMap.js.map +1 -1
- package/dist/models/CustomFieldValue.cjs +1 -1
- package/dist/models/CustomFieldValue.cjs.map +1 -1
- package/dist/models/CustomFieldValue.d.cts +0 -1
- package/dist/models/CustomFieldValue.d.ts +0 -1
- 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.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +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.ts +1 -1
- package/dist/utils/init.cjs +1 -1
- package/dist/utils/init.js +1 -1
- package/package.json +22 -22
- /package/dist/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.103.0}/helpers/decorate.cjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.103.0}/helpers/decorate.js +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.103.0}/helpers/decorateMetadata.cjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.97.0 → _@oxc-project_runtime@0.103.0}/helpers/decorateMetadata.js +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./utils/logger/index.cjs`),t=require(`./utils/constants/index.cjs`),n=require(`./models/
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./utils/logger/index.cjs`),t=require(`./utils/constants/index.cjs`),n=require(`./models/CustomFieldValue.cjs`),r=require(`./models/CustomFieldDefinition.cjs`),i=require(`./models/CustomFieldEntries.cjs`),a=require(`./models/CustomValidator.cjs`),o=require(`./models/index.cjs`),s=require(`./api/index.cjs`),c=require(`./utils/db/index.cjs`),l=require(`./utils/helpers/index.cjs`),u=require(`./scopes/filter.cjs`),d=require(`./utils/init.cjs`),f=require(`./utils/validations/schema/custom-fields.cjs`),p=async(t,n,r)=>{e.tryAddingTraceIdMiddleware();let{models:i,useCustomFieldsEntries:a,useModelTypeMapping:l}=r;t&&t.use(`/api`,s.default);let u=r.sequelize??c.default(r.databaseConfig);return process.env.NODE_ENV===`test`&&await o.initTestModels(u),d.addHooks(i,n,{useCustomFieldsEntries:a}),await o.initTables(u,r.getUser,{useCustomFieldsEntries:a,useModelTypeMapping:l}),d.addScopes(i,n,{useCustomFieldsEntries:a}),d.applyCustomAssociation(i),e.default.debug(`sadot - custom fields finished initializing with models`,i),u};var m=p;const h=(e,t)=>{d.removeHooks(e,t)};exports.CUSTOM_FIELDS_FILTER_SCOPE=t.CUSTOM_FIELDS_FILTER_SCOPE,exports.CustomFieldDefinition=r,exports.CustomFieldDefinitionType=t.CustomFieldDefinitionType,exports.CustomFieldEntries=i,exports.CustomFieldValue=n,exports.CustomFieldsSchema=f.CustomFieldsSchema,exports.CustomValidator=a,exports.customFieldsSortScope=u.customFieldsSortScope,exports.default=m,exports.disableCustomFields=h,exports.generateCustomFieldSearchQueryPayload=l.generateCustomFieldSearchQueryPayload,exports.generateRandomString=l.generateRandomString,exports.supportedEntities=t.supportedEntities;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CUSTOM_FIELDS_FILTER_SCOPE, CustomFieldDefinitionType, supportedEntities } from "./utils/constants/index.cjs";
|
|
2
2
|
import { CustomFieldValue } from "./models/CustomFieldValue.cjs";
|
|
3
|
-
import { CustomFieldEntries } from "./models/CustomFieldEntries.cjs";
|
|
4
|
-
import { CustomValidator } from "./models/CustomValidator.cjs";
|
|
5
|
-
import "./models/index.cjs";
|
|
6
3
|
import { CustomFieldDefinition } from "./models/CustomFieldDefinition.cjs";
|
|
4
|
+
import { CustomValidator } from "./models/CustomValidator.cjs";
|
|
7
5
|
import { CustomFieldOptions, ModelFetcher, Models } from "./types/index.cjs";
|
|
8
6
|
import { CustomFieldsSchema } from "./utils/validations/schema/custom-fields.cjs";
|
|
9
7
|
import { generateCustomFieldSearchQueryPayload, generateRandomString } from "./utils/helpers/index.cjs";
|
|
10
8
|
import { customFieldsSortScope } from "./scopes/filter.cjs";
|
|
9
|
+
import { CustomFieldEntries } from "./models/CustomFieldEntries.cjs";
|
|
10
|
+
import "./models/index.cjs";
|
|
11
11
|
import { Application } from "express";
|
|
12
12
|
import { Sequelize } from "sequelize-typescript";
|
|
13
13
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CUSTOM_FIELDS_FILTER_SCOPE, CustomFieldDefinitionType, supportedEntities } from "./utils/constants/index.js";
|
|
2
2
|
import { CustomFieldValue } from "./models/CustomFieldValue.js";
|
|
3
|
-
import { CustomFieldEntries } from "./models/CustomFieldEntries.js";
|
|
4
|
-
import { CustomValidator } from "./models/CustomValidator.js";
|
|
5
|
-
import "./models/index.js";
|
|
6
3
|
import { CustomFieldDefinition } from "./models/CustomFieldDefinition.js";
|
|
4
|
+
import { CustomValidator } from "./models/CustomValidator.js";
|
|
7
5
|
import { CustomFieldOptions, ModelFetcher, Models } from "./types/index.js";
|
|
8
6
|
import { CustomFieldsSchema } from "./utils/validations/schema/custom-fields.js";
|
|
9
7
|
import { generateCustomFieldSearchQueryPayload, generateRandomString } from "./utils/helpers/index.js";
|
|
10
8
|
import { customFieldsSortScope } from "./scopes/filter.js";
|
|
9
|
+
import { CustomFieldEntries } from "./models/CustomFieldEntries.js";
|
|
10
|
+
import "./models/index.js";
|
|
11
11
|
import { Sequelize } from "sequelize-typescript";
|
|
12
12
|
import { Application } from "express";
|
|
13
13
|
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{tryAddingTraceIdMiddleware as t}from"./utils/logger/index.js";import{CUSTOM_FIELDS_FILTER_SCOPE as n,CustomFieldDefinitionType as r,supportedEntities as i}from"./utils/constants/index.js";import a from"./models/
|
|
1
|
+
import e,{tryAddingTraceIdMiddleware as t}from"./utils/logger/index.js";import{CUSTOM_FIELDS_FILTER_SCOPE as n,CustomFieldDefinitionType as r,supportedEntities as i}from"./utils/constants/index.js";import a from"./models/CustomFieldValue.js";import o from"./models/CustomFieldDefinition.js";import s from"./models/CustomFieldEntries.js";import c from"./models/CustomValidator.js";import{initTables as l,initTestModels as u}from"./models/index.js";import d from"./api/index.js";import f from"./utils/db/index.js";import{generateCustomFieldSearchQueryPayload as p,generateRandomString as m}from"./utils/helpers/index.js";import{customFieldsSortScope as h}from"./scopes/filter.js";import{addHooks as g,addScopes as _,applyCustomAssociation as v,removeHooks as y}from"./utils/init.js";import{CustomFieldsSchema as b}from"./utils/validations/schema/custom-fields.js";var x=async(n,r,i)=>{t();let{models:a,useCustomFieldsEntries:o,useModelTypeMapping:s}=i;n&&n.use(`/api`,d);let c=i.sequelize??f(i.databaseConfig);return process.env.NODE_ENV===`test`&&await u(c),g(a,r,{useCustomFieldsEntries:o}),await l(c,i.getUser,{useCustomFieldsEntries:o,useModelTypeMapping:s}),_(a,r,{useCustomFieldsEntries:o}),v(a),e.debug(`sadot - custom fields finished initializing with models`,a),c};const S=(e,t)=>{y(e,t)};export{n as CUSTOM_FIELDS_FILTER_SCOPE,o as CustomFieldDefinition,r as CustomFieldDefinitionType,s as CustomFieldEntries,a as CustomFieldValue,b as CustomFieldsSchema,c as CustomValidator,h as customFieldsSortScope,x as default,S as disableCustomFields,p as generateCustomFieldSearchQueryPayload,m as generateRandomString,i as supportedEntities};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/logger/index.cjs`),n=require(`../utils/constants/index.cjs`),r=require(`../utils/validations/validators/index.cjs`),i=require(`../events/index.cjs`),a=require(`../errors/index.cjs`),o=require(`../utils/validations/index.cjs`),s=require(`../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../utils/logger/index.cjs`),n=require(`../utils/constants/index.cjs`),r=require(`../utils/validations/validators/index.cjs`),i=require(`../events/index.cjs`),a=require(`../errors/index.cjs`),o=require(`../utils/validations/index.cjs`),s=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs`),c=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs`),l=require(`./CustomFieldValue.cjs`);let u=require(`sequelize-typescript`);var d,f,p,m,h,g;let _=class extends u.Model{static displayNameDefaultValue(e){if(e?.displayName||(e.displayName=e.name),![null,void 0].includes(e.defaultValue)){let t=o.validateValue(e.defaultValue,e.fieldType,e.validation);if(t.error)throw new a.InvalidValueError(e.defaultValue,e.name,t.error)}}static afterSaveHandler(e,t){t.transaction?t.transaction.afterCommit(()=>i.sendDimEvent(e)):i.sendDimEvent(e)}};c.__decorate([u.PrimaryKey,(0,u.Column)({type:u.DataType.UUID,defaultValue:u.DataType.UUIDV4,allowNull:!1}),s.__decorateMetadata(`design:type`,String)],_.prototype,`id`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.STRING,allowNull:!1}),s.__decorateMetadata(`design:type`,String)],_.prototype,`name`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.STRING}),s.__decorateMetadata(`design:type`,String)],_.prototype,`displayName`,void 0),c.__decorate([(0,u.Is)(`SupportedType`,e=>{if(!Object.values(n.CustomFieldDefinitionType).includes(e))throw new a.UnsupportedCustomFieldTypeError(`"${e}" is not a supported type.`)}),(0,u.Column)({type:u.DataType.STRING,allowNull:!1}),s.__decorateMetadata(`design:type`,typeof(d=n.CustomFieldDefinitionType!==void 0&&n.CustomFieldDefinitionType)==`function`?d:Object)],_.prototype,`fieldType`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.JSONB}),s.__decorateMetadata(`design:type`,Object)],_.prototype,`validation`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.UUID,allowNull:!1}),s.__decorateMetadata(`design:type`,String)],_.prototype,`entityId`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.STRING,allowNull:!1}),s.__decorateMetadata(`design:type`,String)],_.prototype,`entityType`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.STRING,allowNull:!1}),s.__decorateMetadata(`design:type`,String)],_.prototype,`modelType`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.TEXT}),s.__decorateMetadata(`design:type`,String)],_.prototype,`description`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.BOOLEAN,defaultValue:!1}),s.__decorateMetadata(`design:type`,Boolean)],_.prototype,`required`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.BOOLEAN,defaultValue:!1}),s.__decorateMetadata(`design:type`,Boolean)],_.prototype,`disabled`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.JSONB,allowNull:!0}),s.__decorateMetadata(`design:type`,Object)],_.prototype,`defaultValue`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.DATE,allowNull:!1}),s.__decorateMetadata(`design:type`,typeof(f=typeof Date<`u`&&Date)==`function`?f:Object)],_.prototype,`createdAt`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.DATE,allowNull:!0}),s.__decorateMetadata(`design:type`,typeof(p=typeof Date<`u`&&Date)==`function`?p:Object)],_.prototype,`updatedAt`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.DATE,allowNull:!0}),s.__decorateMetadata(`design:type`,typeof(m=typeof Date<`u`&&Date)==`function`?m:Object)],_.prototype,`deletedAt`,void 0),c.__decorate([(0,u.Column)({type:u.DataType.BOOLEAN,defaultValue:!1,allowNull:!1}),s.__decorateMetadata(`design:type`,Boolean)],_.prototype,`blockEditingFromUI`,void 0),c.__decorate([(0,u.HasMany)(()=>l.default),s.__decorateMetadata(`design:type`,Array)],_.prototype,`values`,void 0),c.__decorate([u.BeforeCreate,s.__decorateMetadata(`design:type`,Function),s.__decorateMetadata(`design:paramtypes`,[typeof(h=_!==void 0&&_)==`function`?h:Object]),s.__decorateMetadata(`design:returntype`,void 0)],_,`displayNameDefaultValue`,null),c.__decorate([u.AfterSave,s.__decorateMetadata(`design:type`,Function),s.__decorateMetadata(`design:paramtypes`,[typeof(g=_!==void 0&&_)==`function`?g:Object,Object]),s.__decorateMetadata(`design:returntype`,void 0)],_,`afterSaveHandler`,null),_=c.__decorate([(0,u.DefaultScope)(()=>({where:{disabled:!1}})),(0,u.Table)({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&&r.CustomValidationTypes[this.fieldType])throw t.default.error(`No custom validation for custom field type ${this.fieldType} found`),new a.UnsupportedCustomValidationError(`Validation provided for "${this.fieldType}" is not supported`)}}})],_);var v=_;exports.default=v;
|
|
2
2
|
//# sourceMappingURL=CustomFieldDefinition.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFieldDefinition.cjs","names":["CustomFieldDefinition","Model","validateValue","InvalidValueError","sendDimEvent","PrimaryKey","DataType","CustomFieldDefinitionType","UnsupportedCustomFieldTypeError","CustomFieldValue","BeforeCreate","AfterSave","CustomValidationTypes","UnsupportedCustomValidationError"],"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
|
|
1
|
+
{"version":3,"file":"CustomFieldDefinition.cjs","names":["CustomFieldDefinition","Model","validateValue","InvalidValueError","sendDimEvent","PrimaryKey","DataType","CustomFieldDefinitionType","UnsupportedCustomFieldTypeError","CustomFieldValue","BeforeCreate","AfterSave","CustomValidationTypes","UnsupportedCustomValidationError"],"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 './CustomFieldValue';\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":"oiBAsBA,IAAA,EAAA,cAuBoCC,EAAAA,KAAM,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,EAAUC,EAAAA,cAAc,EAAS,aAAc,EAAS,UAAW,EAAS,WAAW,CAC7F,GAAI,EAAQ,MACV,MAAM,IAAIC,EAAAA,kBAAkB,EAAS,aAAc,EAAS,KAAM,EAAQ,MAAM,EAKtF,OACO,iBAAiB,EAAiC,EAA8B,CACjF,EAAQ,YACV,EAAQ,YAAY,gBAAkBC,EAAAA,aAAa,EAAS,CAAC,CAE7D,EAAA,aAAa,EAAS,iBAhIzBC,EAAAA,wBACO,CACN,KAAMC,EAAAA,SAAS,KACf,aAAcA,EAAAA,SAAS,OACvB,UAAW,GACZ,CAAC,iGAGM,CACN,KAAMA,EAAAA,SAAS,OACf,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,OAAA,IAAA,GAAA,4BAGM,CACN,KAAMA,EAAAA,SAAS,OAChB,CAAC,CAAA,EAAA,mBAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,cAAA,IAAA,GAAA,wBAGE,gBAAkB,GAAU,CAC9B,GAAI,CAAC,OAAO,OAAOC,EAAAA,0BAA0B,CAAC,SAAS,EAAmC,CACxF,MAAM,IAAIC,EAAAA,gCAAgC,IAAI,EAAM,4BAA4B,EAElF,cACM,CACN,KAAMF,EAAAA,SA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AA,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,QACf,aAAc,GACd,UAAW,GACZ,CAAC,CAAA,EAAA,mBAAA,cAAA,QAAA,CAAA,CAAA,EAAA,UAAA,qBAAA,IAAA,GAAA,iCAGaG,EAAAA,QAAiB,CAAA,EAAA,mBAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,SAAA,IAAA,GAAA,eAS/BC,EAAAA,qPAaAC,EAAAA,4QAnJkB,CAAE,MAAO,CAAE,SAAU,GAAO,CAAE,EAAE,EAAA,EAAA,EAAA,OAC9C,CACL,UAAW,2BACX,UAAW,wBACX,QAAS,CACP,CACE,KAAM,yBACN,OAAQ,CAAC,aAAc,YAAa,OAAO,CAC3C,OAAQ,GACT,CACF,CACD,WAAY,GACZ,SAAU,CACR,kBAA8C,CAE5C,GAAI,CAAC,KAAK,YAAcC,EAAAA,sBAAsB,KAAK,WAGjD,MADA,EAAA,QAAO,MAAM,8CAA8C,KAAK,UAAU,QAAQ,CAC5E,IAAIC,EAAAA,iCAAiC,4BAA4B,KAAK,UAAU,oBAAoB,EAG/G,CACF,CAAC,CAAA,CAAA,EAAA,CAuIF,IAAA,EAAe"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CustomFieldDefinitionType } from "../utils/constants/index.cjs";
|
|
2
2
|
import { CustomFieldValue } from "./CustomFieldValue.cjs";
|
|
3
3
|
import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.cjs";
|
|
4
|
-
import "./index.cjs";
|
|
5
4
|
import { Model } from "sequelize-typescript";
|
|
6
5
|
import { CreateOptions } from "sequelize";
|
|
7
6
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CustomFieldDefinitionType } from "../utils/constants/index.js";
|
|
2
2
|
import { CustomFieldValue } from "./CustomFieldValue.js";
|
|
3
3
|
import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.js";
|
|
4
|
-
import "./index.js";
|
|
5
4
|
import { CreateOptions } from "sequelize";
|
|
6
5
|
import { Model } from "sequelize-typescript";
|
|
7
6
|
|
|
@@ -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.103.0/helpers/decorateMetadata.js";import{__decorate as l}from"../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js";import u from"./CustomFieldValue.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
|
|
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 './CustomFieldValue';\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":"w1BAsBA,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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Q,CAAC,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(`../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../utils/validations/index.cjs`),r=require(`../repository/definition.cjs`),i=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs`),a=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.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])}};a.__decorate([o.PrimaryKey,(0,o.Column)({type:o.DataType.UUID,allowNull:!1}),i.__decorateMetadata(`design:type`,String)],u.prototype,`modelId`,void 0),a.__decorate([(0,o.Column)({type:o.DataType.UUID,allowNull:!1}),i.__decorateMetadata(`design:type`,String)],u.prototype,`entityId`,void 0),a.__decorate([(0,o.Column)({type:o.DataType.JSONB,allowNull:!1,defaultValue:{}}),i.__decorateMetadata(`design:type`,typeof(s=typeof Record<`u`&&Record)==`function`?s:Object)],u.prototype,`customFields`,void 0),a.__decorate([(0,o.Column)({type:o.DataType.STRING,allowNull:!1}),i.__decorateMetadata(`design:type`,String)],u.prototype,`modelType`,void 0),a.__decorate([(0,o.Column)({type:o.DataType.DATE,allowNull:!1}),i.__decorateMetadata(`design:type`,typeof(c=typeof Date<`u`&&Date)==`function`?c:Object)],u.prototype,`createdAt`,void 0),a.__decorate([(0,o.Column)({type:o.DataType.DATE,allowNull:!0}),i.__decorateMetadata(`design:type`,typeof(l=typeof Date<`u`&&Date)==`function`?l:Object)],u.prototype,`updatedAt`,void 0),a.__decorate([o.AfterUpsert,i.__decorateMetadata(`design:type`,Function),i.__decorateMetadata(`design:paramtypes`,[Array,Object]),i.__decorateMetadata(`design:returntype`,void 0)],u,`afterSaveHandler`,null),u=a.__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 r.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":"2XAaA,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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ateInstanceCustomFieldEntries as t}from"../utils/validations/index.js";import{
|
|
1
|
+
import{sendDimEvent as e}from"../events/index.js";import{validateInstanceCustomFieldEntries as t}from"../utils/validations/index.js";import{getCustomFieldDefinitionsDictionary as n}from"../repository/definition.js";import{__decorateMetadata as r}from"../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js";import{__decorate as i}from"../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.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])}};i([l,o({type:s.UUID,allowNull:!1}),r(`design:type`,String)],m.prototype,`modelId`,void 0),i([o({type:s.UUID,allowNull:!1}),r(`design:type`,String)],m.prototype,`entityId`,void 0),i([o({type:s.JSONB,allowNull:!1,defaultValue:{}}),r(`design:type`,typeof(d=typeof Record<`u`&&Record)==`function`?d:Object)],m.prototype,`customFields`,void 0),i([o({type:s.STRING,allowNull:!1}),r(`design:type`,String)],m.prototype,`modelType`,void 0),i([o({type:s.DATE,allowNull:!1}),r(`design:type`,typeof(f=typeof Date<`u`&&Date)==`function`?f:Object)],m.prototype,`createdAt`,void 0),i([o({type:s.DATE,allowNull:!0}),r(`design:type`,typeof(p=typeof Date<`u`&&Date)==`function`?p:Object)],m.prototype,`updatedAt`,void 0),i([a,r(`design:type`,Function),r(`design:paramtypes`,[Array,Object]),r(`design:returntype`,void 0)],m,`afterSaveHandler`,null),m=i([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 n([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":"0hBAaA,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"}
|
|
@@ -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.103.0/helpers/decorateMetadata.cjs`),n=require(`../_virtual/_@oxc-project_runtime@0.103.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
2
|
//# sourceMappingURL=CustomFieldModelTypeMap.cjs.map
|
|
@@ -1 +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":"
|
|
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":"2SAUA,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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import{__decorateMetadata as e}from"../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js";import{__decorate as t}from"../_virtual/_@oxc-project_runtime@0.103.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
2
|
//# sourceMappingURL=CustomFieldModelTypeMap.js.map
|
|
@@ -1 +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":"
|
|
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":"0WAUA,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(`../_virtual/_@oxc-project_runtime@0.
|
|
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(`../repository/definition.cjs`),a=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs`),o=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs`),s=require(`./CustomFieldDefinition.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 i.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 i.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])}};o.__decorate([c.PrimaryKey,(0,c.Column)({type:c.DataType.UUID,allowNull:!1}),a.__decorateMetadata(`design:type`,String)],m.prototype,`modelId`,void 0),o.__decorate([c.PrimaryKey,(0,c.ForeignKey)(()=>s.default),(0,c.Column)({type:c.DataType.UUID,allowNull:!1}),a.__decorateMetadata(`design:type`,String)],m.prototype,`customFieldDefinitionId`,void 0),o.__decorate([(0,c.Column)({type:c.DataType.JSONB,allowNull:!0}),a.__decorateMetadata(`design:type`,Object)],m.prototype,`value`,void 0),o.__decorate([(0,c.Column)({type:c.DataType.DATE,allowNull:!1}),a.__decorateMetadata(`design:type`,typeof(l=typeof Date<`u`&&Date)==`function`?l:Object)],m.prototype,`createdAt`,void 0),o.__decorate([(0,c.Column)({type:c.DataType.DATE,allowNull:!0}),a.__decorateMetadata(`design:type`,typeof(u=typeof Date<`u`&&Date)==`function`?u:Object)],m.prototype,`updatedAt`,void 0),o.__decorate([(0,c.Column)({type:c.DataType.DATE,allowNull:!0}),a.__decorateMetadata(`design:type`,typeof(d=typeof Date<`u`&&Date)==`function`?d:Object)],m.prototype,`deletedAt`,void 0),o.__decorate([(0,c.BelongsTo)(()=>s.default,{scope:{disabled:!1}}),a.__decorateMetadata(`design:type`,typeof(f=s.default!==void 0&&s.default)==`function`?f:Object)],m.prototype,`customFieldDefinition`,void 0),o.__decorate([c.BeforeBulkCreate,c.BeforeBulkUpdate,a.__decorateMetadata(`design:type`,Function),a.__decorateMetadata(`design:paramtypes`,[Array]),a.__decorateMetadata(`design:returntype`,Promise)],m,`validateCustomFieldValues`,null),o.__decorate([c.BeforeUpdate,c.BeforeCreate,c.BeforeUpsert,a.__decorateMetadata(`design:type`,Function),a.__decorateMetadata(`design:paramtypes`,[typeof(p=m!==void 0&&m)==`function`?p:Object]),a.__decorateMetadata(`design:returntype`,Promise)],m,`validateCustomFieldValue`,null),o.__decorate([c.AfterUpsert,a.__decorateMetadata(`design:type`,Function),a.__decorateMetadata(`design:paramtypes`,[Array,Object]),a.__decorateMetadata(`design:returntype`,void 0)],m,`afterSaveHandler`,null),m=o.__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
|
|
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 './CustomFieldDefinition';\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":"ycAsBA,IAAA,EAAA,cAK+BC,EAAAA,KAAM,CA2CnC,OAAe,+BACb,EACA,EACM,CACN,GAAM,CAAE,aAAY,YAAW,QAAS,EAExC,GAAI,CADqBC,EAAAA,kBAAkB,EAAU,CAEnD,MAAM,IAAIC,EAAAA,sBAAsB,EAAU,CAG5C,GAAI,EAAS,QAAU,KAAM,OAC7B,IAAM,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AA,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{findById as a,findByIds as o}from"../repository/definition.js";import{__decorateMetadata as s}from"../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js";import{__decorate as c}from"../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js";import l from"./CustomFieldDefinition.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 o(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 a(t,{withDisabled:!0});this.validateValueAgainstDefinition(e,n)}static afterSaveHandler(t,n){n.transaction?n.transaction.afterCommit(()=>e(t[0])):e(t[0])}};c([x,_({type:v.UUID,allowNull:!1}),s(`design:type`,String)],O.prototype,`modelId`,void 0),c([x,y(()=>l),_({type:v.UUID,allowNull:!1}),s(`design:type`,String)],O.prototype,`customFieldDefinitionId`,void 0),c([_({type:v.JSONB,allowNull:!0}),s(`design:type`,Object)],O.prototype,`value`,void 0),c([_({type:v.DATE,allowNull:!1}),s(`design:type`,typeof(C=typeof Date<`u`&&Date)==`function`?C:Object)],O.prototype,`createdAt`,void 0),c([_({type:v.DATE,allowNull:!0}),s(`design:type`,typeof(w=typeof Date<`u`&&Date)==`function`?w:Object)],O.prototype,`updatedAt`,void 0),c([_({type:v.DATE,allowNull:!0}),s(`design:type`,typeof(T=typeof Date<`u`&&Date)==`function`?T:Object)],O.prototype,`deletedAt`,void 0),c([g(()=>l,{scope:{disabled:!1}}),s(`design:type`,typeof(E=l!==void 0&&l)==`function`?E:Object)],O.prototype,`customFieldDefinition`,void 0),c([d,f,s(`design:type`,Function),s(`design:paramtypes`,[Array]),s(`design:returntype`,Promise)],O,`validateCustomFieldValues`,null),c([m,p,h,s(`design:type`,Function),s(`design:paramtypes`,[typeof(D=O!==void 0&&O)==`function`?D:Object]),s(`design:returntype`,Promise)],O,`validateCustomFieldValue`,null),c([u,s(`design:type`,Function),s(`design:paramtypes`,[Array,Object]),s(`design:returntype`,void 0)],O,`afterSaveHandler`,null),O=c([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
|
|
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 './CustomFieldDefinition';\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":"ixBAsBA,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,EAAyB,CAAE,aAAc,GAAM,CAAC,CACrG,KAAK,+BAA+B,EAAU,EAAK,CAGrD,OACO,iBAAiB,EAA8B,EAA8B,CAC9E,EAAQ,YACV,EAAQ,YAAY,gBAAkB,EAAa,EAAS,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
+
const e=require(`../_virtual/rolldown_runtime.cjs`),t=require(`../events/index.cjs`),n=require(`../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs`),r=require(`../_virtual/_@oxc-project_runtime@0.103.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":"8TAeA,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.103.0/helpers/decorateMetadata.js";import{__decorate as n}from"../_virtual/_@oxc-project_runtime@0.103.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":"6bAeA,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(`./CustomFieldValue.cjs`),r=require(`./CustomFieldDefinition.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=[r.default,n.default,l.default,...s?[c.default]:[],...f?[u.default]:[]];e.addModels(m),f&&(r.default.hasMany(u.default,{foreignKey:`customFieldDefinitionId`,as:`modelTypeMappings`}),u.default.belongsTo(r.default,{foreignKey:`customFieldDefinitionId`,as:`customFieldDefinition`})),r.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 r.default.sync({alter:!0}),await n.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
|
package/dist/models/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomFieldValue } from "./CustomFieldValue.cjs";
|
|
2
|
-
import { CustomFieldEntries } from "./CustomFieldEntries.cjs";
|
|
3
|
-
import { CustomValidator } from "./CustomValidator.cjs";
|
|
4
2
|
import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.cjs";
|
|
5
3
|
import { CustomFieldDefinition } from "./CustomFieldDefinition.cjs";
|
|
4
|
+
import { CustomValidator } from "./CustomValidator.cjs";
|
|
6
5
|
import "../types/index.cjs";
|
|
6
|
+
import { CustomFieldEntries } from "./CustomFieldEntries.cjs";
|
|
7
7
|
import { Sequelize } from "sequelize-typescript";
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomFieldValue } from "./CustomFieldValue.js";
|
|
2
|
-
import { CustomFieldEntries } from "./CustomFieldEntries.js";
|
|
3
|
-
import { CustomValidator } from "./CustomValidator.js";
|
|
4
2
|
import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.js";
|
|
5
3
|
import { CustomFieldDefinition } from "./CustomFieldDefinition.js";
|
|
4
|
+
import { CustomValidator } from "./CustomValidator.js";
|
|
6
5
|
import "../types/index.js";
|
|
6
|
+
import { CustomFieldEntries } from "./CustomFieldEntries.js";
|
|
7
7
|
import { Sequelize } from "sequelize-typescript";
|