UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 3.31 kB
import{_ as s}from"../chunks/tslib.es6.js";import i from"../core/Error.js";import{JSONSupportMixin as e}from"../core/JSONSupport.js";import t from"../core/Loadable.js";import{generateUUID as r}from"../core/uuid.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";let a=class extends(e(t)){read(s,i){this.sourceJSON=s,super.read(s,i)}constructor(s){super(s),this._sessionId=null,this.url=null,this.sourceJSON=null,this.id=null,this.description=null,this.creationDate=null,this.access="private"}load(s){return this.addResolvingPromise(this._loadFromSource()),Promise.resolve(this)}async startReading(){if(this.url){const{startReading:s}=await import("../rest/versionManagementService/gdbVersion/startReading.js");this._sessionId||(this._sessionId=`{${r()}}`);return await s(this.url,this.guid,this._sessionId)}throw new i("gdb-version:missing-url","service url is missing")}async stopReading(){if(this.url){if(!this._sessionId)throw new i("gdb-version:missing-session-id","reading session has not been started");const{stopReading:s}=await import("../rest/versionManagementService/gdbVersion/stopReading.js"),e=await s(this.url,this.guid,this._sessionId);return e&&(this._sessionId=null),e}throw new i("gdb-version:missing-url","service url is missing")}async startEditing(){if(this.url){if(!this._sessionId)throw new i("gdb-version:missing-session-id","reading session has not been started");const{startEditing:s}=await import("../rest/versionManagementService/gdbVersion/startEditing.js");return await s(this.url,this.guid,this._sessionId)}throw new i("gdb-version:missing-url","service url is missing")}async stopEditing(s){if(this.url){if(!this._sessionId)throw new i("gdb-version:missing-session-id","reading session has not been started");const{stopEditing:e}=await import("../rest/versionManagementService/gdbVersion/stopEditing.js");return await e(this.url,this.guid,this._sessionId,s)}throw new i("gdb-version:missing-url","service url is missing")}async getStatusInfo(){if(this.url){return await this._loadFromUrl(this.url,this.guid)}throw new i("gdb-version:missing-url","service url is missing")}async _loadFromSource(){this.sourceJSON&&this.read(this.sourceJSON),this.url&&this.guid&&await this._loadFromUrl(this.url,this.guid)}async _loadFromUrl(s,i){const{getVersion:e}=await import("../rest/versionManagementService/getVersion.js"),t=await e(s,i);return t&&this.read(t),t}};s([o()],a.prototype,"_sessionId",void 0),s([o()],a.prototype,"url",void 0),s([o()],a.prototype,"sourceJSON",void 0),s([o({type:String,json:{name:"versionName",write:!0}})],a.prototype,"name",void 0),s([o({type:String,json:{name:"versionGuid",write:!0}})],a.prototype,"guid",void 0),s([o({type:Number,json:{name:"versionId",write:!0}})],a.prototype,"id",void 0),s([o({type:String,json:{write:!0}})],a.prototype,"description",void 0),s([o({type:Date,json:{type:Number,write:{writer:(s,i)=>{i.creationDate=s?s.getTime():null}}}})],a.prototype,"creationDate",void 0),s([o({type:["private","public","protected","hidden"],json:{write:!0}})],a.prototype,"access",void 0),a=s([n("esri.versionManagementService.GDBVersion")],a);const d=a;export{d as default};