fms-odata-js 0.3.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.
@@ -0,0 +1,6 @@
1
+ var y=class extends Error{constructor(t,e){super(t),this.name="FMSODataError",this.status=e.status,e.code!==void 0&&(this.code=e.code),e.odataError!==void 0&&(this.odataError=e.odataError),e.request!==void 0&&(this.request=e.request)}};async function H(r,t){let e=r.status,n="";try{n=await r.text()}catch{}let i,s=r.statusText||`HTTP ${e}`,o=n,a=(r.headers.get("content-type")??"").toLowerCase(),c=a.includes("json")||n.startsWith("{")&&n.endsWith("}"),u=a.includes("xml")||n.trimStart().startsWith("<?xml")||n.includes("<m:error");if(c)try{let p=JSON.parse(n);o=p;let l=p?.error?.code,g=p?.error?.message,F=typeof g=="string"?g:g?.value;l&&(i=String(l)),F&&(s=F)}catch{}else if(u){let p=n.match(/<m:code>([^<]+)<\/m:code>/),l=n.match(/<m:message(?:\s[^>]*)?>([^<]+)<\/m:message>/);p?.[1]&&(i=p[1]),l?.[1]&&(s=l[1])}return new y(s,{status:e,...i!==void 0?{code:i}:{},odataError:o,request:t})}var w=class extends y{constructor(t,e){super(t,{status:e.status,code:e.scriptError,...e.odataError!==void 0?{odataError:e.odataError}:{},...e.request!==void 0?{request:e.request}:{}}),this.name="FMScriptError",this.scriptError=e.scriptError,e.scriptResult!==void 0&&(this.scriptResult=e.scriptResult)}};function J(r){return r instanceof y}function ot(r){return r instanceof w}var at=/^(basic|bearer|fmid|negotiate|digest)\s+\S/i;async function ct(r){let t=typeof r=="function"?await r():r;if(typeof t!="string"||t.length===0)throw new TypeError("fms-odata-js: token resolver produced an empty value");return at.test(t)?t:`Bearer ${t}`}function ut(r,t){let e=`${r}:${t}`;return`Basic ${typeof Buffer<"u"?Buffer.from(e,"utf8").toString("base64"):btoa(unescape(encodeURIComponent(e)))}`}function pt(r){return`FMID ${r}`}function dt(r){let t=r.filter(n=>n!==void 0);if(t.length===0)return;if(t.length===1)return t[0];let e=new AbortController;for(let n of t){if(n.aborted)return e.abort(n.reason),e.signal;n.addEventListener("abort",()=>e.abort(n.reason),{once:!0})}return e.signal}var lt={json:"application/json",xml:"application/xml",text:"text/plain",binary:"application/octet-stream",none:"*/*"};async function f(r,t,e={}){return W(r,t,e,!1)}async function W(r,t,e,n){let i=e.method??"GET",s=new Headers(e.headers);s.set("Authorization",await ct(r.token)),s.has("OData-Version")||s.set("OData-Version","4.0"),s.has("OData-MaxVersion")||s.set("OData-MaxVersion","4.0"),s.has("Accept")||s.set("Accept",lt[e.accept??"json"]);let o=new AbortController,a=r.timeoutMs&&r.timeoutMs>0?setTimeout(()=>o.abort(new Error(`Timeout after ${r.timeoutMs}ms`)),r.timeoutMs):void 0,c=dt([e.signal,r.timeoutMs?o.signal:void 0]),u;try{u=await r.fetch(t,{method:i,headers:s,keepalive:!0,...e.body!==void 0?{body:e.body}:{},...c?{signal:c}:{}})}catch(p){throw a&&clearTimeout(a),p}if(a&&clearTimeout(a),u.status===401&&r.onUnauthorized&&!n)return await r.onUnauthorized(),W(r,t,e,!0);if(!u.ok)throw await H(u,{url:t,method:i});return u}async function m(r,t,e={}){let n=await f(r,t,e);if(n.status===204)return;let i=(n.headers.get("content-type")??"").toLowerCase();if(!i.includes("json")){let s=await n.text();if(!s)return;try{return JSON.parse(s)}catch{throw new y(`Expected JSON response, got "${i||"no content-type"}"`,{status:n.status,odataError:s,request:{url:t,method:e.method??"GET"}})}}return await n.json()}function S(r){return r.replace(/'/g,"''")}function ft(r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new TypeError("formatDateTime: invalid Date");return r.toISOString().replace(/\.\d{3}Z$/,"Z")}function x(r){if(r==null)return"null";if(typeof r=="string")return`'${S(r)}'`;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`formatLiteral: cannot encode non-finite number: ${r}`);return String(r)}if(typeof r=="boolean")return r?"true":"false";if(r instanceof Date)return ft(r);throw new TypeError(`formatLiteral: unsupported OData literal type: ${typeof r}`)}function h(r){return encodeURIComponent(r)}function $(r){return encodeURIComponent(r).replace(/%2C/gi,",").replace(/%24/g,"$").replace(/%3D/g,"=").replace(/%3B/g,";").replace(/%28/g,"(").replace(/%29/g,")")}function G(r){let t=[];for(let[e,n]of r)n===""||n===void 0||n===null||t.push(`${e}=${$(n)}`);return t.join("&")}function ht(r){return typeof TextEncoder<"u"?new TextEncoder().encode(r).byteLength:Buffer.byteLength(r,"utf8")}function Q(r){let t=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${r}_${t}`}function Y(r,t,e){let n=[];e?.$top!==void 0&&n.push(`$top=${$(String(e.$top))}`),e?.$skip!==void 0&&n.push(`$skip=${$(String(e.$skip))}`),e?.$filter&&n.push(`$filter=${$(e.$filter)}`),e?.$select&&n.push(`$select=${$(e.$select)}`);let i=n.join("&"),s=h(t);return i?`${r}/${s}?${i}`:`${r}/${s}`}function z(r,t,e){let n=h(t),i;if(typeof e=="number")i=String(e);else if(typeof e=="string")i=`'${e.replace(/'/g,"''")}'`;else if(typeof e=="boolean")i=e?"true":"false";else throw new TypeError("Batch: unsupported key type");return`${r}/${n}(${i})`}var I=class{constructor(t){this._ops=[];this._handles=[];this._baseUrl=t}get _operations(){return this._ops}get _handleSlots(){return this._handles}create(t,e){let n=Y(this._baseUrl,t),i,s,o=new Promise((c,u)=>{i=c,s=u}),a=this._handles.length;return this._handles.push({resolve:i,reject:s}),this._ops.push({method:"POST",path:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),{__brand:"BatchHandle",_promise:o,_index:a}}patch(t,e,n,i){let s=z(this._baseUrl,t,e),o={"Content-Type":"application/json"};i?.ifMatch&&(o["If-Match"]=i.ifMatch);let a,c,u=new Promise((l,g)=>{a=l,c=g}),p=this._handles.length;return this._handles.push({resolve:a,reject:c}),this._ops.push({method:"PATCH",path:s,headers:o,body:JSON.stringify(n)}),{__brand:"BatchHandle",_promise:u,_index:p}}delete(t,e,n){let i=z(this._baseUrl,t,e),s={};n?.ifMatch&&(s["If-Match"]=n.ifMatch);let o,a,c=new Promise((p,l)=>{o=p,a=l}),u=this._handles.length;return this._handles.push({resolve:o,reject:a}),this._ops.push({method:"DELETE",path:i,headers:s}),{__brand:"BatchHandle",_promise:c,_index:u}}},D=class{constructor(t){this._parts=[];this._changesets=[];this._client=t}add(t){let e=Y(this._client.baseUrl,t.entitySet,t.query),n,i,o={__brand:"BatchHandle",_promise:new Promise((a,c)=>{n=a,i=c}),_index:this._parts.length};return this._parts.push({type:"read",content:{method:"GET",path:e},handle:o}),o}changeset(t){let e=new I(this._client.baseUrl);t(e),this._changesets.push(e),this._parts.push({type:"changeset",content:e})}_serialize(){let t=Q("batch"),e=[];for(let n of this._parts)if(e.push(`--${t}`),n.type==="read"){let i=n.content;e.push("Content-Type: application/http"),e.push("Content-Transfer-Encoding: binary"),e.push(""),e.push(`${i.method} ${i.path} HTTP/1.1`)}else if(n.type==="changeset"){let i=n.content,s=Q("changeset");e.push("Content-Type: multipart/mixed; boundary="+s),e.push("");for(let o of i._operations){if(e.push(`--${s}`),e.push("Content-Type: application/http"),e.push("Content-Transfer-Encoding: binary"),e.push(""),e.push(`${o.method} ${o.path} HTTP/1.1`),o.headers)for(let[a,c]of Object.entries(o.headers))e.push(`${a}: ${c}`);o.body&&(e.push(`Content-Length: ${ht(o.body)}`),e.push(""),e.push(o.body))}e.push(`--${s}--`)}return e.push(`--${t}--`),{boundary:t,body:e.join(`\r
2
+ `)}}async send(t={}){let{boundary:e,body:n}=this._serialize(),i=await f(this._client._ctx,`${this._client.baseUrl}/$batch`,{method:"POST",headers:{"Content-Type":`multipart/mixed; boundary=${e}`},body:n,accept:"none",...t.signal?{signal:t.signal}:{}}),s=await i.text();return this._parseResponse(s,i.headers.get("content-type")??"")}_parseResponse(t,e){let i=e.match(/boundary=([^;\s]+)/)?.[1];if(!i)throw new Error("Batch response missing boundary in Content-Type");let s=t.split(`--${i}`),o=[],a=0;for(let c=1;c<s.length-1;c++){let u=s[c].trim();if(!u||u==="--")continue;let p=this._parts[a];if(p){if(p.type==="read"){let l=this._parseHttpPart(u);o.push(l),p.handle&&this._resolveHandle(p.handle,l),a++}else if(p.type==="changeset"){let l=p.content,g=this._parseChangesetResponse(u,l);o.push(...g);let F=g.find(R=>!R.ok);for(let R=0;R<l._handleSlots.length;R++){let V=l._handleSlots[R],q=g[R];F?V.reject(new Error(`Changeset failed: ${F.status}`)):q?V.resolve(q.body):V.resolve(void 0)}a++}}}return{responses:o,ok:o.every(c=>c.ok)}}_parseHttpPart(t){let e=t.indexOf(`\r
3
+ \r
4
+ `),n=e>=0?t.slice(e+4):t,i=n.indexOf(`\r
5
+ \r
6
+ `),s=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+4).trim():"",a=s.match(/^HTTP\/1\.\d (\d+)/),c=a?parseInt(a[1],10):0,u;if(o&&s.toLowerCase().includes("application/json"))try{u=JSON.parse(o)}catch{u=o}else o&&(u=o);return{status:c,body:u,headers:new Headers,ok:c>=200&&c<300}}_parseChangesetResponse(t,e){let i=t.match(/boundary=([^\s]+)/)?.[1];if(!i)return[this._parseHttpPart(t)];let s=t.split(`--${i}`),o=[];for(let a=1;a<s.length-1;a++){let c=s[a].trim();!c||c==="--"||o.push(this._parseHttpPart(c))}return o}_resolveHandle(t,e){}};var mt={19:"FileMaker 19.x",21:"Claris FileMaker 2023",22:"Claris FileMaker 2024",26:"Claris FileMaker 2026",future:"Future / next"},gt="4.0",E={19:{major:"19",name:"FileMaker 19.x",releaseYear:null,internalVersion:"19.x",status:"baseline",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!1,scriptListing:!1,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!1,webhookQueryHeaders:!1,applyAggregation:!1,typeCasting:!1,parameterizedFilters:!1,immutableIdUrls:!1,aiAnnotation:!1,serverVersionAnnotation:!1,enrichedFMComment:!1,authBasic:!0,authFMID:!1,authOAuth:!1},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!1,$search:!1,$compute:!1}},21:{major:"21",name:"Claris FileMaker 2023",releaseYear:2023,internalVersion:"21.x",status:"supported",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!1,scriptListing:!1,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!1,applyAggregation:!1,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!1,aiAnnotation:!1,serverVersionAnnotation:!1,enrichedFMComment:!1,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!1,$search:!1,$compute:!1}},22:{major:"22",name:"Claris FileMaker 2024",releaseYear:2024,internalVersion:"22.x",status:"supported",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!1,scriptListing:!1,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!0,applyAggregation:!0,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!1,aiAnnotation:!1,serverVersionAnnotation:!1,enrichedFMComment:!1,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!0,$search:!1,$compute:!1}},26:{major:"26",name:"Claris FileMaker 2026",releaseYear:2026,internalVersion:"26.x",status:"current",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!0,scriptListing:!0,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!0,applyAggregation:!0,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!0,aiAnnotation:!0,serverVersionAnnotation:!0,enrichedFMComment:!0,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!0,$search:!1,$compute:!1}},future:{major:"future",name:"Future / next",releaseYear:null,internalVersion:"unknown",status:"future",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!0,scriptListing:!0,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!0,applyAggregation:!0,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!0,aiAnnotation:!0,serverVersionAnnotation:!0,enrichedFMComment:!0,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!0,$search:!1,$compute:!1}}};function L(r,t){return E[r]?.features[t]??!1}function yt(r,t){return E[r]?.queryOptions[t]??!1}function xt(r){let t=["19","21","22","26"];for(let e of t)if(E[e].features[r])return e;return null}function O(r){let t=r.trim().match(/(\d+)\.(\d+)\.(\d+)/);return t?{major:parseInt(t[1],10),minor:parseInt(t[2],10),patch:parseInt(t[3],10),raw:r.trim()}:null}function N(r){if(!r||typeof r!="string")return null;let t=r.match(/Term\s*=\s*["']Org\.OData\.Core\.V1\.ProductVersion["'][^>]*String\s*=\s*["']([^"']+)["']/);if(t){let o=O(t[1]);if(o)return o}let e=r.match(/String\s*=\s*["']([^"']+)["'][^>]*Term\s*=\s*["']Org\.OData\.Core\.V1\.ProductVersion["']/);if(e){let o=O(e[1]);if(o)return o}let n=r.match(/Term\s*=\s*["']ServerVersion["'][^>]*String\s*=\s*["']([^"']+)["']/i);if(n){let o=O(n[1]);if(o&&o.major>=17)return o}let i=r.match(/String\s*=\s*["']([^"']+)["'][^>]*Term\s*=\s*["']ServerVersion["']/i);if(i){let o=O(i[1]);if(o&&o.major>=17)return o}let s=r.match(/Term\s*=\s*["'][^"']*Version[^"']*["'][^>]*String\s*=\s*["'][^"']*?(\d{2,}\.\d+\.\d+(?:\.\d+)?)[^"']*?["']/i);if(s){let o=O(s[1]);if(o&&o.major>=17)return o}return null}function bt(r,t){return r===void 0?t:r==="true"}function j(r,t){let e=new RegExp(`${t}="([^"]*)"`,"i");return r.match(e)?.[1]}function C(r){let t={},e=/(\w+)="([^"]*)"/g,n;for(;(n=e.exec(r))!==null;)t[n[1]]=n[2];return t}function b(r,t){let e=[],n=new RegExp(`<([\\w]+:)?${t}\\b[^>]*>`,"gi"),i;for(;(i=n.exec(r))!==null;){let s=i[0];if(/\/>\s*$/.test(s)){e.push(s);continue}let o=i.index,a=new RegExp(`</([\\w]+:)?${t}>`,"gi");a.lastIndex=n.lastIndex;let c=a.exec(r);c&&e.push(r.slice(o,c.index+c[0].length))}return e}function k(r,t){let n=new RegExp(`<(?:[\\w]+:)?${t}\\b[^>]*>`,"i").exec(r);if(!n)return;let i=n.index+n[0].length,s=new RegExp(`</(?:[\\w]+:)?${t}>`,"i");s.lastIndex=i;let o=s.exec(r);if(o)return r.slice(i,o.index)}function St(r){let t=C(r),e=bt(t.Nullable,!0),n={name:t.Name??"",type:t.Type??"",nullable:e};if(t.MaxLength!==void 0){let i=parseInt(t.MaxLength,10);Number.isNaN(i)||(n.maxLength=i)}return n}function Et(r){let t=C(r),e=t.Type??"",n=e.startsWith("Collection("),i=n?e.slice(11,-1):e;return{name:t.Name??"",target:i,collection:n}}function Tt(r){let t=[],e=b(r,"PropertyRef");for(let n of e){let i=j(n,"Name");i&&t.push(i)}return t}function Rt(r){let t=j(r,"Name")??"",e=[],n=[],i=[],s=k(r,"EntityType")??r,o=b(s,"Key")[0];o&&e.push(...Tt(o));for(let a of b(s,"Property"))n.push(St(a));for(let a of b(s,"NavigationProperty"))i.push(Et(a));return{name:t,keys:e,properties:n,navigationProperties:i}}function wt(r){let t=C(r);return{name:t.Name??"",entityType:t.EntityType??""}}function $t(r){return N(r)??void 0}function Ot(r){let t=j(r,"Name")??"",e=C(r),n=e.IsBound==="true"?e.EntityType:void 0,i=[],s=k(r,"Action")??r;for(let o of b(s,"Parameter")){let a=C(o);i.push({name:a.Name??"",type:a.Type??""})}return n!==void 0?{name:t,boundTo:n,parameters:i}:{name:t,parameters:i}}function _t(r){try{let t=k(r,"DataServices");if(!t)throw new Error("Missing <edmx:DataServices> in metadata");let e=b(t,"Schema")[0];if(!e)throw new Error("Missing <Schema> in metadata");let n=j(e,"Namespace")??"",i=k(e,"Schema")??e,s=[];for(let l of b(i,"EntityType"))s.push(Rt(l));let o=[],a=b(i,"EntityContainer")[0];if(a){let l=k(a,"EntityContainer")??a;for(let g of b(l,"EntitySet"))o.push(wt(g))}let c=[];for(let l of b(i,"Action"))c.push(Ot(l));let u=$t(r),p={namespace:n,entityTypes:s,entitySets:o,actions:c,raw:r};return u&&(p.serverVersion=u,p.productVersion=u.raw),p}catch(t){let e=t instanceof Error?t.message:String(t);throw new y(`Failed to parse $metadata: ${e}`,{status:0,odataError:r.slice(0,500)})}}async function Mt(r,t,e={}){return(await f(r,`${t}/$metadata`,{method:"GET",accept:"xml",...e.signal?{signal:e.signal}:{}})).text()}var _=class{constructor(t,e){this._ctx=t;this._baseUrl=e}async fetchXml(t={}){return Mt(this._ctx,this._baseUrl,t)}async fetch(t={}){if(!t.refresh&&this._cache)return this._cache;let e=this.fetchXml(t).then(_t);return this._cache=e,e}};var U=["image/png","image/jpeg","image/gif","image/tiff","application/pdf"];function Ft(r){return(r.split(";")[0]??"").trim().toLowerCase()}function Dt(r){let t=Ft(r);return U.includes(t)}function X(r){if(r.length>=8&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71&&r[4]===13&&r[5]===10&&r[6]===26&&r[7]===10)return"image/png";if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"image/jpeg";if(r.length>=4&&r[0]===71&&r[1]===73&&r[2]===70&&r[3]===56)return"image/gif";if(r.length>=4&&(r[0]===73&&r[1]===73&&r[2]===42&&r[3]===0||r[0]===77&&r[1]===77&&r[2]===0&&r[3]===42))return"image/tiff";if(r.length>=4&&r[0]===37&&r[1]===80&&r[2]===68&&r[3]===70)return"application/pdf"}var v=class{constructor(t,e){if(!e)throw new TypeError("ContainerRef: fieldName is required");this._entity=t,this.fieldName=e}url(){return`${this._entity.toURL()}/${h(this.fieldName)}`}_valueUrl(){return`${this.url()}/$value`}async get(t={}){let e=await f(this._entity._client._ctx,this._valueUrl(),{method:"GET",accept:"none",...t.signal?{signal:t.signal}:{}}),n=e.headers.get("content-type")??"",i=e.headers.get("content-disposition"),s=i?kt(i):void 0,o=await e.blob(),a={blob:o,contentType:n,size:o.size};return s!==void 0&&(a.filename=s),a}async getStream(t={}){let e=await f(this._entity._client._ctx,this._valueUrl(),{method:"GET",accept:"none",...t.signal?{signal:t.signal}:{}});if(!e.body)throw new TypeError("ContainerRef.getStream: response has no body");return e.body}async upload(t,e={}){let n=t.encoding??"binary",i=await vt(t.data),s=t.contentType;if(!s){let a=X(i);if(!a)throw new TypeError(`ContainerRef.upload: contentType is required and could not be sniffed from the payload. Pass a contentType explicitly (one of ${U.join(", ")}).`);s=a}if(n==="binary"){if(!Dt(s))throw new TypeError(`ContainerRef.upload (binary): contentType "${s}" is not a FileMaker-supported container type. Use one of ${U.join(", ")}, or switch to { encoding: 'base64' }.`);let a={"Content-Type":s};t.filename&&(a["Content-Disposition"]=Ct(t.filename));let c=new ArrayBuffer(i.byteLength);new Uint8Array(c).set(i),await f(this._entity._client._ctx,this.url(),{method:"PATCH",headers:a,body:c,accept:"none",...e.signal?{signal:e.signal}:{}});return}let o=M({[this.fieldName]:{data:Z(i),contentType:s,...t.filename?{filename:t.filename}:{}}});await f(this._entity._client._ctx,this._entity.toURL(),{method:"PATCH",headers:{"Content-Type":"application/json",Prefer:"return=minimal"},body:JSON.stringify(o),accept:"none",...e.signal?{signal:e.signal}:{}})}async delete(t={}){let e={[this.fieldName]:null};await f(this._entity._client._ctx,this._entity.toURL(),{method:"PATCH",headers:{"Content-Type":"application/json",Prefer:"return=minimal"},body:JSON.stringify(e),accept:"none",...t.signal?{signal:t.signal}:{}})}};function M(r,t={}){let e={...t};for(let[n,i]of Object.entries(r)){if(!i.contentType)throw new TypeError(`buildContainerJsonBody: "${n}".contentType is required`);e[n]=i.data,e[`${n}@com.filemaker.odata.ContentType`]=i.contentType,i.filename&&(e[`${n}@com.filemaker.odata.Filename`]=i.filename)}return e}function kt(r){let t=r.match(/filename\*\s*=\s*([^']+)'[^']*'([^;]+)/i);if(t){let n=t[1].trim().toLowerCase(),i=t[2].trim();try{let s=decodeURIComponent(i);return s}catch{}}let e=r.match(/filename\s*=\s*("([^"\\]*(?:\\.[^"\\]*)*)"|([^;]+))/i);if(e){let n=e[2];if(n!==void 0)return n.replace(/\\(.)/g,"$1").trim();let i=e[3];if(i!==void 0)return i.trim()}}function Ct(r){let t=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,e=/[^\x00-\x7F]/.test(r),n;return t.test(r)?n=`inline; filename=${r}`:n=`inline; filename="${r.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"`,e?`${n}; filename*=UTF-8''${encodeURIComponent(r)}`:n}async function vt(r){if(r instanceof Uint8Array)return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);let t=await r.arrayBuffer();return new Uint8Array(t)}function Z(r){if(typeof Buffer<"u")return Buffer.from(r).toString("base64");let t="",e=32768;for(let n=0;n<r.length;n+=e)t+=String.fromCharCode.apply(null,Array.from(r.subarray(n,n+e)));return btoa(t)}function Pt(r){if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError("ScriptInvoker: key must be a finite number");return String(r)}if(typeof r=="string")return`'${S(r)}'`;if(typeof r=="boolean")return r?"true":"false";throw new TypeError("ScriptInvoker: unsupported key type")}var T=class{constructor(t,e={}){this._client=t,e.entitySet!==void 0&&(this.entitySet=e.entitySet),e.key!==void 0&&(this.key=e.key)}url(t){if(!t)throw new TypeError("ScriptInvoker: script name is required");return this._urlForSegment(`Script.${h(t)}`)}urlById(t){if(!Number.isFinite(t))throw new TypeError("ScriptInvoker: fmsid must be a finite number");return this._urlForSegment(`Script.FMSID:${t}`)}_urlForSegment(t){let e=this._client.baseUrl;if(this.entitySet===void 0)return`${e}/${t}`;let n=h(this.entitySet);return this.key===void 0?`${e}/${n}/${t}`:`${e}/${n}(${Pt(this.key)})/${t}`}async run(t,e={}){return this._runAtUrl(this.url(t),e)}async runById(t,e={}){return this._runAtUrl(this.urlById(t),e)}async _runAtUrl(t,e){let n={},i;e.parameter!==void 0&&(n["Content-Type"]="application/json",i=JSON.stringify({scriptParameterValue:e.parameter}));let s="POST",o=await m(this._client._ctx,t,{method:s,headers:n,...i!==void 0?{body:i}:{},accept:"json",...e.signal?{signal:e.signal}:{}});return At(o,{url:t,method:s})}};function At(r,t){let e=It(r),n=e.scriptResult,i,s;if(n!==null&&typeof n=="object"&&"resultParameter"in n){let a=n;s=a.code!==void 0?String(a.code):"0",i=a.resultParameter!==void 0?String(a.resultParameter):void 0}else s=e.scriptError!==void 0?String(e.scriptError):"0",i=n!==void 0?typeof n=="string"?n:JSON.stringify(n):void 0;if(s!=="0")throw new w(`FileMaker script error ${s}`,{status:200,scriptError:s,...i!==void 0?{scriptResult:i}:{},odataError:r,request:t});let o={scriptError:s,raw:r};return i!==void 0&&(o.scriptResult=i),o}function It(r){if(r===null||typeof r!="object")return{};let t=r;if("scriptError"in t||"scriptResult"in t)return t;for(let e of Object.values(t))if(e&&typeof e=="object"){let n=e;if("scriptError"in n||"scriptResult"in n)return n}return{}}function K(r,t,e){return new T(r).run(t,e)}function tt(r,t,e){return new T(r).runById(t,e)}function et(r,t,e,n){return new T(r,{entitySet:t}).run(e,n)}function rt(r,t,e,n,i){return new T(r,{entitySet:t,key:e}).run(n,i)}function jt(r){if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError("EntityRef: key must be a finite number");return String(r)}if(typeof r=="string")return`'${S(r)}'`;if(typeof r=="boolean")return r?"true":"false";throw new TypeError("EntityRef: unsupported key type")}var P=class{constructor(t,e,n){this._client=t,this.entitySet=e,this.key=n}toURL(){return`${this._client.baseUrl}/${h(this.entitySet)}(${jt(this.key)})`}async get(t={}){return await m(this._client._ctx,this.toURL(),{method:"GET",accept:"json",...t.signal?{signal:t.signal}:{}})}async fieldValue(t,e={}){let n=`${this.toURL()}/${h(t)}`;return(await m(this._client._ctx,n,{method:"GET",accept:"json",...e.signal?{signal:e.signal}:{}})).value}async patch(t,e={}){let n={"Content-Type":"application/json",Prefer:e.returnRepresentation?"return=representation":"return=minimal"};return e.ifMatch&&(n["If-Match"]=e.ifMatch),await m(this._client._ctx,this.toURL(),{method:"PATCH",headers:n,body:JSON.stringify(t),accept:"json",...e.signal?{signal:e.signal}:{}})}async delete(t={}){let e={};t.ifMatch&&(e["If-Match"]=t.ifMatch),await f(this._client._ctx,this.toURL(),{method:"DELETE",headers:e,accept:"none",...t.signal?{signal:t.signal}:{}})}async script(t,e={}){return rt(this._client,this.entitySet,this.key,t,e)}container(t){return new v(this,t)}async patchContainers(t,e={},n={}){let i={"Content-Type":"application/json",Prefer:n.returnRepresentation?"return=representation":"return=minimal"};n.ifMatch&&(i["If-Match"]=n.ifMatch);let s=M(t,e);await f(this._client._ctx,this.toURL(),{method:"PATCH",headers:i,body:JSON.stringify(s),accept:"none",...n.signal?{signal:n.signal}:{}})}async getRefs(t,e={}){let n=`${this.toURL()}/${h(t)}/$ref`,i=await m(this._client._ctx,n,{method:"GET",accept:"json",...e.signal?{signal:e.signal}:{}});return i?.value?i.value:i?.["@odata.id"]?[i]:[]}async addRef(t,e,n={}){let i=`${this.toURL()}/${h(t)}/$ref`,s={"Content-Type":"application/json"};n.ifMatch&&(s["If-Match"]=n.ifMatch);let o=JSON.stringify({"@odata.id":this._refId(t,e)});await f(this._client._ctx,i,{method:"POST",headers:s,body:o,accept:"none",...n.signal?{signal:n.signal}:{}})}async setRef(t,e,n={}){let i=`${this.toURL()}/${h(t)}/$ref`,s={"Content-Type":"application/json"};n.ifMatch&&(s["If-Match"]=n.ifMatch);let o=JSON.stringify({"@odata.id":this._refId(t,e)});await f(this._client._ctx,i,{method:"PATCH",headers:s,body:o,accept:"none",...n.signal?{signal:n.signal}:{}})}async removeRef(t,e,n={}){let i=`${this.toURL()}/${h(t)}/$ref`,s={};n.ifMatch&&(s["If-Match"]=n.ifMatch),e!==void 0&&(i+=`('${S(this._refId(t,e))}')`),await f(this._client._ctx,i,{method:"DELETE",headers:s,accept:"none",...n.signal?{signal:n.signal}:{}})}_refId(t,e){let n=t;return typeof e=="number"?`${n}(${e})`:`${n}('${S(e)}')`}};var d=class r{constructor(t){this.expr=t}toString(){return this.expr}and(t){return new r(`(${this.expr}) and (${r.coerce(t)})`)}or(t){return new r(`(${this.expr}) or (${r.coerce(t)})`)}not(){return new r(`not (${this.expr})`)}static coerce(t){return t instanceof r?t.expr:t}},it={eq:(r,t)=>new d(`${r} eq ${x(t)}`),ne:(r,t)=>new d(`${r} ne ${x(t)}`),gt:(r,t)=>new d(`${r} gt ${x(t)}`),ge:(r,t)=>new d(`${r} ge ${x(t)}`),lt:(r,t)=>new d(`${r} lt ${x(t)}`),le:(r,t)=>new d(`${r} le ${x(t)}`),startswith:(r,t)=>new d(`startswith(${r},${x(t)})`),endswith:(r,t)=>new d(`endswith(${r},${x(t)})`),contains:(r,t)=>new d(`contains(${r},${x(t)})`),and:(r,t)=>new d(`(${d.coerce(r)}) and (${d.coerce(t)})`),or:(r,t)=>new d(`(${d.coerce(r)}) or (${d.coerce(t)})`),not:r=>new d(`not (${d.coerce(r)})`),raw:r=>new d(r)};function nt(r){return typeof r=="function"?d.coerce(r(it)):d.coerce(r)}var A=class r{constructor(t,e,n){this._state={};this._baseUrl=t,this._entitySet=e,n&&(this._client=n)}select(...t){return this._state.select=[...this._state.select??[],...t],this}filter(t){let e=nt(t);return this._state.filter=this._state.filter?`(${this._state.filter}) and (${e})`:e,this}or(t){let e=nt(t);return this._state.filter=this._state.filter?`(${this._state.filter}) or (${e})`:e,this}expand(t,e){let n={name:t};if(e){let i=new r("",t);e(i),n.options=i._state}return this._state.expand=[...this._state.expand??[],n],this}orderby(t,e="asc"){return this._state.orderby=[...this._state.orderby??[],{field:t,dir:e}],this}top(t){if(!Number.isInteger(t)||t<0)throw new RangeError(`Query#top: expected non-negative integer, got ${t}`);return this._state.top=t,this}skip(t){if(!Number.isInteger(t)||t<0)throw new RangeError(`Query#skip: expected non-negative integer, got ${t}`);return this._state.skip=t,this}count(t=!0){return this._state.count=t,this}search(t){return this._state.search=t,this}apply(t){return this._state.apply=t,this}aggregate(t){let e=t.map(n=>`${n.field} with ${n.function} as ${n.alias}`);return this._state.apply=`aggregate(${e.join(",")})`,this}groupBy(t,e){let n=t.join(",");if(e&&e.length>0){let i=e.map(s=>`${s.field} with ${s.function} as ${s.alias}`);this._state.apply=`groupby((${n}),aggregate(${i.join(",")}))`}else this._state.apply=`groupby((${n}))`;return this}toURL(){let t=st(this._state,{topLevel:!0}),e=`${this._baseUrl}/${h(this._entitySet)}`;return t?`${e}?${t}`:e}byKey(t){if(!this._client)throw new Error("Query#byKey: no client attached (use FMSOData#from)");return new P(this._client,this._entitySet,t)}async create(t,e={}){if(!this._client)throw new Error("Query#create: no client attached (use FMSOData#from)");let n=`${this._baseUrl}/${h(this._entitySet)}`;return await m(this._client._ctx,n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),accept:"json",...e.signal?{signal:e.signal}:{}})}async createWithContainers(t,e,n={}){if(!this._client)throw new Error("Query#createWithContainers: no client attached (use FMSOData#from)");let i=`${this._baseUrl}/${h(this._entitySet)}`,s=M(e,t);return await m(this._client._ctx,i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s),accept:"json",...n.signal?{signal:n.signal}:{}})}async get(t={}){if(!this._client)throw new Error("Query#get: no client attached (use FMSOData#from)");let e=await m(this._client._ctx,this.toURL(),{method:"GET",accept:"json",...t.signal?{signal:t.signal}:{}}),n={value:e?.value??[]};return e&&typeof e["@odata.count"]=="number"&&(n.count=e["@odata.count"]),e&&typeof e["@odata.nextLink"]=="string"&&(n.nextLink=e["@odata.nextLink"]),n}async script(t,e={}){if(!this._client)throw new Error("Query#script: no client attached (use FMSOData#from)");return et(this._client,this._entitySet,t,e)}};function st(r,t){let e=[];if(r.select&&r.select.length>0&&e.push(["$select",r.select.join(",")]),r.filter&&e.push(["$filter",r.filter]),r.expand&&r.expand.length>0){let n=r.expand.map(i=>{if(!i.options)return i.name;let s=st(i.options,{topLevel:!1});return s?`${i.name}(${s})`:i.name});e.push(["$expand",n.join(",")])}return r.orderby&&r.orderby.length>0&&e.push(["$orderby",r.orderby.map(n=>`${n.field} ${n.dir}`).join(",")]),r.top!==void 0&&e.push(["$top",String(r.top)]),r.skip!==void 0&&e.push(["$skip",String(r.skip)]),r.count&&e.push(["$count","true"]),r.search&&e.push(["$search",r.search]),r.apply&&e.push(["$apply",r.apply]),t.topLevel?G(e):e.map(([n,i])=>`${n}=${i}`).join(";")}var B=class{constructor(t){if(!t.host)throw new TypeError("FMSOData: `host` is required");if(!t.database)throw new TypeError("FMSOData: `database` is required");if(t.token===void 0||t.token===null)throw new TypeError("FMSOData: `token` is required");this.host=t.host.replace(/\/+$/,""),this.database=t.database,this.baseUrl=`${this.host}/fmi/odata/v4/${encodeURIComponent(this.database)}`,this.timeoutMs=t.timeoutMs,this._ctx={token:t.token,fetch:t.fetch??globalThis.fetch.bind(globalThis),timeoutMs:t.timeoutMs,...t.onUnauthorized?{onUnauthorized:t.onUnauthorized}:{}}}from(t){if(!t)throw new TypeError("FMSOData#from: entitySet is required");return new A(this.baseUrl,t,this)}async request(t,e={}){return m(this._ctx,this._resolveUrl(t),e)}async rawRequest(t,e={}){return f(this._ctx,this._resolveUrl(t),e)}async script(t,e={}){return K(this,t,e)}async scriptById(t,e={}){return tt(this,t,e)}async metadata(t={}){return this._metadataFetcher||(this._metadataFetcher=new _(this._ctx,this.baseUrl)),this._metadataFetcher.fetch(t)}async metadataXml(t={}){return this._metadataFetcher||(this._metadataFetcher=new _(this._ctx,this.baseUrl)),this._metadataFetcher.fetchXml(t)}async version(){if(this._detectedVersion!==void 0)return this._detectedVersion;try{let t=await this.serverVersion();if(!t)return this._detectedVersion=null,null;let e=String(t.major);return this._detectedVersion=e in E?e:"future",this._detectedVersion}catch{return this._detectedVersion=null,null}}async serverVersion(){if(this._detectedServerVersion!==void 0)return this._detectedServerVersion;try{let t=await this.metadata();return this._detectedServerVersion=t.serverVersion??null,this._detectedServerVersion}catch{return this._detectedServerVersion=null,null}}async versionInfo(){let t=await this.version();return t?E[t]:null}async hasFeature(t){let e=await this.version();return e?L(e,t):!1}batch(){return new D(this)}_resolveUrl(t){return/^https?:\/\//i.test(t)?t:t.startsWith("/")?`${this.baseUrl}${t}`:`${this.baseUrl}/${t}`}};export{D as Batch,I as Changeset,v as ContainerRef,P as EntityRef,B as FMOData,y as FMODataError,B as FMSOData,y as FMSODataError,w as FMScriptError,U as FM_CONTAINER_SUPPORTED_MIME_TYPES,E as FM_VERSION_MATRIX,mt as FM_VERSION_NAMES,d as Filter,_ as MetadataFetcher,gt as ODATA_PROTOCOL_VERSION,A as Query,T as ScriptInvoker,ut as basicAuth,M as buildContainerJsonBody,it as filterFactory,pt as fmidAuth,L as hasFeature,yt as hasQueryOption,J as isFMODataError,J as isFMSODataError,ot as isFMScriptError,xt as minVersionForFeature,N as parseServerVersion,O as parseVersionString,X as sniffContainerMime,Z as toBase64};
@@ -0,0 +1,6 @@
1
+ "use strict";var FMSODataLib=(()=>{var H=Object.defineProperty,be=Object.defineProperties,Se=Object.getOwnPropertyDescriptor,Ee=Object.getOwnPropertyDescriptors,Te=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var Z=(r,e,t)=>e in r?H(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))K.call(e,t)&&Z(r,t,e[t]);if(X)for(var t of X(e))Re.call(e,t)&&Z(r,t,e[t]);return r},U=(r,e)=>be(r,Ee(e));var $e=(r,e)=>{for(var t in e)H(r,t,{get:e[t],enumerable:!0})},we=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Te(e))!K.call(r,i)&&i!==t&&H(r,i,{get:()=>e[i],enumerable:!(n=Se(e,i))||n.enumerable});return r};var Oe=r=>we(H({},"__esModule",{value:!0}),r);var Ze={};$e(Ze,{Batch:()=>C,Changeset:()=>B,ContainerRef:()=>v,EntityRef:()=>P,FMOData:()=>N,FMODataError:()=>S,FMSOData:()=>N,FMSODataError:()=>S,FMScriptError:()=>O,FM_CONTAINER_SUPPORTED_MIME_TYPES:()=>L,FM_VERSION_MATRIX:()=>$,FM_VERSION_NAMES:()=>ue,Filter:()=>d,MetadataFetcher:()=>F,ODATA_PROTOCOL_VERSION:()=>pe,Query:()=>A,ScriptInvoker:()=>w,basicAuth:()=>re,buildContainerJsonBody:()=>D,filterFactory:()=>Y,fmidAuth:()=>ne,hasFeature:()=>q,hasQueryOption:()=>de,isFMODataError:()=>G,isFMSODataError:()=>G,isFMScriptError:()=>te,minVersionForFeature:()=>le,parseServerVersion:()=>J,parseVersionString:()=>M,sniffContainerMime:()=>Q,toBase64:()=>z});var S=class extends Error{constructor(e,t){super(e),this.name="FMSODataError",this.status=t.status,t.code!==void 0&&(this.code=t.code),t.odataError!==void 0&&(this.odataError=t.odataError),t.request!==void 0&&(this.request=t.request)}};async function ee(r,e){var l,f,x;let t=r.status,n="";try{n=await r.text()}catch(h){}let i,s=r.statusText||`HTTP ${t}`,o=n,a=((l=r.headers.get("content-type"))!=null?l:"").toLowerCase(),c=a.includes("json")||n.startsWith("{")&&n.endsWith("}"),p=a.includes("xml")||n.trimStart().startsWith("<?xml")||n.includes("<m:error");if(c)try{let h=JSON.parse(n);o=h;let m=(f=h==null?void 0:h.error)==null?void 0:f.code,E=(x=h==null?void 0:h.error)==null?void 0:x.message,I=typeof E=="string"?E:E==null?void 0:E.value;m&&(i=String(m)),I&&(s=I)}catch(h){}else if(p){let h=n.match(/<m:code>([^<]+)<\/m:code>/),m=n.match(/<m:message(?:\s[^>]*)?>([^<]+)<\/m:message>/);h!=null&&h[1]&&(i=h[1]),m!=null&&m[1]&&(s=m[1])}return new S(s,U(u({status:t},i!==void 0?{code:i}:{}),{odataError:o,request:e}))}var O=class extends S{constructor(e,t){super(e,u(u({status:t.status,code:t.scriptError},t.odataError!==void 0?{odataError:t.odataError}:{}),t.request!==void 0?{request:t.request}:{})),this.name="FMScriptError",this.scriptError=t.scriptError,t.scriptResult!==void 0&&(this.scriptResult=t.scriptResult)}};function G(r){return r instanceof S}function te(r){return r instanceof O}var _e=/^(basic|bearer|fmid|negotiate|digest)\s+\S/i;async function Me(r){let e=typeof r=="function"?await r():r;if(typeof e!="string"||e.length===0)throw new TypeError("fms-odata-js: token resolver produced an empty value");return _e.test(e)?e:`Bearer ${e}`}function re(r,e){let t=`${r}:${e}`;return`Basic ${typeof Buffer!="undefined"?Buffer.from(t,"utf8").toString("base64"):btoa(unescape(encodeURIComponent(t)))}`}function ne(r){return`FMID ${r}`}function Fe(r){let e=r.filter(n=>n!==void 0);if(e.length===0)return;if(e.length===1)return e[0];let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(n.reason),t.signal;n.addEventListener("abort",()=>t.abort(n.reason),{once:!0})}return t.signal}var De={json:"application/json",xml:"application/xml",text:"text/plain",binary:"application/octet-stream",none:"*/*"};async function g(r,e,t={}){return ie(r,e,t,!1)}async function ie(r,e,t,n){var l,f;let i=(l=t.method)!=null?l:"GET",s=new Headers(t.headers);s.set("Authorization",await Me(r.token)),s.has("OData-Version")||s.set("OData-Version","4.0"),s.has("OData-MaxVersion")||s.set("OData-MaxVersion","4.0"),s.has("Accept")||s.set("Accept",De[(f=t.accept)!=null?f:"json"]);let o=new AbortController,a=r.timeoutMs&&r.timeoutMs>0?setTimeout(()=>o.abort(new Error(`Timeout after ${r.timeoutMs}ms`)),r.timeoutMs):void 0,c=Fe([t.signal,r.timeoutMs?o.signal:void 0]),p;try{p=await r.fetch(e,u(u({method:i,headers:s,keepalive:!0},t.body!==void 0?{body:t.body}:{}),c?{signal:c}:{}))}catch(x){throw a&&clearTimeout(a),x}if(a&&clearTimeout(a),p.status===401&&r.onUnauthorized&&!n)return await r.onUnauthorized(),ie(r,e,t,!0);if(!p.ok)throw await ee(p,{url:e,method:i});return p}async function b(r,e,t={}){var s,o;let n=await g(r,e,t);if(n.status===204)return;let i=((s=n.headers.get("content-type"))!=null?s:"").toLowerCase();if(!i.includes("json")){let a=await n.text();if(!a)return;try{return JSON.parse(a)}catch(c){throw new S(`Expected JSON response, got "${i||"no content-type"}"`,{status:n.status,odataError:a,request:{url:e,method:(o=t.method)!=null?o:"GET"}})}}return await n.json()}function _(r){return r.replace(/'/g,"''")}function ke(r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new TypeError("formatDateTime: invalid Date");return r.toISOString().replace(/\.\d{3}Z$/,"Z")}function T(r){if(r==null)return"null";if(typeof r=="string")return`'${_(r)}'`;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`formatLiteral: cannot encode non-finite number: ${r}`);return String(r)}if(typeof r=="boolean")return r?"true":"false";if(r instanceof Date)return ke(r);throw new TypeError(`formatLiteral: unsupported OData literal type: ${typeof r}`)}function y(r){return encodeURIComponent(r)}function k(r){return encodeURIComponent(r).replace(/%2C/gi,",").replace(/%24/g,"$").replace(/%3D/g,"=").replace(/%3B/g,";").replace(/%28/g,"(").replace(/%29/g,")")}function se(r){let e=[];for(let[t,n]of r)n===""||n===void 0||n===null||e.push(`${t}=${k(n)}`);return e.join("&")}function Ce(r){return typeof TextEncoder!="undefined"?new TextEncoder().encode(r).byteLength:Buffer.byteLength(r,"utf8")}function oe(r){let e=typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;return`${r}_${e}`}function ce(r,e,t){let n=[];(t==null?void 0:t.$top)!==void 0&&n.push(`$top=${k(String(t.$top))}`),(t==null?void 0:t.$skip)!==void 0&&n.push(`$skip=${k(String(t.$skip))}`),t!=null&&t.$filter&&n.push(`$filter=${k(t.$filter)}`),t!=null&&t.$select&&n.push(`$select=${k(t.$select)}`);let i=n.join("&"),s=y(e);return i?`${r}/${s}?${i}`:`${r}/${s}`}function ae(r,e,t){let n=y(e),i;if(typeof t=="number")i=String(t);else if(typeof t=="string")i=`'${t.replace(/'/g,"''")}'`;else if(typeof t=="boolean")i=t?"true":"false";else throw new TypeError("Batch: unsupported key type");return`${r}/${n}(${i})`}var B=class{constructor(e){this._ops=[];this._handles=[];this._baseUrl=e}get _operations(){return this._ops}get _handleSlots(){return this._handles}create(e,t){let n=ce(this._baseUrl,e),i,s,o=new Promise((c,p)=>{i=c,s=p}),a=this._handles.length;return this._handles.push({resolve:i,reject:s}),this._ops.push({method:"POST",path:n,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),{__brand:"BatchHandle",_promise:o,_index:a}}patch(e,t,n,i){let s=ae(this._baseUrl,e,t),o={"Content-Type":"application/json"};i!=null&&i.ifMatch&&(o["If-Match"]=i.ifMatch);let a,c,p=new Promise((f,x)=>{a=f,c=x}),l=this._handles.length;return this._handles.push({resolve:a,reject:c}),this._ops.push({method:"PATCH",path:s,headers:o,body:JSON.stringify(n)}),{__brand:"BatchHandle",_promise:p,_index:l}}delete(e,t,n){let i=ae(this._baseUrl,e,t),s={};n!=null&&n.ifMatch&&(s["If-Match"]=n.ifMatch);let o,a,c=new Promise((l,f)=>{o=l,a=f}),p=this._handles.length;return this._handles.push({resolve:o,reject:a}),this._ops.push({method:"DELETE",path:i,headers:s}),{__brand:"BatchHandle",_promise:c,_index:p}}},C=class{constructor(e){this._parts=[];this._changesets=[];this._client=e}add(e){let t=ce(this._client.baseUrl,e.entitySet,e.query),n,i,o={__brand:"BatchHandle",_promise:new Promise((a,c)=>{n=a,i=c}),_index:this._parts.length};return this._parts.push({type:"read",content:{method:"GET",path:t},handle:o}),o}changeset(e){let t=new B(this._client.baseUrl);e(t),this._changesets.push(t),this._parts.push({type:"changeset",content:t})}_serialize(){let e=oe("batch"),t=[];for(let n of this._parts)if(t.push(`--${e}`),n.type==="read"){let i=n.content;t.push("Content-Type: application/http"),t.push("Content-Transfer-Encoding: binary"),t.push(""),t.push(`${i.method} ${i.path} HTTP/1.1`)}else if(n.type==="changeset"){let i=n.content,s=oe("changeset");t.push("Content-Type: multipart/mixed; boundary="+s),t.push("");for(let o of i._operations){if(t.push(`--${s}`),t.push("Content-Type: application/http"),t.push("Content-Transfer-Encoding: binary"),t.push(""),t.push(`${o.method} ${o.path} HTTP/1.1`),o.headers)for(let[a,c]of Object.entries(o.headers))t.push(`${a}: ${c}`);o.body&&(t.push(`Content-Length: ${Ce(o.body)}`),t.push(""),t.push(o.body))}t.push(`--${s}--`)}return t.push(`--${e}--`),{boundary:e,body:t.join(`\r
2
+ `)}}async send(e={}){var o;let{boundary:t,body:n}=this._serialize(),i=await g(this._client._ctx,`${this._client.baseUrl}/$batch`,u({method:"POST",headers:{"Content-Type":`multipart/mixed; boundary=${t}`},body:n,accept:"none"},e.signal?{signal:e.signal}:{})),s=await i.text();return this._parseResponse(s,(o=i.headers.get("content-type"))!=null?o:"")}_parseResponse(e,t){let n=t.match(/boundary=([^;\s]+)/),i=n==null?void 0:n[1];if(!i)throw new Error("Batch response missing boundary in Content-Type");let s=e.split(`--${i}`),o=[],a=0;for(let c=1;c<s.length-1;c++){let p=s[c].trim();if(!p||p==="--")continue;let l=this._parts[a];if(l){if(l.type==="read"){let f=this._parseHttpPart(p);o.push(f),l.handle&&this._resolveHandle(l.handle,f),a++}else if(l.type==="changeset"){let f=l.content,x=this._parseChangesetResponse(p,f);o.push(...x);let h=x.find(m=>!m.ok);for(let m=0;m<f._handleSlots.length;m++){let E=f._handleSlots[m],I=x[m];h?E.reject(new Error(`Changeset failed: ${h.status}`)):I?E.resolve(I.body):E.resolve(void 0)}a++}}}return{responses:o,ok:o.every(c=>c.ok)}}_parseHttpPart(e){let t=e.indexOf(`\r
3
+ \r
4
+ `),n=t>=0?e.slice(t+4):e,i=n.indexOf(`\r
5
+ \r
6
+ `),s=i>=0?n.slice(0,i):n,o=i>=0?n.slice(i+4).trim():"",a=s.match(/^HTTP\/1\.\d (\d+)/),c=a?parseInt(a[1],10):0,p;if(o&&s.toLowerCase().includes("application/json"))try{p=JSON.parse(o)}catch(l){p=o}else o&&(p=o);return{status:c,body:p,headers:new Headers,ok:c>=200&&c<300}}_parseChangesetResponse(e,t){let n=e.match(/boundary=([^\s]+)/),i=n==null?void 0:n[1];if(!i)return[this._parseHttpPart(e)];let s=e.split(`--${i}`),o=[];for(let a=1;a<s.length-1;a++){let c=s[a].trim();!c||c==="--"||o.push(this._parseHttpPart(c))}return o}_resolveHandle(e,t){}};var ue={19:"FileMaker 19.x",21:"Claris FileMaker 2023",22:"Claris FileMaker 2024",26:"Claris FileMaker 2026",future:"Future / next"},pe="4.0",$={19:{major:"19",name:"FileMaker 19.x",releaseYear:null,internalVersion:"19.x",status:"baseline",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!1,scriptListing:!1,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!1,webhookQueryHeaders:!1,applyAggregation:!1,typeCasting:!1,parameterizedFilters:!1,immutableIdUrls:!1,aiAnnotation:!1,serverVersionAnnotation:!1,enrichedFMComment:!1,authBasic:!0,authFMID:!1,authOAuth:!1},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!1,$search:!1,$compute:!1}},21:{major:"21",name:"Claris FileMaker 2023",releaseYear:2023,internalVersion:"21.x",status:"supported",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!1,scriptListing:!1,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!1,applyAggregation:!1,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!1,aiAnnotation:!1,serverVersionAnnotation:!1,enrichedFMComment:!1,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!1,$search:!1,$compute:!1}},22:{major:"22",name:"Claris FileMaker 2024",releaseYear:2024,internalVersion:"22.x",status:"supported",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!1,scriptListing:!1,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!0,applyAggregation:!0,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!1,aiAnnotation:!1,serverVersionAnnotation:!1,enrichedFMComment:!1,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!0,$search:!1,$compute:!1}},26:{major:"26",name:"Claris FileMaker 2026",releaseYear:2026,internalVersion:"26.x",status:"current",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!0,scriptListing:!0,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!0,applyAggregation:!0,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!0,aiAnnotation:!0,serverVersionAnnotation:!0,enrichedFMComment:!0,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!0,$search:!1,$compute:!1}},future:{major:"future",name:"Future / next",releaseYear:null,internalVersion:"unknown",status:"future",features:{serviceDocument:!0,metadata:!0,databaseListing:!0,tableListing:!0,recordCRUD:!0,recordReferences:!0,crossJoin:!0,batch:!0,scripts:!0,scriptsByFMSID:!0,scriptListing:!0,containerBinaryUpload:!0,containerBase64Upload:!0,containerDownload:!0,schemaModification:!0,webhooks:!0,webhookQueryHeaders:!0,applyAggregation:!0,typeCasting:!0,parameterizedFilters:!0,immutableIdUrls:!0,aiAnnotation:!0,serverVersionAnnotation:!0,enrichedFMComment:!0,authBasic:!0,authFMID:!0,authOAuth:!0},queryOptions:{$filter:!0,$select:!0,$orderby:!0,$top:!0,$skip:!0,$expand:!0,$count:!0,$apply:!0,$search:!1,$compute:!1}}};function q(r,e){var t,n;return(n=(t=$[r])==null?void 0:t.features[e])!=null?n:!1}function de(r,e){var t,n;return(n=(t=$[r])==null?void 0:t.queryOptions[e])!=null?n:!1}function le(r){let e=["19","21","22","26"];for(let t of e)if($[t].features[r])return t;return null}function M(r){let e=r.trim().match(/(\d+)\.(\d+)\.(\d+)/);return e?{major:parseInt(e[1],10),minor:parseInt(e[2],10),patch:parseInt(e[3],10),raw:r.trim()}:null}function J(r){if(!r||typeof r!="string")return null;let e=r.match(/Term\s*=\s*["']Org\.OData\.Core\.V1\.ProductVersion["'][^>]*String\s*=\s*["']([^"']+)["']/);if(e){let o=M(e[1]);if(o)return o}let t=r.match(/String\s*=\s*["']([^"']+)["'][^>]*Term\s*=\s*["']Org\.OData\.Core\.V1\.ProductVersion["']/);if(t){let o=M(t[1]);if(o)return o}let n=r.match(/Term\s*=\s*["']ServerVersion["'][^>]*String\s*=\s*["']([^"']+)["']/i);if(n){let o=M(n[1]);if(o&&o.major>=17)return o}let i=r.match(/String\s*=\s*["']([^"']+)["'][^>]*Term\s*=\s*["']ServerVersion["']/i);if(i){let o=M(i[1]);if(o&&o.major>=17)return o}let s=r.match(/Term\s*=\s*["'][^"']*Version[^"']*["'][^>]*String\s*=\s*["'][^"']*?(\d{2,}\.\d+\.\d+(?:\.\d+)?)[^"']*?["']/i);if(s){let o=M(s[1]);if(o&&o.major>=17)return o}return null}function ve(r,e){return r===void 0?e:r==="true"}function W(r,e){let t=new RegExp(`${e}="([^"]*)"`,"i"),n=r.match(t);return n==null?void 0:n[1]}function j(r){let e={},t=/(\w+)="([^"]*)"/g,n;for(;(n=t.exec(r))!==null;)e[n[1]]=n[2];return e}function R(r,e){let t=[],n=new RegExp(`<([\\w]+:)?${e}\\b[^>]*>`,"gi"),i;for(;(i=n.exec(r))!==null;){let s=i[0];if(/\/>\s*$/.test(s)){t.push(s);continue}let o=i.index,a=new RegExp(`</([\\w]+:)?${e}>`,"gi");a.lastIndex=n.lastIndex;let c=a.exec(r);c&&t.push(r.slice(o,c.index+c[0].length))}return t}function V(r,e){let n=new RegExp(`<(?:[\\w]+:)?${e}\\b[^>]*>`,"i").exec(r);if(!n)return;let i=n.index+n[0].length,s=new RegExp(`</(?:[\\w]+:)?${e}>`,"i");s.lastIndex=i;let o=s.exec(r);if(o)return r.slice(i,o.index)}function Pe(r){var i,s;let e=j(r),t=ve(e.Nullable,!0),n={name:(i=e.Name)!=null?i:"",type:(s=e.Type)!=null?s:"",nullable:t};if(e.MaxLength!==void 0){let o=parseInt(e.MaxLength,10);Number.isNaN(o)||(n.maxLength=o)}return n}function Ae(r){var s,o;let e=j(r),t=(s=e.Type)!=null?s:"",n=t.startsWith("Collection("),i=n?t.slice(11,-1):t;return{name:(o=e.Name)!=null?o:"",target:i,collection:n}}function Ie(r){let e=[],t=R(r,"PropertyRef");for(let n of t){let i=W(n,"Name");i&&e.push(i)}return e}function Ue(r){var a,c;let e=(a=W(r,"Name"))!=null?a:"",t=[],n=[],i=[],s=(c=V(r,"EntityType"))!=null?c:r,o=R(s,"Key")[0];o&&t.push(...Ie(o));for(let p of R(s,"Property"))n.push(Pe(p));for(let p of R(s,"NavigationProperty"))i.push(Ae(p));return{name:e,keys:t,properties:n,navigationProperties:i}}function Be(r){var t,n;let e=j(r);return{name:(t=e.Name)!=null?t:"",entityType:(n=e.EntityType)!=null?n:""}}function Ve(r){var e;return(e=J(r))!=null?e:void 0}function je(r){var o,a,c,p;let e=(o=W(r,"Name"))!=null?o:"",t=j(r),n=t.IsBound==="true"?t.EntityType:void 0,i=[],s=(a=V(r,"Action"))!=null?a:r;for(let l of R(s,"Parameter")){let f=j(l);i.push({name:(c=f.Name)!=null?c:"",type:(p=f.Type)!=null?p:""})}return n!==void 0?{name:e,boundTo:n,parameters:i}:{name:e,parameters:i}}function Le(r){var e,t,n;try{let i=V(r,"DataServices");if(!i)throw new Error("Missing <edmx:DataServices> in metadata");let s=R(i,"Schema")[0];if(!s)throw new Error("Missing <Schema> in metadata");let o=(e=W(s,"Namespace"))!=null?e:"",a=(t=V(s,"Schema"))!=null?t:s,c=[];for(let m of R(a,"EntityType"))c.push(Ue(m));let p=[],l=R(a,"EntityContainer")[0];if(l){let m=(n=V(l,"EntityContainer"))!=null?n:l;for(let E of R(m,"EntitySet"))p.push(Be(E))}let f=[];for(let m of R(a,"Action"))f.push(je(m));let x=Ve(r),h={namespace:o,entityTypes:c,entitySets:p,actions:f,raw:r};return x&&(h.serverVersion=x,h.productVersion=x.raw),h}catch(i){let s=i instanceof Error?i.message:String(i);throw new S(`Failed to parse $metadata: ${s}`,{status:0,odataError:r.slice(0,500)})}}async function Ne(r,e,t={}){return(await g(r,`${e}/$metadata`,u({method:"GET",accept:"xml"},t.signal?{signal:t.signal}:{}))).text()}var F=class{constructor(e,t){this._ctx=e;this._baseUrl=t}async fetchXml(e={}){return Ne(this._ctx,this._baseUrl,e)}async fetch(e={}){if(!e.refresh&&this._cache)return this._cache;let t=this.fetchXml(e).then(Le);return this._cache=t,t}};var L=["image/png","image/jpeg","image/gif","image/tiff","application/pdf"];function He(r){var e;return((e=r.split(";")[0])!=null?e:"").trim().toLowerCase()}function qe(r){let e=He(r);return L.includes(e)}function Q(r){if(r.length>=8&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71&&r[4]===13&&r[5]===10&&r[6]===26&&r[7]===10)return"image/png";if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"image/jpeg";if(r.length>=4&&r[0]===71&&r[1]===73&&r[2]===70&&r[3]===56)return"image/gif";if(r.length>=4&&(r[0]===73&&r[1]===73&&r[2]===42&&r[3]===0||r[0]===77&&r[1]===77&&r[2]===0&&r[3]===42))return"image/tiff";if(r.length>=4&&r[0]===37&&r[1]===80&&r[2]===68&&r[3]===70)return"application/pdf"}var v=class{constructor(e,t){if(!t)throw new TypeError("ContainerRef: fieldName is required");this._entity=e,this.fieldName=t}url(){return`${this._entity.toURL()}/${y(this.fieldName)}`}_valueUrl(){return`${this.url()}/$value`}async get(e={}){var c;let t=await g(this._entity._client._ctx,this._valueUrl(),u({method:"GET",accept:"none"},e.signal?{signal:e.signal}:{})),n=(c=t.headers.get("content-type"))!=null?c:"",i=t.headers.get("content-disposition"),s=i?Je(i):void 0,o=await t.blob(),a={blob:o,contentType:n,size:o.size};return s!==void 0&&(a.filename=s),a}async getStream(e={}){let t=await g(this._entity._client._ctx,this._valueUrl(),u({method:"GET",accept:"none"},e.signal?{signal:e.signal}:{}));if(!t.body)throw new TypeError("ContainerRef.getStream: response has no body");return t.body}async upload(e,t={}){var a;let n=(a=e.encoding)!=null?a:"binary",i=await Ge(e.data),s=e.contentType;if(!s){let c=Q(i);if(!c)throw new TypeError(`ContainerRef.upload: contentType is required and could not be sniffed from the payload. Pass a contentType explicitly (one of ${L.join(", ")}).`);s=c}if(n==="binary"){if(!qe(s))throw new TypeError(`ContainerRef.upload (binary): contentType "${s}" is not a FileMaker-supported container type. Use one of ${L.join(", ")}, or switch to { encoding: 'base64' }.`);let c={"Content-Type":s};e.filename&&(c["Content-Disposition"]=We(e.filename));let p=new ArrayBuffer(i.byteLength);new Uint8Array(p).set(i),await g(this._entity._client._ctx,this.url(),u({method:"PATCH",headers:c,body:p,accept:"none"},t.signal?{signal:t.signal}:{}));return}let o=D({[this.fieldName]:u({data:z(i),contentType:s},e.filename?{filename:e.filename}:{})});await g(this._entity._client._ctx,this._entity.toURL(),u({method:"PATCH",headers:{"Content-Type":"application/json",Prefer:"return=minimal"},body:JSON.stringify(o),accept:"none"},t.signal?{signal:t.signal}:{}))}async delete(e={}){let t={[this.fieldName]:null};await g(this._entity._client._ctx,this._entity.toURL(),u({method:"PATCH",headers:{"Content-Type":"application/json",Prefer:"return=minimal"},body:JSON.stringify(t),accept:"none"},e.signal?{signal:e.signal}:{}))}};function D(r,e={}){let t=u({},e);for(let[n,i]of Object.entries(r)){if(!i.contentType)throw new TypeError(`buildContainerJsonBody: "${n}".contentType is required`);t[n]=i.data,t[`${n}@com.filemaker.odata.ContentType`]=i.contentType,i.filename&&(t[`${n}@com.filemaker.odata.Filename`]=i.filename)}return t}function Je(r){let e=r.match(/filename\*\s*=\s*([^']+)'[^']*'([^;]+)/i);if(e){let n=e[1].trim().toLowerCase(),i=e[2].trim();try{let s=decodeURIComponent(i);return s}catch(s){}}let t=r.match(/filename\s*=\s*("([^"\\]*(?:\\.[^"\\]*)*)"|([^;]+))/i);if(t){let n=t[2];if(n!==void 0)return n.replace(/\\(.)/g,"$1").trim();let i=t[3];if(i!==void 0)return i.trim()}}function We(r){let e=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,t=/[^\x00-\x7F]/.test(r),n;return e.test(r)?n=`inline; filename=${r}`:n=`inline; filename="${r.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"`,t?`${n}; filename*=UTF-8''${encodeURIComponent(r)}`:n}async function Ge(r){if(r instanceof Uint8Array)return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);let e=await r.arrayBuffer();return new Uint8Array(e)}function z(r){if(typeof Buffer!="undefined")return Buffer.from(r).toString("base64");let e="",t=32768;for(let n=0;n<r.length;n+=t)e+=String.fromCharCode.apply(null,Array.from(r.subarray(n,n+t)));return btoa(e)}function Qe(r){if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError("ScriptInvoker: key must be a finite number");return String(r)}if(typeof r=="string")return`'${_(r)}'`;if(typeof r=="boolean")return r?"true":"false";throw new TypeError("ScriptInvoker: unsupported key type")}var w=class{constructor(e,t={}){this._client=e,t.entitySet!==void 0&&(this.entitySet=t.entitySet),t.key!==void 0&&(this.key=t.key)}url(e){if(!e)throw new TypeError("ScriptInvoker: script name is required");return this._urlForSegment(`Script.${y(e)}`)}urlById(e){if(!Number.isFinite(e))throw new TypeError("ScriptInvoker: fmsid must be a finite number");return this._urlForSegment(`Script.FMSID:${e}`)}_urlForSegment(e){let t=this._client.baseUrl;if(this.entitySet===void 0)return`${t}/${e}`;let n=y(this.entitySet);return this.key===void 0?`${t}/${n}/${e}`:`${t}/${n}(${Qe(this.key)})/${e}`}async run(e,t={}){return this._runAtUrl(this.url(e),t)}async runById(e,t={}){return this._runAtUrl(this.urlById(e),t)}async _runAtUrl(e,t){let n={},i;t.parameter!==void 0&&(n["Content-Type"]="application/json",i=JSON.stringify({scriptParameterValue:t.parameter}));let s="POST",o=await b(this._client._ctx,e,u(U(u({method:s,headers:n},i!==void 0?{body:i}:{}),{accept:"json"}),t.signal?{signal:t.signal}:{}));return ze(o,{url:e,method:s})}};function ze(r,e){let t=Ye(r),n=t.scriptResult,i,s;if(n!==null&&typeof n=="object"&&"resultParameter"in n){let a=n;s=a.code!==void 0?String(a.code):"0",i=a.resultParameter!==void 0?String(a.resultParameter):void 0}else s=t.scriptError!==void 0?String(t.scriptError):"0",i=n!==void 0?typeof n=="string"?n:JSON.stringify(n):void 0;if(s!=="0")throw new O(`FileMaker script error ${s}`,U(u({status:200,scriptError:s},i!==void 0?{scriptResult:i}:{}),{odataError:r,request:e}));let o={scriptError:s,raw:r};return i!==void 0&&(o.scriptResult=i),o}function Ye(r){if(r===null||typeof r!="object")return{};let e=r;if("scriptError"in e||"scriptResult"in e)return e;for(let t of Object.values(e))if(t&&typeof t=="object"){let n=t;if("scriptError"in n||"scriptResult"in n)return n}return{}}function fe(r,e,t){return new w(r).run(e,t)}function he(r,e,t){return new w(r).runById(e,t)}function me(r,e,t,n){return new w(r,{entitySet:e}).run(t,n)}function ge(r,e,t,n,i){return new w(r,{entitySet:e,key:t}).run(n,i)}function Xe(r){if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError("EntityRef: key must be a finite number");return String(r)}if(typeof r=="string")return`'${_(r)}'`;if(typeof r=="boolean")return r?"true":"false";throw new TypeError("EntityRef: unsupported key type")}var P=class{constructor(e,t,n){this._client=e,this.entitySet=t,this.key=n}toURL(){return`${this._client.baseUrl}/${y(this.entitySet)}(${Xe(this.key)})`}async get(e={}){return await b(this._client._ctx,this.toURL(),u({method:"GET",accept:"json"},e.signal?{signal:e.signal}:{}))}async fieldValue(e,t={}){let n=`${this.toURL()}/${y(e)}`;return(await b(this._client._ctx,n,u({method:"GET",accept:"json"},t.signal?{signal:t.signal}:{}))).value}async patch(e,t={}){let n={"Content-Type":"application/json",Prefer:t.returnRepresentation?"return=representation":"return=minimal"};return t.ifMatch&&(n["If-Match"]=t.ifMatch),await b(this._client._ctx,this.toURL(),u({method:"PATCH",headers:n,body:JSON.stringify(e),accept:"json"},t.signal?{signal:t.signal}:{}))}async delete(e={}){let t={};e.ifMatch&&(t["If-Match"]=e.ifMatch),await g(this._client._ctx,this.toURL(),u({method:"DELETE",headers:t,accept:"none"},e.signal?{signal:e.signal}:{}))}async script(e,t={}){return ge(this._client,this.entitySet,this.key,e,t)}container(e){return new v(this,e)}async patchContainers(e,t={},n={}){let i={"Content-Type":"application/json",Prefer:n.returnRepresentation?"return=representation":"return=minimal"};n.ifMatch&&(i["If-Match"]=n.ifMatch);let s=D(e,t);await g(this._client._ctx,this.toURL(),u({method:"PATCH",headers:i,body:JSON.stringify(s),accept:"none"},n.signal?{signal:n.signal}:{}))}async getRefs(e,t={}){let n=`${this.toURL()}/${y(e)}/$ref`,i=await b(this._client._ctx,n,u({method:"GET",accept:"json"},t.signal?{signal:t.signal}:{}));return i!=null&&i.value?i.value:i!=null&&i["@odata.id"]?[i]:[]}async addRef(e,t,n={}){let i=`${this.toURL()}/${y(e)}/$ref`,s={"Content-Type":"application/json"};n.ifMatch&&(s["If-Match"]=n.ifMatch);let o=JSON.stringify({"@odata.id":this._refId(e,t)});await g(this._client._ctx,i,u({method:"POST",headers:s,body:o,accept:"none"},n.signal?{signal:n.signal}:{}))}async setRef(e,t,n={}){let i=`${this.toURL()}/${y(e)}/$ref`,s={"Content-Type":"application/json"};n.ifMatch&&(s["If-Match"]=n.ifMatch);let o=JSON.stringify({"@odata.id":this._refId(e,t)});await g(this._client._ctx,i,u({method:"PATCH",headers:s,body:o,accept:"none"},n.signal?{signal:n.signal}:{}))}async removeRef(e,t,n={}){let i=`${this.toURL()}/${y(e)}/$ref`,s={};n.ifMatch&&(s["If-Match"]=n.ifMatch),t!==void 0&&(i+=`('${_(this._refId(e,t))}')`),await g(this._client._ctx,i,u({method:"DELETE",headers:s,accept:"none"},n.signal?{signal:n.signal}:{}))}_refId(e,t){let n=e;return typeof t=="number"?`${n}(${t})`:`${n}('${_(t)}')`}};var d=class r{constructor(e){this.expr=e}toString(){return this.expr}and(e){return new r(`(${this.expr}) and (${r.coerce(e)})`)}or(e){return new r(`(${this.expr}) or (${r.coerce(e)})`)}not(){return new r(`not (${this.expr})`)}static coerce(e){return e instanceof r?e.expr:e}},Y={eq:(r,e)=>new d(`${r} eq ${T(e)}`),ne:(r,e)=>new d(`${r} ne ${T(e)}`),gt:(r,e)=>new d(`${r} gt ${T(e)}`),ge:(r,e)=>new d(`${r} ge ${T(e)}`),lt:(r,e)=>new d(`${r} lt ${T(e)}`),le:(r,e)=>new d(`${r} le ${T(e)}`),startswith:(r,e)=>new d(`startswith(${r},${T(e)})`),endswith:(r,e)=>new d(`endswith(${r},${T(e)})`),contains:(r,e)=>new d(`contains(${r},${T(e)})`),and:(r,e)=>new d(`(${d.coerce(r)}) and (${d.coerce(e)})`),or:(r,e)=>new d(`(${d.coerce(r)}) or (${d.coerce(e)})`),not:r=>new d(`not (${d.coerce(r)})`),raw:r=>new d(r)};function ye(r){return typeof r=="function"?d.coerce(r(Y)):d.coerce(r)}var A=class r{constructor(e,t,n){this._state={};this._baseUrl=e,this._entitySet=t,n&&(this._client=n)}select(...e){var t;return this._state.select=[...(t=this._state.select)!=null?t:[],...e],this}filter(e){let t=ye(e);return this._state.filter=this._state.filter?`(${this._state.filter}) and (${t})`:t,this}or(e){let t=ye(e);return this._state.filter=this._state.filter?`(${this._state.filter}) or (${t})`:t,this}expand(e,t){var i;let n={name:e};if(t){let s=new r("",e);t(s),n.options=s._state}return this._state.expand=[...(i=this._state.expand)!=null?i:[],n],this}orderby(e,t="asc"){var n;return this._state.orderby=[...(n=this._state.orderby)!=null?n:[],{field:e,dir:t}],this}top(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`Query#top: expected non-negative integer, got ${e}`);return this._state.top=e,this}skip(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`Query#skip: expected non-negative integer, got ${e}`);return this._state.skip=e,this}count(e=!0){return this._state.count=e,this}search(e){return this._state.search=e,this}apply(e){return this._state.apply=e,this}aggregate(e){let t=e.map(n=>`${n.field} with ${n.function} as ${n.alias}`);return this._state.apply=`aggregate(${t.join(",")})`,this}groupBy(e,t){let n=e.join(",");if(t&&t.length>0){let i=t.map(s=>`${s.field} with ${s.function} as ${s.alias}`);this._state.apply=`groupby((${n}),aggregate(${i.join(",")}))`}else this._state.apply=`groupby((${n}))`;return this}toURL(){let e=xe(this._state,{topLevel:!0}),t=`${this._baseUrl}/${y(this._entitySet)}`;return e?`${t}?${e}`:t}byKey(e){if(!this._client)throw new Error("Query#byKey: no client attached (use FMSOData#from)");return new P(this._client,this._entitySet,e)}async create(e,t={}){if(!this._client)throw new Error("Query#create: no client attached (use FMSOData#from)");let n=`${this._baseUrl}/${y(this._entitySet)}`;return await b(this._client._ctx,n,u({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),accept:"json"},t.signal?{signal:t.signal}:{}))}async createWithContainers(e,t,n={}){if(!this._client)throw new Error("Query#createWithContainers: no client attached (use FMSOData#from)");let i=`${this._baseUrl}/${y(this._entitySet)}`,s=D(t,e);return await b(this._client._ctx,i,u({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s),accept:"json"},n.signal?{signal:n.signal}:{}))}async get(e={}){var i;if(!this._client)throw new Error("Query#get: no client attached (use FMSOData#from)");let t=await b(this._client._ctx,this.toURL(),u({method:"GET",accept:"json"},e.signal?{signal:e.signal}:{})),n={value:(i=t==null?void 0:t.value)!=null?i:[]};return t&&typeof t["@odata.count"]=="number"&&(n.count=t["@odata.count"]),t&&typeof t["@odata.nextLink"]=="string"&&(n.nextLink=t["@odata.nextLink"]),n}async script(e,t={}){if(!this._client)throw new Error("Query#script: no client attached (use FMSOData#from)");return me(this._client,this._entitySet,e,t)}};function xe(r,e){let t=[];if(r.select&&r.select.length>0&&t.push(["$select",r.select.join(",")]),r.filter&&t.push(["$filter",r.filter]),r.expand&&r.expand.length>0){let n=r.expand.map(i=>{if(!i.options)return i.name;let s=xe(i.options,{topLevel:!1});return s?`${i.name}(${s})`:i.name});t.push(["$expand",n.join(",")])}return r.orderby&&r.orderby.length>0&&t.push(["$orderby",r.orderby.map(n=>`${n.field} ${n.dir}`).join(",")]),r.top!==void 0&&t.push(["$top",String(r.top)]),r.skip!==void 0&&t.push(["$skip",String(r.skip)]),r.count&&t.push(["$count","true"]),r.search&&t.push(["$search",r.search]),r.apply&&t.push(["$apply",r.apply]),e.topLevel?se(t):t.map(([n,i])=>`${n}=${i}`).join(";")}var N=class{constructor(e){var t;if(!e.host)throw new TypeError("FMSOData: `host` is required");if(!e.database)throw new TypeError("FMSOData: `database` is required");if(e.token===void 0||e.token===null)throw new TypeError("FMSOData: `token` is required");this.host=e.host.replace(/\/+$/,""),this.database=e.database,this.baseUrl=`${this.host}/fmi/odata/v4/${encodeURIComponent(this.database)}`,this.timeoutMs=e.timeoutMs,this._ctx=u({token:e.token,fetch:(t=e.fetch)!=null?t:globalThis.fetch.bind(globalThis),timeoutMs:e.timeoutMs},e.onUnauthorized?{onUnauthorized:e.onUnauthorized}:{})}from(e){if(!e)throw new TypeError("FMSOData#from: entitySet is required");return new A(this.baseUrl,e,this)}async request(e,t={}){return b(this._ctx,this._resolveUrl(e),t)}async rawRequest(e,t={}){return g(this._ctx,this._resolveUrl(e),t)}async script(e,t={}){return fe(this,e,t)}async scriptById(e,t={}){return he(this,e,t)}async metadata(e={}){return this._metadataFetcher||(this._metadataFetcher=new F(this._ctx,this.baseUrl)),this._metadataFetcher.fetch(e)}async metadataXml(e={}){return this._metadataFetcher||(this._metadataFetcher=new F(this._ctx,this.baseUrl)),this._metadataFetcher.fetchXml(e)}async version(){if(this._detectedVersion!==void 0)return this._detectedVersion;try{let e=await this.serverVersion();if(!e)return this._detectedVersion=null,null;let t=String(e.major);return this._detectedVersion=t in $?t:"future",this._detectedVersion}catch(e){return this._detectedVersion=null,null}}async serverVersion(){var e;if(this._detectedServerVersion!==void 0)return this._detectedServerVersion;try{let t=await this.metadata();return this._detectedServerVersion=(e=t.serverVersion)!=null?e:null,this._detectedServerVersion}catch(t){return this._detectedServerVersion=null,null}}async versionInfo(){let e=await this.version();return e?$[e]:null}async hasFeature(e){let t=await this.version();return t?q(t,e):!1}batch(){return new C(this)}_resolveUrl(e){return/^https?:\/\//i.test(e)?e:e.startsWith("/")?`${this.baseUrl}${e}`:`${this.baseUrl}/${e}`}};return Oe(Ze);})();
package/dist/http.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * HTTP plumbing shared by the query builder, entity handles, and (later)
3
+ * containers, scripts, metadata, and batch.
4
+ *
5
+ * Aligned with `@fms-odata/spec-ts` for auth type definitions. fms-odata-js
6
+ * keeps its own `resolveAuthHeader`, `basicAuth`, `combineSignals`, and
7
+ * `executeRequest` implementations which are more feature-rich (401 retry,
8
+ * timeout composition, browser/Web Viewer compatibility).
9
+ *
10
+ * Responsibilities:
11
+ * - Authorization header resolution (Basic, Bearer, or FMID, auto-detected).
12
+ * - Timeout + AbortSignal composition.
13
+ * - 401 retry via `onUnauthorized` (once).
14
+ * - Error envelope normalization into `FMSODataError`.
15
+ *
16
+ * @see https://github.com/fsans/fms-odata-spec/blob/main/docs/04-authentication.md
17
+ */
18
+ import type { TokenProvider, RequestOptions } from './types.js';
19
+ /** Resolve a `TokenProvider` to a complete Authorization header value. */
20
+ export declare function resolveAuthHeader(provider: TokenProvider): Promise<string>;
21
+ /** Encode an FMS account username + password into a `Basic …` header value. */
22
+ export declare function basicAuth(user: string, password: string): string;
23
+ /** Build an FMID auth header value for FileMaker Cloud (Claris ID token). */
24
+ export declare function fmidAuth(token: string): string;
25
+ /** Auth scheme type (aligned with spec). */
26
+ export type { FMAuthScheme, FMAuthToken, FMAuthTokenProvider } from '@fms-odata/spec-ts';
27
+ /** Combine multiple `AbortSignal`s into one that aborts when any input aborts. */
28
+ export declare function combineSignals(signals: ReadonlyArray<AbortSignal | undefined>): AbortSignal | undefined;
29
+ /** Options accepted by the shared request executor. */
30
+ export interface HttpRequestOptions extends RequestOptions {
31
+ method?: string;
32
+ headers?: HeadersInit;
33
+ body?: BodyInit | null;
34
+ /** Expected response shape; controls default Accept header. */
35
+ accept?: 'json' | 'xml' | 'text' | 'binary' | 'none';
36
+ }
37
+ /** Context supplied by `FMSOData` to execute a request. */
38
+ export interface HttpClientContext {
39
+ token: TokenProvider;
40
+ onUnauthorized?: () => void | Promise<void>;
41
+ fetch: typeof globalThis.fetch;
42
+ timeoutMs: number | undefined;
43
+ }
44
+ /**
45
+ * Execute an HTTP request against the FMS OData endpoint. Centralizes auth,
46
+ * timeout, retry, and error handling. Returns the raw `Response` on success.
47
+ */
48
+ export declare function executeRequest(ctx: HttpClientContext, url: string, opts?: HttpRequestOptions): Promise<Response>;
49
+ /** Convenience: execute and parse the response as JSON. */
50
+ export declare function executeJson<T = unknown>(ctx: HttpClientContext, url: string, opts?: HttpRequestOptions): Promise<T>;
51
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAK/D,0EAA0E;AAC1E,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAShF;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,4CAA4C;AAC5C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExF,kFAAkF;AAClF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,CAAC,WAAW,GAAG,SAAS,CAAC,GAC9C,WAAW,GAAG,SAAS,CAiBzB;AAED,uDAAuD;AACvD,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAA;CACrD;AAED,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B;AAUD;;;GAGG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,kBAAuB,GAC5B,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAqDD,2DAA2D;AAC3D,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAC3C,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,kBAAuB,GAC5B,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
@@ -0,0 +1,31 @@
1
+ export { FMSOData } from './client.js';
2
+ export { Batch, Changeset } from './batch.js';
3
+ export type { BatchHandle, BatchOpResult, BatchReadOp, BatchResult, } from './batch.js';
4
+ export { buildContainerJsonBody, ContainerRef, FM_CONTAINER_SUPPORTED_MIME_TYPES, sniffContainerMime, toBase64, } from './containers.js';
5
+ export type { ContainerDownload, ContainerJsonValue, ContainerUploadInput, FMContainerMimeType, } from './containers.js';
6
+ export { EntityRef } from './entity.js';
7
+ export type { EntityWriteOptions, EntityRefInfo } from './entity.js';
8
+ export { FMSODataError, FMScriptError, isFMSODataError, isFMScriptError } from './errors.js';
9
+ export type { ODataErrorBody } from './errors.js';
10
+ export { basicAuth, fmidAuth } from './http.js';
11
+ export type { FMAuthScheme, FMAuthToken, FMAuthTokenProvider } from './http.js';
12
+ export { MetadataFetcher } from './metadata.js';
13
+ export type { EdmAction, EdmEntitySet, EdmEntityType, EdmProperty, MetadataOptions, ODataMetadata, } from './metadata.js';
14
+ export { Filter, Query, filterFactory } from './query.js';
15
+ export type { FilterFactory, FilterInput, OrderDir, QueryResult } from './query.js';
16
+ export type { AggregateFunction } from '@fms-odata/spec-ts';
17
+ export { ScriptInvoker } from './scripts.js';
18
+ export type { ScriptOptions, ScriptResult, ScriptScope, ScriptIdentifier } from './scripts.js';
19
+ export type { FMSODataOptions, TokenProvider, RequestOptions } from './types.js';
20
+ export type { ODataLiteral } from './url.js';
21
+ export { FM_VERSION_NAMES, FM_VERSION_MATRIX, ODATA_PROTOCOL_VERSION, hasFeature, hasQueryOption, minVersionForFeature, parseServerVersion, parseVersionString, } from '@fms-odata/spec-ts';
22
+ export type { FMVersionMajor, FMVersionStatus, FMFeatureFlags, FMQueryOptionFlags, FMVersionInfo, FMServerVersion, } from '@fms-odata/spec-ts';
23
+ /** @deprecated Use `FMSOData` instead. */
24
+ export { FMSOData as FMOData } from './client.js';
25
+ /** @deprecated Use `FMSODataError` instead. */
26
+ export { FMSODataError as FMODataError } from './errors.js';
27
+ /** @deprecated Use `isFMSODataError` instead. */
28
+ export { isFMSODataError as isFMODataError } from './errors.js';
29
+ /** @deprecated Use `FMSODataOptions` instead. */
30
+ export type { FMSODataOptions as FMODataOptions } from './types.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC7C,YAAY,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,iCAAiC,EACjC,kBAAkB,EAClB,QAAQ,GACT,MAAM,iBAAiB,CAAA;AAC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oB,CAAA;AAC3B,YAAY,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAQ3B,0CAA0C;AAC1C,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AACjD,+CAA+C;AAC/C,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,MAAM,aAAa,CAAA;AAC3D,iDAAiD;AACjD,OAAO,EAAE,eAAe,IAAI,cAAc,EAAE,MAAM,aAAa,CAAA;AAC/D,iDAAiD;AACjD,YAAY,EAAE,eAAe,IAAI,cAAc,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * $metadata (EDMX/CSDL) fetch and lightweight parser.
3
+ *
4
+ * FMS returns a subset of the full OData CSDL spec. This module parses just
5
+ * what FMS emits: EntityTypes, EntitySets, and Actions (FileMaker scripts).
6
+ * No inheritance, complex types, or enums are expected.
7
+ *
8
+ * The parser is intentionally dependency-free and uses simple regex-based
9
+ * extraction to stay within the bundle budget (~1 KB gzipped).
10
+ */
11
+ import { type HttpClientContext } from './http.js';
12
+ import type { RequestOptions } from './types.js';
13
+ import { type FMServerVersion } from '@fms-odata/spec-ts';
14
+ /** Property on an entity type (field in FileMaker). */
15
+ export interface EdmProperty {
16
+ name: string;
17
+ type: string;
18
+ nullable: boolean;
19
+ maxLength?: number;
20
+ }
21
+ /** Entity type (FileMaker table occurrence). */
22
+ export interface EdmEntityType {
23
+ name: string;
24
+ keys: string[];
25
+ properties: EdmProperty[];
26
+ navigationProperties: {
27
+ name: string;
28
+ target: string;
29
+ collection: boolean;
30
+ }[];
31
+ }
32
+ /** Entity set (exposed layout/table in OData). */
33
+ export interface EdmEntitySet {
34
+ name: string;
35
+ entityType: string;
36
+ }
37
+ /** Action (FileMaker script exposed as OData Action). */
38
+ export interface EdmAction {
39
+ name: string;
40
+ boundTo?: string;
41
+ parameters: {
42
+ name: string;
43
+ type: string;
44
+ }[];
45
+ }
46
+ /** Parsed OData metadata document. */
47
+ export interface ODataMetadata {
48
+ namespace: string;
49
+ entityTypes: EdmEntityType[];
50
+ entitySets: EdmEntitySet[];
51
+ actions: EdmAction[];
52
+ /** Product version string extracted from Org.OData.Core.V1.ProductVersion annotation (if present). */
53
+ productVersion?: string;
54
+ /** Full parsed server version (major.minor.patch + raw), if detected from $metadata. */
55
+ serverVersion?: FMServerVersion;
56
+ /** Original XML, for debugging and forward compatibility. */
57
+ raw: string;
58
+ }
59
+ /** Options for metadata fetch. */
60
+ export interface MetadataOptions extends RequestOptions {
61
+ /** Force refetch, bypassing the internal cache. */
62
+ refresh?: boolean;
63
+ }
64
+ /**
65
+ * @internal — parse raw CSDL XML into ODataMetadata.
66
+ * Throws FMSODataError for malformed XML.
67
+ */
68
+ export declare function parseMetadata(xml: string): ODataMetadata;
69
+ /**
70
+ * @internal — fetch raw $metadata XML.
71
+ */
72
+ export declare function fetchMetadataXml(ctx: HttpClientContext, baseUrl: string, opts?: RequestOptions): Promise<string>;
73
+ /**
74
+ * Metadata fetcher bound to a client. Caches by default; pass `refresh: true` to bypass.
75
+ * @internal — exported for testing; use via `FMSOData#metadata()`.
76
+ */
77
+ export declare class MetadataFetcher {
78
+ private _ctx;
79
+ private _baseUrl;
80
+ private _cache;
81
+ constructor(_ctx: HttpClientContext, _baseUrl: string);
82
+ fetchXml(opts?: RequestOptions): Promise<string>;
83
+ fetch(opts?: MetadataOptions): Promise<ODataMetadata>;
84
+ }
85
+ //# sourceMappingURL=metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAsB,KAAK,eAAe,EAAE,MAA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GG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CA+DxD;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;GAGG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,QAAQ;IAJlB,OAAO,CAAC,MAAM,CAAoC;gBAGxC,IAAI,EAAE,iBAAiB,EACvB,QAAQ,EAAE,MAAM;IAGpB,QAAQ,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpD,KAAK,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,aAAa,CAAC;CAQhE"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Fluent OData query builder.
3
+ *
4
+ * `Query` accumulates `$select`, `$filter`, `$expand`, `$orderby`, `$top`,
5
+ * `$skip`, `$count`, and `$search` options and serializes them into an absolute
6
+ * URL via `toURL()`. Actual HTTP execution (`.get()`) lands in M3 alongside
7
+ * auth, error handling, and the mock server.
8
+ */
9
+ import type { FMSOData } from './client.js';
10
+ import { type ContainerJsonValue } from './containers.js';
11
+ import { EntityRef } from './entity.js';
12
+ import { type ScriptOptions, type ScriptResult } from './scripts.js';
13
+ import type { RequestOptions } from './types.js';
14
+ import { type ODataLiteral } from './url.js';
15
+ import type { AggregateFunction } from '@fms-odata/spec-ts';
16
+ /**
17
+ * Opaque filter expression produced by `filterFactory`. Use `.and()`, `.or()`,
18
+ * `.not()` to compose; pass to `Query#filter`.
19
+ */
20
+ export declare class Filter {
21
+ readonly expr: string;
22
+ constructor(expr: string);
23
+ toString(): string;
24
+ and(other: Filter | string): Filter;
25
+ or(other: Filter | string): Filter;
26
+ not(): Filter;
27
+ /** @internal */
28
+ static coerce(x: Filter | string): string;
29
+ }
30
+ /** Factory passed to callback-form `Query#filter(f => ...)`. */
31
+ export interface FilterFactory {
32
+ eq(field: string, value: ODataLiteral): Filter;
33
+ ne(field: string, value: ODataLiteral): Filter;
34
+ gt(field: string, value: ODataLiteral): Filter;
35
+ ge(field: string, value: ODataLiteral): Filter;
36
+ lt(field: string, value: ODataLiteral): Filter;
37
+ le(field: string, value: ODataLiteral): Filter;
38
+ startswith(field: string, value: string): Filter;
39
+ endswith(field: string, value: string): Filter;
40
+ contains(field: string, value: string): Filter;
41
+ and(a: Filter | string, b: Filter | string): Filter;
42
+ or(a: Filter | string, b: Filter | string): Filter;
43
+ not(a: Filter | string): Filter;
44
+ /** Escape hatch: embed a raw OData filter fragment verbatim. */
45
+ raw(expr: string): Filter;
46
+ }
47
+ export declare const filterFactory: FilterFactory;
48
+ export type FilterInput = Filter | string | ((f: FilterFactory) => Filter | string);
49
+ export type OrderDir = 'asc' | 'desc';
50
+ /** @internal */
51
+ export interface QueryOptionsState {
52
+ select?: string[];
53
+ filter?: string;
54
+ expand?: Array<{
55
+ name: string;
56
+ options?: QueryOptionsState;
57
+ }>;
58
+ orderby?: Array<{
59
+ field: string;
60
+ dir: OrderDir;
61
+ }>;
62
+ top?: number;
63
+ skip?: number;
64
+ count?: boolean;
65
+ search?: string;
66
+ apply?: string;
67
+ }
68
+ /**
69
+ * Fluent query builder. Methods mutate and return `this` for chaining.
70
+ */
71
+ /** Result envelope returned by `Query#get()`. */
72
+ export interface QueryResult<T> {
73
+ value: T[];
74
+ /** Present when `.count()` was enabled on the query. */
75
+ count?: number;
76
+ /** Server-driven paging link. */
77
+ nextLink?: string;
78
+ }
79
+ export declare class Query<T = Record<string, unknown>> {
80
+ /** @internal */ readonly _state: QueryOptionsState;
81
+ /** @internal */ readonly _baseUrl: string;
82
+ /** @internal */ readonly _entitySet: string;
83
+ /** @internal */ readonly _client: FMSOData | undefined;
84
+ constructor(baseUrl: string, entitySet: string, client?: FMSOData);
85
+ select(...fields: string[]): this;
86
+ filter(input: FilterInput): this;
87
+ or(input: FilterInput): this;
88
+ expand(name: string, build?: (q: Query) => Query | void): this;
89
+ orderby(field: string, dir?: OrderDir): this;
90
+ top(n: number): this;
91
+ skip(n: number): this;
92
+ count(enabled?: boolean): this;
93
+ search(term: string): this;
94
+ /**
95
+ * Set a raw `$apply` expression. Use this for advanced transformations
96
+ * that the `aggregate()` / `groupBy()` helpers don't cover.
97
+ *
98
+ * Requires FileMaker Server 2024+ (v22). Use `db.hasFeature('applyAggregation')`
99
+ * to check before calling.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const result = await db.from('orders').apply('aggregate(total with sum as totalSum)')
104
+ * .get()
105
+ * ```
106
+ */
107
+ apply(expr: string): this;
108
+ /**
109
+ * Aggregate the entity set. Produces a `$apply=aggregate(...)` expression.
110
+ *
111
+ * Requires FileMaker Server 2024+ (v22).
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * const result = await db.from('orders')
116
+ * .aggregate([{ field: 'total', function: 'sum', alias: 'totalSum' }])
117
+ * .get()
118
+ * // $apply=aggregate(total with sum as totalSum)
119
+ * ```
120
+ */
121
+ aggregate(expressions: Array<{
122
+ field: string;
123
+ function: AggregateFunction;
124
+ alias: string;
125
+ }>): this;
126
+ /**
127
+ * Group the entity set by one or more fields, optionally with aggregation.
128
+ * Produces a `$apply=groupby((fields), aggregate(...))` expression.
129
+ *
130
+ * Requires FileMaker Server 2024+ (v22).
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const result = await db.from('orders')
135
+ * .groupBy(
136
+ * ['customerId'],
137
+ * [{ field: 'total', function: 'sum', alias: 'totalSum' }],
138
+ * )
139
+ * .get()
140
+ * // $apply=groupby((customerId),aggregate(total with sum as totalSum))
141
+ * ```
142
+ */
143
+ groupBy(fields: string[], aggregateExpressions?: Array<{
144
+ field: string;
145
+ function: AggregateFunction;
146
+ alias: string;
147
+ }>): this;
148
+ /** Build the absolute request URL for this query. */
149
+ toURL(): string;
150
+ /**
151
+ * Get a handle to a single entity by its primary key. Subsequent operations
152
+ * (`.get()`, `.patch()`, `.delete()`) hit `/<EntitySet>(<key>)`.
153
+ */
154
+ byKey(key: string | number): EntityRef<T>;
155
+ /**
156
+ * `POST` a new entity to the collection. Returns the created row (FMS echoes
157
+ * it by default).
158
+ */
159
+ create(body: Partial<T> | Record<string, unknown>, opts?: RequestOptions): Promise<T>;
160
+ /**
161
+ * `POST` a new entity carrying one or more container fields. Maps to the
162
+ * Claris "Operation 1" — the request body is a JSON object containing
163
+ * regular field values plus, for each container field, the base64 data
164
+ * and the `@com.filemaker.odata.{ContentType,Filename}` annotations.
165
+ *
166
+ * Each container value's `data` must already be base64-encoded.
167
+ *
168
+ * @example
169
+ * await db.from('contact').createWithContainers(
170
+ * { first_name: 'Bob', last_name: 'Jones' },
171
+ * { photo: { data: photoB64, contentType: 'image/png', filename: 'BJONES.png' } },
172
+ * )
173
+ */
174
+ createWithContainers(regularFields: Partial<T> | Record<string, unknown>, containers: Record<string, ContainerJsonValue>, opts?: RequestOptions): Promise<T>;
175
+ /**
176
+ * Execute the query. Returns the parsed OData collection envelope.
177
+ */
178
+ get(opts?: RequestOptions): Promise<QueryResult<T>>;
179
+ /**
180
+ * Invoke a FileMaker script in the context of this query's entity set.
181
+ *
182
+ * Filter / select / orderby / paging state on the `Query` is **ignored** —
183
+ * the underlying OData Action only cares about the entity set. Use
184
+ * `EntityRef#script` to run a script in the context of a specific record.
185
+ */
186
+ script(name: string, opts?: ScriptOptions): Promise<ScriptResult>;
187
+ }
188
+ /**
189
+ * Serialize query options either as a top-level querystring (percent-encoded)
190
+ * or as a nested `$expand` option block (semicolon-joined, unencoded — the
191
+ * outer param encoder will encode the whole block once).
192
+ *
193
+ * @internal
194
+ */
195
+ export declare function serializeOptions(s: QueryOptionsState, opts: {
196
+ topLevel: boolean;
197
+ }): string;
198
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AA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