@ac_packages/autocode-data-dictionary
Version:
Data dictionary package
3 lines (2 loc) • 19.8 kB
JavaScript
var e,t,r,i,s,o;!function(e){e.autoIncrement="auto_increment",e.autoNumberLength="auto_number_length",e.autoNumberPrefix="auto_number_prefix",e.checkInAutoNumber="check_in_auto_number",e.checkInModify="check_in_modify",e.checkInSave="check_in_save",e.defaultValue="default_value",e.fieldTitle="field_title",e.foreignKey="foreign_key",e.format="format",e.isSelectDistinct="is_select_distinct",e.inSearchQuery="in_search_query",e.notNull="not_null",e.remarks="remarks",e.required="required",e.primaryKey="primary_key",e.selectOptions="select_options",e.setNullBeforeDelete="set_null_before_delete",e.size="size",e.uniqueKey="unique_key"}(e||(e={})),function(e){e.autoNumber="auto_number",e.blob="blob",e.date="date",e.datetime="datetime",e.double="double",e.encrypted="encrypted",e.guid="guid",e.integer="integer",e.json="json",e.mediaJson="media_json",e.password="password",e.string="string",e.text="text",e.time="time",e.timestamp="timestamp",e.userDefinedFunction="user_defined_function"}(t||(t={}));class n{constructor(){this.cascadeDeleteDestination=!1,this.cascadeDeleteSource=!1,this.destinationField="",this.destinationTable="",this.sourceField="",this.sourceTable=""}static fromJson(e){const t=new n;return t.setValuesFromJson(e),t}static getInstances({destinationField:e,destinationTable:t,dataDictionaryName:r="default"}){let i=[],s=u.getInstance({dataDictionaryName:r});if(s.relationships[t]){let r=s.relationships[t];if(r[e]){let t=r[e];for(let e of Object.keys(t)){let r=t[e];for(let e of Object.keys(r)){let t=r[e],s=n.fromJson(t);i.push(s)}}}}return i}setValuesFromJson(e={}){e.hasOwnProperty(n.keyCascadeDeleteDestination)&&(this.cascadeDeleteDestination=e[n.keyCascadeDeleteDestination]),e.hasOwnProperty(n.keyCascadeDeleteSource)&&(this.cascadeDeleteSource=e[n.keyCascadeDeleteSource]),e.hasOwnProperty(n.keyDestinationField)&&(this.destinationField=e[n.keyDestinationField]),e.hasOwnProperty(n.keyDestinationTable)&&(this.destinationTable=e[n.keyDestinationTable]),e.hasOwnProperty(n.keySourceField)&&(this.sourceField=e[n.keySourceField]),e.hasOwnProperty(n.keySourceTable)&&(this.sourceTable=e[n.keySourceTable])}toJson(){return{[n.keyCascadeDeleteDestination]:this.cascadeDeleteDestination,[n.keyCascadeDeleteSource]:this.cascadeDeleteSource,[n.keyDestinationField]:this.destinationField,[n.keyDestinationTable]:this.destinationTable,[n.keySourceField]:this.sourceField,[n.keySourceTable]:this.sourceTable}}toString(){return JSON.stringify(this.toJson())}}n.keyCascadeDeleteDestination="cascade_delete_destination",n.keyCascadeDeleteSource="cascade_delete_source",n.keyDestinationField="destination_field",n.keyDestinationTable="destination_table",n.keySourceField="source_field",n.keySourceTable="source_table";class a{constructor(){this.propertyName="",this.propertyValue=null}static fromJson(e){const t=new a;return t.setValuesFromJson(e),t}setValuesFromJson(e={}){e.hasOwnProperty(a.keyPropertyName)&&(this.propertyName=String(e[a.keyPropertyName])),e.hasOwnProperty(a.keyPropertyValue)&&(this.propertyValue=e[a.keyPropertyValue])}toJson(){return{[a.keyPropertyName]:this.propertyName,[a.keyPropertyValue]:this.propertyValue}}toString(){return JSON.stringify(this.toJson())}}a.keyPropertyName="property_name",a.keyPropertyValue="property_value";class l{constructor(){this.fieldName="",this.fieldProperties={},this.fieldType=t.text,this.fieldValue=null,this.table=new y}get autoNumberLength(){let t=0;return this.fieldProperties&&this.fieldProperties[e.autoNumberLength]&&(t=this.fieldProperties[e.autoNumberLength].propertyValue),t}get autoNumberPrefix(){let t="";return this.fieldProperties&&this.fieldProperties[e.autoNumberPrefix]&&(t=this.fieldProperties[e.autoNumberPrefix].propertyValue),t}get checkInAutoNumber(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.checkInAutoNumber]&&(t=1==this.fieldProperties[e.checkInAutoNumber].propertyValue),t}get checkInModify(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.checkInModify]&&(t=1==this.fieldProperties[e.checkInModify].propertyValue),t}get checkInSave(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.checkInSave]&&(t=1==this.fieldProperties[e.checkInSave].propertyValue),t}get defaultValue(){let t;return this.fieldProperties&&this.fieldProperties[e.defaultValue]&&(t=1==this.fieldProperties[e.defaultValue].propertyValue),t}get fieldTitle(){let t=this.fieldName;return this.fieldProperties&&this.fieldProperties[e.fieldTitle]&&this.fieldProperties[e.fieldTitle].propertyValue&&(t=this.fieldProperties[e.fieldTitle].propertyValue),t}get foreignKey(){let e=!1;if(this.table&&this.table.tableName){e=n.getInstances({destinationTable:this.table.tableName,destinationField:this.fieldName}).length>0}return e}get foreignKeyRelationship(){let e,t=this.foreignKeyRelationships;return t.length>0&&(e=t[0]),e}get foreignKeyRelationships(){return n.getInstances({destinationField:this.fieldName,destinationTable:this.table.tableName})}get inSearchQuery(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.inSearchQuery]&&(t=1==this.fieldProperties[e.inSearchQuery].propertyValue),t}get isAutoIncrement(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.autoIncrement]&&(t=1==this.fieldProperties[e.autoIncrement].propertyValue),t}get isAutoNumber(){return this.fieldType==t.autoNumber}get isSelectDistinct(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.isSelectDistinct]&&(t=1==this.fieldProperties[e.isSelectDistinct].propertyValue),t}get notNull(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.notNull]&&(t=1==this.fieldProperties[e.notNull].propertyValue),t}get primaryKey(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.primaryKey]&&(t=1==this.fieldProperties[e.primaryKey].propertyValue),t}get required(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.required]&&(t=1==this.fieldProperties[e.required].propertyValue),t}get selectOptions(){let t=[];return this.fieldProperties&&this.fieldProperties[e.selectOptions]&&(t=this.fieldProperties[e.selectOptions].propertyValue),t}get setNullBeforeDelete(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.setNullBeforeDelete]&&(t=1==this.fieldProperties[e.setNullBeforeDelete].propertyValue),t}get size(){let t=-1;return this.fieldProperties&&this.fieldProperties[e.size]&&(t=this.fieldProperties[e.size].propertyValue),t}get uniqueKey(){let t=!1;return this.fieldProperties&&this.fieldProperties[e.uniqueKey]&&(t=1==this.fieldProperties[e.uniqueKey].propertyValue),t}static fromJson(e){const t=new l;return t.setValuesFromJson(e),t}setValuesFromJson(e={}){if(e.hasOwnProperty(l.keyFieldName)&&(this.fieldName=String(e[l.keyFieldName])),e.hasOwnProperty(l.keyFieldType)&&(this.fieldType=String(e[l.keyFieldType])),e.hasOwnProperty(l.keyFieldValue)&&(this.fieldValue=e[l.keyFieldValue]),e.hasOwnProperty(l.keyFieldProperties)){const t=e[l.keyFieldProperties];for(const e in t)t.hasOwnProperty(e)&&(this.fieldProperties[e]=a.fromJson(t[e]))}}toJson(){const e={[l.keyFieldName]:this.fieldName,[l.keyFieldType]:this.fieldType,[l.keyFieldValue]:this.fieldValue,[l.keyFieldProperties]:{}};for(const t in this.fieldProperties)this.fieldProperties.hasOwnProperty(t)&&(e[l.keyFieldProperties][t]=this.fieldProperties[t].toJson());return e}toString(){return JSON.stringify(this.toJson())}}l.keyFieldName="field_name",l.keyFieldProperties="field_properties",l.keyFieldType="field_type",l.keyFieldValue="field_value";class d{constructor(){this.propertyName="",this.propertyValue=null}static fromJson(e){const t=new d;return t.setValuesFromJson(e),t}setValuesFromJson(e={}){e.hasOwnProperty(d.keyPropertyName)&&(this.propertyName=String(e[d.keyPropertyName])),e.hasOwnProperty(d.keyPropertyValue)&&(this.propertyValue=e[d.keyPropertyValue])}toJson(){return{[d.keyPropertyName]:this.propertyName,[d.keyPropertyValue]:this.propertyValue}}toString(){return JSON.stringify(this.toJson())}}d.keyPropertyName="property_name",d.keyPropertyValue="property_value";class y{constructor(){this.tableName="",this.tableFields={},this.tableProperties={}}get primaryKeyField(){let e,t=this.primaryKeyFields;return t.length>0&&(e=t[0]),e}get primaryKeyFields(){let e=[];if(this.tableFields)for(let t of Object.keys(this.tableFields)){let r=this.tableFields[t];r.primaryKey&&e.push(r)}return e}get foreignKeyFields(){let e=[];if(this.tableFields)for(let t of Object.keys(this.tableFields)){let r=this.tableFields[t];r.foreignKey&&e.push(r)}return e}static fromJson(e){const t=new y;return t.setValuesFromJson(e),t}static getInstance({tableName:e,dataDictionaryName:t="default"}){let r=new y,i=u.getInstance({dataDictionaryName:t});return i.tables[e]&&r.setValuesFromJson(i.tables[e]),r}setValuesFromJson(e={}){if(e.hasOwnProperty(y.keyTableName)&&(this.tableName=String(e[y.keyTableName])),e.hasOwnProperty(y.keyTableFields)){const t=e[y.keyTableFields];for(const e in t)t.hasOwnProperty(e)&&(this.tableFields[e]=l.fromJson(t[e]),this.tableFields[e].table=this)}if(e.hasOwnProperty(y.keyTableProperties)){const t=e[y.keyTableProperties];for(const e in t)t.hasOwnProperty(e)&&(this.tableProperties[e]=d.fromJson(t[e]))}}toJson(){const e={[y.keyTableName]:this.tableName,[y.keyTableFields]:{},[y.keyTableProperties]:{}};for(const t in this.tableFields)this.tableFields.hasOwnProperty(t)&&(e[y.keyTableFields][t]=this.tableFields[t].toJson());for(const t in this.tableProperties)this.tableProperties.hasOwnProperty(t)&&(e[y.keyTableProperties][t]=this.tableProperties[t].toJson());return e}toString(){return JSON.stringify(this.toJson())}}y.keyTableFields="table_fields",y.keyTableName="table_name",y.keyTableProperties="table_properties";class u{constructor(){this.functions={},this.relationships={},this.storedProcedures={},this.tables={},this.triggers={},this.version=0,this.views={}}static fromJson(e){const t=new u;return t.setValuesFromJson(e),t}static getInstance({dataDictionaryName:e="default"}={}){let t=new u;return this.dataDictionaries[e]&&t.setValuesFromJson(this.dataDictionaries[e]),t}static getTables({dataDictionaryName:e="default"}={}){let t={},r=u.getInstance({dataDictionaryName:e});if(r.tables)for(let e of Object.keys(r.tables))t[e]=y.fromJson(r.tables[e]);return t}static registerDataDictionary({dataDictionaryJson:e,dataDictionaryName:t="default"}){u.dataDictionaries[t]=e}setValuesFromJson(e={}){e.hasOwnProperty(u.keyFunctions)&&(this.functions=e[u.keyFunctions]),e.hasOwnProperty(u.keyRelationships)&&(this.relationships=e[u.keyRelationships]),e.hasOwnProperty(u.keyStoredProcedures)&&(this.storedProcedures=e[u.keyStoredProcedures]),e.hasOwnProperty(u.keyTables)&&(this.tables=e[u.keyTables]),e.hasOwnProperty(u.keyTriggers)&&(this.triggers=e[u.keyTriggers]),e.hasOwnProperty(u.keyVersion)&&(this.version=e[u.keyVersion]),e.hasOwnProperty(u.keyViews)&&(this.views=e[u.keyViews])}toJson(){return{[u.keyFunctions]:this.functions,[u.keyRelationships]:this.relationships,[u.keyStoredProcedures]:this.storedProcedures,[u.keyTables]:this.tables,[u.keyVersion]:this.version,[u.keyViews]:this.views}}toString(){return JSON.stringify(this.toJson())}}u.keyFunctions="functions",u.keyRelationships="relationships",u.keyStoredProcedures="stored_procedures",u.keyTables="tables",u.keyTriggers="triggers",u.keyVersion="version",u.keyViews="views",u.dataDictionaries={};class c{constructor(){this.functionName="",this.functionCode=""}static fromJson(e){const t=new c;return t.setValuesFromJson(e),t}static getInstance({functionName:e,dataDictionaryName:t="default"}){let r=new c,i=u.getInstance({dataDictionaryName:t});return i.functions[e]&&r.setValuesFromJson(i.functions[e]),r}setValuesFromJson(e={}){e.hasOwnProperty(c.keyFunctionName)&&(this.functionName=String(e[c.keyFunctionName])),e.hasOwnProperty(c.keyFunctionCode)&&(this.functionCode=String(e[c.keyFunctionCode]))}toJson(){return{[c.keyFunctionName]:this.functionName,[c.keyFunctionCode]:this.functionCode}}toString(){return JSON.stringify(this.toJson())}}c.keyFunctionName="function_name",c.keyFunctionCode="function_code",c.keyFunctionScript="function_script",c.keyFunctionParameters="function_parameters",c.keyFunctionValueTableField="function_value_table_field";class h{constructor(){this.storedProcedureName="",this.storedProcedureCode=""}static fromJson(e){const t=new h;return t.setValuesFromJson(e),t}static getInstance({storedProcedureName:e,dataDictionaryName:t="default"}){let r=new h,i=u.getInstance({dataDictionaryName:t});return i.storedProcedures[e]&&r.setValuesFromJson(i.storedProcedures[e]),r}setValuesFromJson(e={}){e.hasOwnProperty(h.keyStoredProcedureName)&&(this.storedProcedureName=String(e[h.keyStoredProcedureName])),e.hasOwnProperty(h.keyStoredProcedureCode)&&(this.storedProcedureCode=String(e[h.keyStoredProcedureCode]))}toJson(){return{[h.keyStoredProcedureName]:this.storedProcedureName,[h.keyStoredProcedureCode]:this.storedProcedureCode}}toString(){return JSON.stringify(this.toJson())}}h.keyStoredProcedureName="stored_procedure_name",h.keyStoredProcedureCode="stored_procedure_code",function(e){e.afterDelete="after_delete",e.afterFormat="after_format",e.afterInsert="after_insert",e.afterModify="after_modify",e.afterSave="after_save",e.afterUpdate="after_update",e.beforeDelete="before_delete",e.beforeFormat="before_format",e.beforeInsert="before_insert",e.beforeModify="before_modify",e.beforeSave="before_save",e.beforeUpdate="before_update",e.unknown="unknown"}(r||(r={}));class p{constructor(){this.abortOperation=!1,this.condition="",this.eventType=r.unknown,this.newRecords=[],this.oldRecords=[],this.operation="",this.originalCondition="",this.result={},this.tableName="",this.uniqueCondition="",this.values={}}static fromJson(e){const t=new p;return t.setValuesFromJson(e),t}setValuesFromJson(e){e.hasOwnProperty(p.keyAbort)&&(this.abortOperation=e[p.keyAbort]),e.hasOwnProperty(p.keyCondition)&&(this.condition=e[p.keyCondition]),e.hasOwnProperty(p.keyEventType)&&(this.eventType=e[p.keyEventType]),e.hasOwnProperty(p.keyNewRecords)&&(this.newRecords=e[p.keyNewRecords]),e.hasOwnProperty(p.keyOldRecords)&&(this.oldRecords=e[p.keyOldRecords]),e.hasOwnProperty(p.keyOperation)&&(this.operation=e[p.keyOperation]),e.hasOwnProperty(p.keyOriginalCondition)&&(this.originalCondition=e[p.keyOriginalCondition]),e.hasOwnProperty(p.keyResult)&&(this.result=e[p.keyResult]),e.hasOwnProperty(p.keyTableName)&&(this.tableName=e[p.keyTableName]),e.hasOwnProperty(p.keyUniqueCondition)&&(this.uniqueCondition=e[p.keyUniqueCondition]),e.hasOwnProperty(p.keyValues)&&(this.values=e[p.keyValues])}toJson(){return{[p.keyAbort]:this.abortOperation,[p.keyCondition]:this.condition,[p.keyEventType]:this.eventType,[p.keyNewRecords]:this.newRecords,[p.keyOldRecords]:this.oldRecords,[p.keyOperation]:this.operation,[p.keyOriginalCondition]:this.originalCondition,[p.keyResult]:this.result,[p.keyTableName]:this.tableName,[p.keyUniqueCondition]:this.uniqueCondition,[p.keyValues]:this.values}}toString(){return JSON.stringify(this.toJson())}}p.keyAbort="abort",p.keyCondition="condition",p.keyEventType="event_type",p.keyNewRecords="new_records",p.keyOldRecords="old_records",p.keyOperation="operation",p.keyOriginalCondition="original_condition",p.keyResult="result",p.keyTableName="table_name",p.keyUniqueCondition="unique_condition",p.keyValues="values";class f{constructor(){this.rowOperation="",this.triggerExecution="",this.tableName="",this.triggerName="",this.triggerCode=""}static fromJson(e){const t=new f;return t.setValuesFromJson(e),t}static getInstance({triggerName:e,dataDictionaryName:t="default"}){let r=new f,i=u.getInstance({dataDictionaryName:t});return i.triggers[e]&&r.setValuesFromJson(i.triggers[e]),r}setValuesFromJson(e={}){e.hasOwnProperty(f.keyTriggerTableRowOperation)&&(this.rowOperation=String(e[f.keyTriggerTableRowOperation])),e.hasOwnProperty(f.keyTriggerTableName)&&(this.tableName=String(e[f.keyTriggerTableName])),e.hasOwnProperty(f.keyTriggerExecution)&&(this.triggerExecution=String(e[f.keyTriggerExecution])),e.hasOwnProperty(f.keyTriggerCode)&&(this.triggerCode=String(e[f.keyTriggerCode])),e.hasOwnProperty(f.keyTriggerName)&&(this.triggerName=String(e[f.keyTriggerName]))}toJson(){return{[f.keyTriggerName]:this.triggerName,[f.keyTriggerCode]:this.triggerCode,[f.keyTriggerTableRowOperation]:this.rowOperation,[f.keyTriggerExecution]:this.triggerExecution,[f.keyTriggerTableName]:this.tableName}}toString(){return JSON.stringify(this.toJson())}}f.keyTriggerName="trigger_name",f.keyTriggerCode="trigger_code",f.keyTriggerTableName="table_name",f.keyTriggerExecution="trigger_execution",f.keyTriggerTableRowOperation="row_operation";class k{constructor(){this.fieldName="",this.fieldProperties={},this.fieldType=t.text,this.fieldValue=null,this.fieldSource="",this.fieldSourceName=""}static fromJson(e){const t=new k;return t.setValuesFromJson(e),t}setValuesFromJson(e={}){if(e.hasOwnProperty(k.keyFieldName)&&(this.fieldName=String(e[k.keyFieldName])),e.hasOwnProperty(k.keyFieldType)&&(this.fieldType=String(e[k.keyFieldType])),e.hasOwnProperty(k.keyFieldValue)&&(this.fieldValue=e[k.keyFieldValue]),e.hasOwnProperty(k.keyFieldSource)&&(this.fieldSource=e[k.keyFieldSource]),e.hasOwnProperty(k.keyFieldSourceName)&&(this.fieldSourceName=e[k.keyFieldSourceName]),e.hasOwnProperty(k.keyFieldProperties)){const t=e[k.keyFieldProperties];for(const e in t)t.hasOwnProperty(e)&&(this.fieldProperties[e]=a.fromJson(t[e]))}}toJson(){const e={[k.keyFieldName]:this.fieldName,[k.keyFieldType]:this.fieldType,[k.keyFieldValue]:this.fieldValue,[k.keyFieldSource]:this.fieldSource,[k.keyFieldSourceName]:this.fieldSourceName,[k.keyFieldProperties]:{}};for(const t in this.fieldProperties)this.fieldProperties.hasOwnProperty(t)&&(e[k.keyFieldProperties][t]=this.fieldProperties[t].toJson());return e}toString(){return JSON.stringify(this.toJson())}}k.keyFieldName="field_name",k.keyFieldProperties="field_properties",k.keyFieldType="field_type",k.keyFieldValue="field_value",k.keyFieldSource="field_source",k.keyFieldSourceName="field_source_name";class m{constructor(){this.viewName="",this.viewQuery="",this.viewFields={}}static fromJson(e){const t=new m;return t.setValuesFromJson(e),t}static getInstance({viewName:e,dataDictionaryName:t="default"}){let r=new m,i=u.getInstance({dataDictionaryName:t});return i.views[e]&&r.setValuesFromJson(i.views[e]),r}setValuesFromJson(e={}){e.hasOwnProperty(m.keyViewName)&&(this.viewName=String(e[m.keyViewName])),e.hasOwnProperty(m.keyViewQuery)&&(this.viewQuery=String(e[m.keyViewQuery]))}toJson(){return{[m.keyViewName]:this.viewName,[m.keyViewQuery]:this.viewQuery}}toString(){return JSON.stringify(this.toJson())}}m.keyViewName="view_name",m.keyViewFields="view_fields",m.keyViewQuery="view_query",function(e){e.date="date",e.encrypt="encrypt",e.hideField="hide_field",e.json="json",e.lowercase="lowercase",e.uppercase="uppercase"}(i||(i={})),function(e){e.defaultOrderBy="default_order_by",e.index="index",e.pluralName="plural_name",e.selectQueryFields="select_query_fields",e.selectQuery="select_query",e.selectRequestFields="select_request_fields",e.selectViewName="select_view_name",e.singularName="singular_name",e.additionalFilterFields="additional_filter_fields"}(s||(s={})),function(e){e.delete="delete",e.format="format",e.insert="insert",e.save="save",e.select="select",e.update="update"}(o||(o={}));export{c as AcDDFunction,n as AcDDRelationship,h as AcDDStoredProcedure,y as AcDDTable,l as AcDDTableField,a as AcDDTableFieldProperty,d as AcDDTableProperty,p as AcDDTableRowEvent,f as AcDDTrigger,m as AcDDView,k as AcDDViewField,u as AcDataDictionary,i as AcEnumDDFieldFormat,e as AcEnumDDFieldProperty,t as AcEnumDDFieldType,s as AcEnumDDTableProperty,r as AcEnumDDTableRowEvent,o as AcEnumDDTableRowOperation};
//# sourceMappingURL=autocode-data-dictionary.esm.js.map