@cognite/cli 1.3.2-alpha.53 → 1.3.2-alpha.https1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_templates/app/new/config/vite.config.ts.ejs.t +6 -3
- package/_templates/app/new/root/.npmrc.ejs.t +1 -0
- package/_templates/app/new/root/AGENTS.md.ejs.t +12 -60
- package/_templates/app/new/root/SPEC.md.ejs.t +15 -17
- package/_templates/app/new/root/gitignore.ejs.t +3 -0
- package/_templates/app/new/root/package.json.ejs.t +2 -5
- package/dist/chunk-A5ASLC6T.js +7 -0
- package/dist/chunk-TYYH4NWG.js +9 -0
- package/dist/cli/cli.js +80 -180
- package/dist/deploy/index.d.ts +52 -22
- package/dist/deploy/index.js +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/{skills-SV7BPHAZ.js → skills-GQ5TZKCM.js} +1 -1
- package/package.json +2 -11
- package/dist/chunk-6C2Y3XBZ.js +0 -9
- package/dist/chunk-EI7MMDWY.js +0 -1
- package/dist/chunk-EILVJ2ZW.js +0 -1
- package/dist/chunk-VTE66IK5.js +0 -8
- package/dist/sdk-runtime/index.d.ts +0 -199
- package/dist/sdk-runtime/index.js +0 -1
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { CogniteClient, ClientOptions } from '@cognite/sdk';
|
|
2
2
|
|
|
3
|
-
type Deployment = {
|
|
4
|
-
org: string;
|
|
5
|
-
project: string;
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
deployClientId: string;
|
|
8
|
-
deploySecretName: string;
|
|
9
|
-
published: boolean;
|
|
10
|
-
/** Identity provider type. Defaults to "cdf" if not specified */
|
|
11
|
-
idpType?: "cdf" | "entra_id";
|
|
12
|
-
/** Tenant ID for Entra ID authentication. Required when idpType is "entra_id" */
|
|
13
|
-
tenantId?: string;
|
|
14
|
-
};
|
|
15
|
-
type App = {
|
|
16
|
-
externalId: string;
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
versionTag: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
declare const deploy: (deployment: Deployment, app: App, folder: string) => Promise<void>;
|
|
23
|
-
|
|
24
3
|
/**
|
|
25
4
|
* App Hosting HTTP API layer.
|
|
26
5
|
*
|
|
@@ -92,6 +71,42 @@ declare class AppHostingClient {
|
|
|
92
71
|
deploy(appExternalId: string, name: string, description: string, versionTag: string, fileContent: Buffer, fileName: string, published?: boolean): Promise<void>;
|
|
93
72
|
}
|
|
94
73
|
|
|
74
|
+
type Deployment = {
|
|
75
|
+
org: string;
|
|
76
|
+
project: string;
|
|
77
|
+
baseUrl: string;
|
|
78
|
+
deployClientId: string;
|
|
79
|
+
deploySecretName: string;
|
|
80
|
+
published: boolean;
|
|
81
|
+
/** Identity provider type. Defaults to "cdf" if not specified */
|
|
82
|
+
idpType?: 'cdf' | 'entra_id';
|
|
83
|
+
/** Tenant ID for Entra ID authentication. Required when idpType is "entra_id" */
|
|
84
|
+
tenantId?: string;
|
|
85
|
+
};
|
|
86
|
+
type App = {
|
|
87
|
+
externalId: string;
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
versionTag: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Package `dist/` into `<folder>/.cognite-bundles/<externalId>-<versionTag>.zip`
|
|
95
|
+
* and upload it via an already-authenticated `AppHostingClient`. Both deploy
|
|
96
|
+
* entry points (programmatic `deploy()` and the CLI's interactive path) reuse
|
|
97
|
+
* this so packaging/upload behaviour stays in one place.
|
|
98
|
+
*
|
|
99
|
+
* The bundle file is intentionally left on disk so the follow-on
|
|
100
|
+
* `cognite apps sign` + `cognite apps publish` flow can operate on the
|
|
101
|
+
* exact bytes the backend received.
|
|
102
|
+
*/
|
|
103
|
+
declare function packageAndUpload(client: AppHostingApiClient, app: App, folder: string, published: boolean): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Programmatic deploy used by CI scripts: resolves an SDK from the
|
|
106
|
+
* deployment's env-var credentials, then runs `packageAndUpload`.
|
|
107
|
+
*/
|
|
108
|
+
declare const deploy: (deployment: Deployment, app: App, folder: string) => Promise<void>;
|
|
109
|
+
|
|
95
110
|
/**
|
|
96
111
|
* Application Packaging
|
|
97
112
|
*
|
|
@@ -136,4 +151,19 @@ type DiscoverSignaturesDeps = {
|
|
|
136
151
|
};
|
|
137
152
|
declare function discoverSignatures(bundlePath: string, deps?: DiscoverSignaturesDeps): string[];
|
|
138
153
|
|
|
139
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Stable on-disk location for a packaged app bundle, keyed on app + version.
|
|
156
|
+
*
|
|
157
|
+
* `cognite apps deploy` writes the zip here and leaves it in place, so the
|
|
158
|
+
* subsequent `cognite apps sign` + `cognite apps publish` steps operate on
|
|
159
|
+
* the *exact bytes* that were uploaded — the bundle SHA in the signed
|
|
160
|
+
* payload matches what the backend has on hand.
|
|
161
|
+
*
|
|
162
|
+
* Lives under a single gitignored folder (`.cognite-bundles/`) so signed
|
|
163
|
+
* artefacts don't accidentally land in version control.
|
|
164
|
+
*/
|
|
165
|
+
declare const BUNDLE_DIR = ".cognite-bundles";
|
|
166
|
+
declare function bundleFileName(externalId: string, versionTag: string): string;
|
|
167
|
+
declare function bundlePath(cwd: string, externalId: string, versionTag: string): string;
|
|
168
|
+
|
|
169
|
+
export { type App, AppHostingClient, ApplicationPackager, BUNDLE_DIR, type Deployment, SIGNATURE_SUFFIXES, bundleFileName, bundlePath, deploy, discoverSignatures, getSdk, getToken, packageAndUpload };
|
package/dist/deploy/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-TYYH4NWG.js";export{a as AppHostingClient,b as ApplicationPackager,c as BUNDLE_DIR,j as SIGNATURE_SUFFIXES,d as bundleFileName,e as bundlePath,i as deploy,k as discoverSignatures,g as getSdk,f as getToken,h as packageAndUpload};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export { App, AppHostingClient, ApplicationPackager, Deployment, SIGNATURE_SUFFIXES, deploy, discoverSignatures, getSdk, getToken } from './deploy/index.js';
|
|
2
|
-
export { DuneRuntime, createDuneRuntime, createDuneRuntimeFromViews } from './sdk-runtime/index.js';
|
|
1
|
+
export { App, AppHostingClient, ApplicationPackager, BUNDLE_DIR, Deployment, SIGNATURE_SUFFIXES, bundleFileName, bundlePath, deploy, discoverSignatures, getSdk, getToken, packageAndUpload } from './deploy/index.js';
|
|
3
2
|
import '@cognite/sdk';
|
|
4
|
-
import 'graphql';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c}from"./chunk-TYYH4NWG.js";export{o as AppHostingClient,r as ApplicationPackager,e as BUNDLE_DIR,b as SIGNATURE_SUFFIXES,f as bundleFileName,m as bundlePath,a as deploy,c as discoverSignatures,t as getSdk,p as getToken,x as packageAndUpload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d}from"./chunk-
|
|
1
|
+
import{b as a,c as b,d as c,e as d}from"./chunk-A5ASLC6T.js";export{c as buildPullArgs,a as execSkillsCli,b as pullAllArgs,d as registerSkillsCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognite/cli",
|
|
3
|
-
"version": "1.3.2-alpha.
|
|
3
|
+
"version": "1.3.2-alpha.https1",
|
|
4
4
|
"description": "CLI for Cognite Data Fusion",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Cognite",
|
|
@@ -22,11 +22,6 @@
|
|
|
22
22
|
"types": "./dist/deploy/index.d.ts",
|
|
23
23
|
"import": "./dist/deploy/index.js",
|
|
24
24
|
"default": "./dist/deploy/index.js"
|
|
25
|
-
},
|
|
26
|
-
"./sdk-runtime": {
|
|
27
|
-
"types": "./dist/sdk-runtime/index.d.ts",
|
|
28
|
-
"import": "./dist/sdk-runtime/index.js",
|
|
29
|
-
"default": "./dist/sdk-runtime/index.js"
|
|
30
25
|
}
|
|
31
26
|
},
|
|
32
27
|
"bin": {
|
|
@@ -39,6 +34,7 @@
|
|
|
39
34
|
],
|
|
40
35
|
"scripts": {
|
|
41
36
|
"build": "tsup",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
42
38
|
"prepare": "tsup",
|
|
43
39
|
"prepack": "pnpm run build",
|
|
44
40
|
"prepublishOnly": "pnpm run build",
|
|
@@ -51,10 +47,6 @@
|
|
|
51
47
|
"dependencies": {
|
|
52
48
|
"@cognite/app-sdk": "^0.5.1",
|
|
53
49
|
"@cognite/sdk": "^10.10.0",
|
|
54
|
-
"@graphql-codegen/cli": "^7.0.0",
|
|
55
|
-
"@graphql-codegen/typescript": "^6.0.1",
|
|
56
|
-
"@graphql-codegen/typescript-generic-sdk": "^5.0.1",
|
|
57
|
-
"@graphql-codegen/typescript-operations": "^6.0.2",
|
|
58
50
|
"@sentry/node": "^10.51.0",
|
|
59
51
|
"@zip.js/zip.js": "^2.7.0",
|
|
60
52
|
"chalk": "^5.6.2",
|
|
@@ -63,7 +55,6 @@
|
|
|
63
55
|
"dotenv": "^17.4.2",
|
|
64
56
|
"enquirer": "^2.4.1",
|
|
65
57
|
"execa": "^5.1.1",
|
|
66
|
-
"graphql": "^16.13.2",
|
|
67
58
|
"hygen": "^6.2.11",
|
|
68
59
|
"jose": "^6.2.2",
|
|
69
60
|
"mixpanel": "^0.21.0",
|
package/dist/chunk-6C2Y3XBZ.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-EI7MMDWY.js";import Y from"fs";import gt from"path";var B="https://docs.cognite.com/cdf/access/";function m(n){return n!==null&&typeof n=="object"}s(m,"isRecord");function S(n){return n instanceof Error&&"status"in n&&typeof n.status=="number"}s(S,"isHttpError");function X(n){switch(n){case 401:return`Your credentials are invalid or expired. Check your client ID and secret.
|
|
2
|
-
See: ${B}`;case 403:return`You don't have the required CDF capabilities. Please contact your CDF admin.
|
|
3
|
-
See: ${B}`;default:return}}s(X,"httpStatusHint");function h(n){let t=n instanceof Error?n:new Error(String(n));if(!S(t))return null;let e=X(t.status);return e?Object.assign(new Error(`${t.message}
|
|
4
|
-
${e}`),{cause:t}):null}s(h,"enrichedHttpError");function Z(n){if(!m(n))return null;let t=n.missing;if(Array.isArray(t))return t;let e=n.data;if(m(e)){let r=e.error;if(m(r)&&Array.isArray(r.missing))return r.missing;if(Array.isArray(e.missing))return e.missing}return null}s(Z,"findMissingArray");function Q(n,t){if(!S(n)||n.status!==400)return!1;let e=Z(n);return e?e.some(r=>m(r)&&typeof r.externalId=="string"&&t.includes(r.externalId)):!1}s(Q,"isMissingExternalIdError");function $(n,t){return S(n)&&n.status===404||Q(n,t)}s($,"isNotFoundError");var M=["DRAFT","PUBLISHED","DEPRECATED","ARCHIVED"],J=["ACTIVE","PREVIEW"],I=class I extends Error{constructor(t,e){super(`Version ${e} of app ${t} not found`),this.name="AppVersionNotFoundError",this.appExternalId=t,this.version=e}};s(I,"AppVersionNotFoundError");var C=I;function q(n,t){return n.includes(t)}s(q,"includesValue");function tt(n){return q(M,n)}s(tt,"isAppVersionLifecycleState");function et(n){return q(J,n)}s(et,"isAppVersionAlias");function nt(n){return typeof n.version=="string"&&tt(n.lifecycleState)&&typeof n.entrypoint=="string"&&typeof n.createdTime=="number"&&typeof n.createdBy=="string"&&typeof n.appExternalId=="string"&&(n.alias===void 0||et(n.alias))&&(n.comment===void 0||typeof n.comment=="string")}s(nt,"isAppVersion");function H(n){if(!m(n))throw new Error("Invalid version response: not an object");if(!nt(n))throw new Error("Invalid version response: missing or malformed fields");return n}s(H,"parseAppVersion");var b=class b{constructor(t){this.client=t}get appsBasePath(){return`/api/v1/projects/${encodeURIComponent(this.client.project)}/apphosting/apps`}async createApp(t,e,r){try{await this.client.post(this.appsBasePath,{data:{items:[{externalId:t,name:e,description:r}]}})}catch(o){throw h(o)??o}}async uploadVersion(t,e,r,o,i="index.html"){console.log(`\u{1F4E4} Uploading version ${e}...`);let a=new FormData;a.append("file",new Blob([new Uint8Array(r)]),o),a.append("version",e),a.append("entryPath",i);let c=encodeURIComponent(t),p=`${this.appsBasePath}/${c}/versions`,l=await this.client.authenticate(),g=`${this.client.getBaseUrl()}${p}`,u=new AbortController,K=setTimeout(()=>u.abort(),300*1e3),A;try{A=await fetch(g,{method:"POST",headers:{Authorization:`Bearer ${l}`},body:a,signal:u.signal})}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Error("Upload timed out after 5 minutes"):f}finally{clearTimeout(K)}if(!A.ok){let f=await A.text(),x=f;try{let k=JSON.parse(f);if(m(k)){let w=k.error;if(typeof w=="string")x=w;else if(m(w)){let E=w.message,j=w.code;x=typeof E=="string"?E:j!=null?`Unknown error (code: ${j})`:f}else{let E=k.message;x=typeof E=="string"?E:f}}}catch{}let O=A.headers.get("x-request-id"),W=O?` | X-Request-ID: ${O}`:"",N=Object.assign(new Error(`Upload failed: ${A.status} \u2014 ${x}${W}`),{status:A.status});throw h(N)??N}console.log(`\u2705 Version ${e} uploaded`)}async getVersion(t,e){let r=encodeURIComponent(t),o=encodeURIComponent(e),i=`${this.appsBasePath}/${r}/versions/${o}`;try{let a=await this.client.get(i);return H(a.data)}catch(a){throw $(a,[t,e])?new C(t,e):h(a)??a}}async getActiveVersion(t){let e=encodeURIComponent(t),r=`${this.appsBasePath}/${e}/active`;try{let o=await this.client.get(r);return H(o.data)}catch(o){if($(o,[t]))return null;throw h(o)??o}}async updateVersions(t,e){let r=encodeURIComponent(t),o=`${this.appsBasePath}/${r}/versions/update`;try{await this.client.post(o,{data:{items:e}})}catch(i){throw h(i)??i}}async submitSignatures(t,e,r){let o=encodeURIComponent(t),i=encodeURIComponent(e),a=`${this.appsBasePath}/${o}/versions/${i}/signatures`;try{await this.client.post(a,{data:{items:r}})}catch(c){throw h(c)??c}}};s(b,"AppHostingApi");var V=b;var T=class T{constructor(t){this.api=new V(t)}getVersion(t,e){return this.api.getVersion(t,e)}uploadVersion(t,e,r,o,i){return this.api.uploadVersion(t,e,r,o,i)}async ensureApp(t,e,r){console.log("\u{1F50D} Ensuring app exists...");try{await this.api.createApp(t,e,r),console.log(`\u2705 App '${t}' created`)}catch(o){if(S(o)&&o.status===409){console.log(`\u2705 App '${t}' already exists`);return}throw o}}async submitSignatures(t,e,r){r.length!==0&&(console.log(`\u{1F50F} Submitting ${r.length} signature${r.length===1?"":"s"} for version ${e}...`),await this.api.submitSignatures(t,e,r),console.log("\u2705 Signatures stored"))}async publishVersion(t,e){await this.api.updateVersions(t,[{version:e,update:{lifecycleState:{set:"PUBLISHED"}}}])}async publishAndActivate(t,e){console.log(`\u{1F680} Publishing and activating version ${e}...`),await this.api.updateVersions(t,[{version:e,update:{lifecycleState:{set:"PUBLISHED"},alias:{set:"ACTIVE"}}}]),console.log(`\u2705 Version ${e} is now PUBLISHED and ACTIVE`)}getActiveVersion(t){return this.api.getActiveVersion(t)}async deactivateVersion(t,e){await this.api.updateVersions(t,[{version:e,update:{alias:{setNull:!0}}}])}async activateVersion(t,e){let r=null;try{r=await this.api.getActiveVersion(t)}catch{r=null}let o=r&&r.version!==e?r.version:void 0;return await this.api.updateVersions(t,[{version:e,update:{alias:{set:"ACTIVE"}}}]),{supersededVersion:o}}async deploy(t,e,r,o,i,a,c=!1){console.log(`
|
|
5
|
-
\u{1F680} Deploying application via App Hosting API...
|
|
6
|
-
`);try{await this.ensureApp(t,e,r),await this.uploadVersion(t,o,i,a),c&&await this.publishAndActivate(t,o),console.log(`
|
|
7
|
-
\u2705 Deployment successful!`)}catch(p){let l=p instanceof Error?p.message:String(p);throw Object.assign(new Error(`Deployment failed: ${l}`),{cause:p})}}};s(T,"AppHostingClient");var P=T;import y from"fs";import d from"path";import{parseAndValidateManifestConfig as rt}from"@cognite/app-sdk/vite";import{BlobReader as ot,Uint8ArrayWriter as st,ZipWriter as it}from"@zip.js/zip.js";var R="package.json",D="package-lock.json",z="manifest.json",_=".cognite",U=class U{constructor(t="dist"){this.distPath=d.isAbsolute(t)?t:d.join(process.cwd(),t),this.appRoot=d.dirname(this.distPath)}validateBuildDirectory(){if(!y.existsSync(this.distPath))throw new Error(`Build directory "${this.distPath}" not found. Run build first.`);let t=d.join(this.appRoot,R);if(!y.existsSync(t))throw new Error(`"${t}" not found. It is required for deployment.`);let e=d.join(this.appRoot,D);if(!y.existsSync(e))throw new Error(`"${e}" not found. It is required for deployment.`)}async createZip(t="app.zip",e=!1){this.validateBuildDirectory(),console.log("\u{1F4E6} Packaging application...");let r=new it(new st,{level:9}),o=s(async(p,l)=>{await r.add(l,new ot(await y.openAsBlob(p))),e&&console.log(` \u{1F4C4} ${l}`)},"addFile"),i=s(async p=>{let l=await y.promises.readdir(p,{withFileTypes:!0});for(let g of l){let u=d.join(p,g.name);g.isDirectory()?await i(u):await o(u,d.relative(this.distPath,u).replace(/\\/g,"/"))}},"addDir"),a;try{await i(this.distPath);let p=d.join(this.appRoot,R);await o(p,d.posix.join(_,R));let l=d.join(this.appRoot,z);if(y.existsSync(l)){let u=y.readFileSync(l,"utf-8");rt(u,l),await o(l,d.posix.join(_,z))}let g=d.join(this.appRoot,D);await o(g,d.posix.join(_,D)),a=await r.close()}catch(p){let l=p instanceof Error?p.message:String(p);throw new Error(`Failed to create zip: ${l}`)}await y.promises.writeFile(t,a);let c=(a.byteLength/1024/1024).toFixed(2);return console.log(`\u2705 App packaged: ${t} (${c} MB)`),t}};s(U,"ApplicationPackager");var v=U;import{CogniteClient as ut}from"@cognite/sdk";var at=s(()=>{let n=process.env.DEPLOYMENT_SECRETS;if(!n)return{};try{let t=JSON.parse(n),e={};for(let[r,o]of Object.entries(t))if(typeof o=="string"){let i=r.toLowerCase().replace(/_/g,"-");e[i]=o}return e}catch(t){return console.error("Error parsing DEPLOYMENT_SECRETS:",t),{}}},"loadSecretsFromEnv"),ct=s(n=>{let t;if(process.env.DEPLOYMENT_SECRET&&(t=process.env.DEPLOYMENT_SECRET),t||(t=at()[n]),t||(t=process.env[n]),!t)throw new Error(`Secret not found in environment: ${n}`);return t},"getSecretFromEnv"),pt=s(n=>{if(!n)return"";try{return new URL(n).hostname.replace(/\.cognitedata\.com$/,"")}catch{let t=n.replace(/^https?:\/\//,"");return t=t.split("/")[0],t=t.split(":")[0],t=t.replace(/\.cognitedata\.com$/,""),t}},"extractClusterFromUrl"),lt=s(async(n,t)=>{let e=`Basic ${btoa(`${n}:${t}`)}`,r=await fetch("https://auth.cognite.com/oauth2/token",{method:"POST",headers:{Authorization:e,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"client_credentials"})});if(!r.ok){let i=await r.text();throw new Error(`Failed to get token from CDF: ${r.status} ${r.statusText}
|
|
8
|
-
${i}`)}let o=await r.json();if(!o.access_token)throw new Error("No access token returned from CDF authentication");return o.access_token},"getTokenCdf"),dt=s(async(n,t,e,r)=>{if(!r)throw new Error("Entra ID authentication requires 'baseUrl' to be set in deployment configuration");let o=pt(r);if(!o)throw new Error(`Entra ID authentication requires 'baseUrl' to be a valid CDF URL (e.g., https://cluster.cognitedata.com), got: ${r}`);let i=`https://login.microsoftonline.com/${e}/oauth2/v2.0/token`,a=`https://${o}.cognitedata.com/.default`,c=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:n,client_secret:t,scope:a,grant_type:"client_credentials"})});if(!c.ok){let l=await c.text();throw new Error(`Failed to get token from Entra ID: ${c.status} ${c.statusText}
|
|
9
|
-
${l}`)}let p=await c.json();if(!p.access_token)throw new Error("No access token returned from Entra ID authentication");return p.access_token},"getTokenEntra"),F=s(async(n,t=process.env)=>{if(t.COGNITE_TOKEN)return t.COGNITE_TOKEN;let{deployClientId:e,deploySecretName:r,idpType:o="cdf",tenantId:i,baseUrl:a}=n,c=ct(r);if(o==="entra_id"){if(!i)throw new Error("Entra ID authentication requires 'tenantId' in deployment configuration");return dt(e,c,i,a)}return lt(e,c)},"getToken");async function L(n,t,e=process.env,r){let o=await F(n,e),i=e.COGNITE_BASE_URL??n.baseUrl,a=(r??(c=>new ut(c)))({appId:t,project:n.project,baseUrl:i,oidcTokenProvider:s(async()=>o,"oidcTokenProvider")});return await a.authenticate(),a}s(L,"getSdk");var ft=s(async(n,t,e)=>{let r=await new v(`${e}/dist`).createZip("app.zip",!0);try{let{externalId:o,name:i,description:a,versionTag:c}=t,p=await L(n,e),l=new P(p),g=Y.readFileSync(r),u=gt.basename(r);await l.deploy(o,i,a,c,g,u,n.published)}finally{try{Y.unlinkSync(r)}catch{}}},"deploy");import{existsSync as mt,readFileSync as yt}from"fs";var G=[".dev.sig",".cert.sig"];function ht(n,t={}){let e=t.existsSync??mt,r=t.readFileSync??((i,a)=>yt(i,a)),o=[];for(let i of G){let a=`${n}${i}`;if(!e(a))continue;let c=r(a,"utf8").trim();c.length>0&&o.push(c)}return o}s(ht,"discoverSignatures");export{P as a,v as b,F as c,L as d,ft as e,G as f,ht as g};
|
package/dist/chunk-EI7MMDWY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var c=Object.defineProperty;var d=(a,b)=>c(a,"name",{value:b,configurable:!0});export{d as a};
|
package/dist/chunk-EILVJ2ZW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-EI7MMDWY.js";import{GraphQLSchema as Zt,GraphQLObjectType as er,GraphQLNonNull as x,GraphQLList as Q,GraphQLString as b,GraphQLInt as tr,GraphQLInputObjectType as Ye,printSchema as rr}from"graphql";function ie(e){return{space:e.space,externalId:e.externalId,version:e.version}}a(ie,"toSharedViewId");function St(e){switch(e){case"text":return"String";case"boolean":return"Boolean";case"int32":case"int64":return"Int";case"float32":case"float64":return"Float";case"timestamp":return"DateTime";case"date":return"Date";case"json":return"JSON";case"timeseries":return"CogniteTimeSeriesReference";case"file":return"CogniteFileReference";case"sequence":return"CogniteSequenceReference";case"enum":return"String";default:return"String"}}a(St,"dmsTypeToGraphQL");function Ne(e){if(!("source"in e)){if(e.type?.type==="direct")return e.type.list?{kind:"scalar",isList:!1,graphqlType:"JSON"}:e.type.source?{kind:"directRelation",targetView:ie(e.type.source)}:{kind:"scalar",isList:!1,graphqlType:"JSON"};if(e.type?.type==="enum"){let t=e.type,n={};if(typeof t=="object"&&t!==null&&"values"in t){let i=t.values;if(typeof i=="object"&&i!==null)for(let[r,s]of Object.entries(i))n[r]={name:typeof s=="object"&&s!==null&&"name"in s?String(s.name):void 0}}return{kind:"enum",values:Object.keys(n),valueNames:Object.fromEntries(Object.entries(n).map(([i,r])=>[i,r.name??i]))}}return{kind:"scalar",isList:e.type!==void 0&&"list"in e.type&&e.type.list===!0,graphqlType:e.type?.type?St(e.type.type):"String"}}if("through"in e)return{kind:e.connectionType==="single_reverse_direct_relation"?"reverseDirect":"reverseList",sourceView:ie(e.source),throughProperty:e.through.identifier};if(e.connectionType==="single_edge_connection"||e.connectionType==="multi_edge_connection"){let t=e.direction==="inwards"?"inwards":"outwards";return{kind:"edge",targetView:ie(e.source),direction:t}}return{kind:"scalar"}}a(Ne,"parsePropertyDescriptor");var Ee=new Set(["String","Boolean","Int","Float","DateTime","Date"]);var xt=new Set(["String","Int","Float","DateTime","Date"]);function Qe(e){return e.kind==="directRelation"||e.kind==="enum"?!0:e.kind!=="scalar"||e.isList===!0?!1:Ee.has(e.graphqlType??"String")}a(Qe,"isFilterableDescriptor");function Ve(e){return e.kind==="enum"?!0:e.kind!=="scalar"||e.isList===!0?!1:Ee.has(e.graphqlType??"String")}a(Ve,"isSortableDescriptor");function Fe(e){return e.kind==="directRelation"||e.kind==="enum"?!0:e.kind==="scalar"&&e.isList!==!0&&xt.has(e.graphqlType??"")}a(Fe,"hasInOpDescriptor");function Ae(e){return e.kind==="scalar"&&e.isList===!0}a(Ae,"hasListOpsDescriptor");function O(e){return e.usedFor!=="edge"}a(O,"isNodeOrAll");function T(e){return Object.entries(e.properties).map(([t,n])=>[t,Ne(n),n.description])}a(T,"parsedProperties");import{GraphQLObjectType as Pe,GraphQLNonNull as F,GraphQLString as ae,GraphQLFloat as j,GraphQLList as vt,GraphQLEnumType as kt}from"graphql";import{GraphQLScalarType as L,Kind as h}from"graphql";function oe(e){switch(e.kind){case h.STRING:case h.BOOLEAN:return e.value;case h.INT:return parseInt(e.value,10);case h.FLOAT:return parseFloat(e.value);case h.OBJECT:{let t={};for(let n of e.fields)t[n.name.value]=oe(n.value);return t}case h.LIST:return e.values.map(oe);case h.NULL:return null;default:return null}}a(oe,"parseLiteralJSON");var Rt=new L({name:"DateTime",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:a(e=>e.kind===h.STRING?e.value:null,"parseLiteral")}),It=new L({name:"Date",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:a(e=>e.kind===h.STRING?e.value:null,"parseLiteral")}),se=new L({name:"JSON",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:oe}),Tt=new L({name:"CogniteTimeSeriesReference",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:a(e=>e.kind===h.STRING?e.value:null,"parseLiteral")}),Dt=new L({name:"CogniteFileReference",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:a(e=>e.kind===h.STRING?e.value:null,"parseLiteral")}),Lt=new L({name:"CogniteSequenceReference",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:a(e=>e.kind===h.STRING?e.value:null,"parseLiteral")}),$=new L({name:"ListLimit",description:"Limit for list/search queries (1\u20131000).",serialize:a(e=>e,"serialize"),parseValue:a(e=>e,"parseValue"),parseLiteral:a(e=>e.kind===h.INT?parseInt(e.value,10):null,"parseLiteral")}),v={DateTime:Rt,Date:It,JSON:se,CogniteTimeSeriesReference:Tt,CogniteFileReference:Dt,CogniteSequenceReference:Lt,ListLimit:$};var bt=new kt({name:"AggregateFunction",values:{count:{value:"count"},avg:{value:"avg"},sum:{value:"sum"},min:{value:"min"},max:{value:"max"},histogram:{value:"histogram"}}}),qe={function:{type:new F(bt)},property:{type:ae},interval:{type:j}},Ct=new Pe({name:"HistogramBucket",fields:{start:{type:new F(j)},count:{type:new F(j)}}}),_e=new Pe({name:"AggregateResult",fields:{aggregate:{type:new F(ae)},property:{type:ae},value:{type:j},buckets:{type:new vt(new F(Ct))},group:{type:se}}});import{GraphQLObjectType as pe,GraphQLNonNull as C,GraphQLList as Nt,GraphQLString as ce,GraphQLBoolean as Et}from"graphql";var Qt=new pe({name:"PageInfo",fields:{endCursor:{type:ce},hasNextPage:{type:new C(Et)}}}),B=new pe({name:"NodeReference",fields:{space:{type:new C(ce)},externalId:{type:new C(ce)}}});function K(e,t){return new pe({name:`${e}Connection`,fields:{items:{type:new C(new Nt(new C(t)))},pageInfo:{type:new C(Qt)}}})}a(K,"makeConnectionType");import{GraphQLInputObjectType as N,GraphQLList as S,GraphQLNonNull as je,GraphQLString as k,GraphQLBoolean as w,GraphQLFloat as Mt,GraphQLInt as Ot}from"graphql";import{GraphQLObjectType as Vt,GraphQLNonNull as Ge,GraphQLList as Ft,GraphQLString as U,GraphQLBoolean as At,GraphQLInt as Pt,GraphQLFloat as qt,GraphQLEnumType as _t}from"graphql";function Me(e){return e==="String"?U:e==="Boolean"?At:e==="Int"?Pt:e==="Float"?qt:v[e]??U}a(Me,"scalarForName");function Oe(e){return{typeRegistry:new Map,connectionRegistry:new Map,viewsByExtId:new Map(e.map(t=>[t.externalId,t])),enumRegistry:new Map,enumFilterRegistry:new Map}}a(Oe,"createTypeContext");function Gt(e){let t=e.replace(/[^_A-Za-z0-9]/g,"_");return/^[0-9]/.test(t)&&(t=`_${t}`),t||"_UNKNOWN"}a(Gt,"sanitizeEnumValue");function le(e,t,n,i){let r=n.enumRegistry.get(e);if(r)return r;let s=new _t({name:e,values:Object.fromEntries(t.map(o=>[Gt(o),{value:o,description:i?.[o]}]))});return n.enumRegistry.set(e,s),s}a(le,"getOrCreateEnumType");function $e(e,t){return new Vt({name:e.externalId,description:e.description??e.name,fields:a(()=>{let n={space:{type:new Ge(U)},externalId:{type:new Ge(U)}};for(let[i,r,s]of T(e))if(r.kind==="scalar")r.isList?n[i]={type:new Ft(Me(r.graphqlType??"String")),description:s}:n[i]={type:Me(r.graphqlType??"String"),description:s};else if(r.kind==="enum"){let o=`${e.externalId}${i.charAt(0).toUpperCase()}${i.slice(1)}`;n[i]={type:le(o,r.values,t,r.valueNames),description:s}}else if(r.kind==="directRelation"){let o=t.typeRegistry.get(r.targetView.externalId)??B;n[i]={type:o,description:s}}else if(r.kind==="reverseList"||r.kind==="edge"){let o=r.kind==="reverseList"?r.sourceView.externalId:r.targetView.externalId,u=t.typeRegistry.get(o)??B,d=t.connectionRegistry.get(o);d||(d=K(o,u),t.connectionRegistry.set(o,d)),n[i]={type:d,description:s}}else if(r.kind==="reverseDirect"){let o=t.typeRegistry.get(r.sourceView.externalId)??B;n[i]={type:o,description:s}}return n},"fields")})}a($e,"generateViewObjectType");function E(e,t,n){let i={isNull:{type:w},exists:{type:w},eq:{type:t}};return n.hasIn&&(i.in={type:new S(t)}),n.hasPrefix&&(i.prefix={type:k}),n.hasRange&&(i.gte={type:t},i.gt={type:t},i.lte={type:t},i.lt={type:t}),n.hasListOps&&(i.containsAny={type:new S(t)},i.containsAll={type:new S(t)},i.overlaps={type:new S(t)}),new N({name:e,fields:i})}a(E,"makeScalarFilter");var H=E("StringFilter",k,{hasIn:!0,hasPrefix:!0}),$t=E("BooleanFilter",w,{}),jt=E("IntFilter",Ot,{hasIn:!0,hasRange:!0}),Bt=E("FloatFilter",Mt,{hasIn:!0,hasRange:!0}),Kt=E("DateTimeFilter",v.DateTime,{hasIn:!0,hasRange:!0}),Ut=E("DateFilter",v.Date,{hasIn:!0,hasRange:!0}),Ht=new N({name:"StringListFilter",fields:{isNull:{type:w},exists:{type:w},containsAny:{type:new S(k)},containsAll:{type:new S(k)},overlaps:{type:new S(k)}}}),A=new N({name:"DirectRelationRef",fields:{space:{type:new je(k)},externalId:{type:new je(k)}}}),zt=new N({name:"DirectRelationFilter",fields:{isNull:{type:w},exists:{type:w},eq:{type:A},in:{type:new S(A)}}});function Xt(e){switch(e){case"String":return H;case"Boolean":return $t;case"Int":return jt;case"Float":return Bt;case"DateTime":return Kt;case"Date":return Ut;default:return H}}a(Xt,"scalarFilterForName");var Be=["space","externalId"];function Ke(e,t,n){let i=t.get(e.externalId),r={};for(let o of Be)r[o]={type:H};let s=new Set(Be);for(let[o,u]of T(e)){if(s.has(o))continue;let d=Qe(u),p=Ae(u);if(!(!d&&!p))if(u.kind==="directRelation"){let c={isNull:{type:w},exists:{type:w},eq:{type:A},in:{type:new S(A)}};Fe(u)&&(c.in={type:new S(A)});let l=t.get(u.targetView.externalId);l&&(c.nested={type:l}),r[o]=l?{type:new N({name:`_${e.externalId}_${o}_Filter`,fields:c})}:{type:zt}}else if(u.kind==="enum"){let c=`${e.externalId}${o.charAt(0).toUpperCase()}${o.slice(1)}`,l=le(c,u.values,n),m=n.enumFilterRegistry.get(c);m||(m=new N({name:`${c}Filter`,fields:{isNull:{type:w},exists:{type:w},eq:{type:l},in:{type:new S(l)}}}),n.enumFilterRegistry.set(c,m)),r[o]={type:m}}else if(p)r[o]={type:Ht};else{let c=u.kind==="scalar"?u.graphqlType??"String":"String",l=Xt(c);l&&(r[o]={type:l})}}return{...r,hasData:{type:w},matchAll:{type:w},_and:{type:new S(i)},_or:{type:new S(i)},_not:{type:i}}}a(Ke,"generateFilterFields");import{GraphQLEnumType as Ue,GraphQLInputObjectType as He,GraphQLList as Yt,GraphQLNonNull as z,GraphQLString as Jt,GraphQLBoolean as Wt}from"graphql";var X=new Ue({name:"SortDirection",values:{ASC:{value:"ascending"},DESC:{value:"descending"}}});function ze(e){let t=[];for(let[i,r]of T(e))Ve(r)&&t.push(i);if(t.length===0)return null;let n=new Ue({name:`${e.externalId}SortField`,values:Object.fromEntries(t.map(i=>[i,{value:i}]))});return new He({name:`${e.externalId}Sort`,fields:{field:{type:new z(n)},direction:{type:new z(X)},nullsFirst:{type:Wt}}})}a(ze,"generateSortInput");var Xe=new He({name:"SearchSort",fields:{property:{type:new z(new Yt(new z(Jt)))},direction:{type:X}}});function Je(e){let t=e.filter(O),n=Oe(t);for(let c of t){let l=$e(c,n);n.typeRegistry.set(c.externalId,l)}let i=new Map;for(let c of t){let l=new Ye({name:`${c.externalId}Filter`,fields:a(()=>Ke(c,i,n),"fields")});i.set(c.externalId,l)}let r={};for(let c of t){let l=c.externalId,m=n.typeRegistry.get(l),f=n.connectionRegistry.get(l);f||(f=K(l,m),n.connectionRegistry.set(l,f));let g=i.get(l),y=ze(c),D={limit:{type:$},cursor:{type:b},filter:{type:g}};y&&(D.sort={type:new Q(y)}),r[`query${l}`]={type:new x(f),args:D},r[`get${l}ById`]={type:m,args:{space:{type:new x(b)},externalId:{type:new x(b)}}},r[`count${l}`]={type:new x(tr),args:{filter:{type:g}}},r[`search${l}`]={type:new x(f),args:{query:{type:b},limit:{type:$},filter:{type:g},sort:{type:new Q(new x(Xe))},properties:{type:new Q(new x(b))}}},r[`aggregate${l}`]={type:new x(new Q(new x(_e))),args:{filter:{type:g},aggregates:{type:new Q(new x(new Ye({name:`${l}AggregateRequest`,fields:qe})))},groupBy:{type:new Q(new x(b))},query:{type:b}}}}let s=[];for(let[c,l]of n.typeRegistry)s.push({name:l.name,source:`typeRegistry[${c}]`});for(let[c,l]of n.connectionRegistry)s.push({name:l.name,source:`connectionRegistry[${c}]`});let o=new Map;for(let{name:c,source:l}of s)o.has(c)||o.set(c,[]),o.get(c).push(l);for(let[c,l]of o)l.length>1&&console.error(`[dune] duplicate type "${c}" from: ${l.join(", ")}`);let u=new Zt({query:new er({name:"Query",fields:r}),types:[X,...Object.values(v),...n.enumRegistry.values()]}),d=new Map;for(let c of t){let l=new Map;for(let[m,f]of T(c))l.set(m,f);d.set(c.externalId,{view:{space:c.space,externalId:c.externalId,version:c.version},properties:l})}let p={view(c){let l=d.get(c.externalId);if(!l)throw new Error(`SchemaKnowledge: no view for externalId "${c.externalId}"`);return l},property(c,l){return d.get(c.externalId)?.properties.get(l)}};return{schema:u,sdl:rr(u),schemaKnowledge:p}}a(Je,"buildSchema");async function We(e,t){let i=(await t.dataModels.retrieve([{space:e.space,externalId:e.dataModelExternalId,version:e.dataModelVersion}],{inlineViews:!1})).items[0];if(!i)throw new Error(`Data model ${e.space}/${e.dataModelExternalId}/${e.dataModelVersion} not found`);if(!i.views?.length)throw new Error(`Data model ${e.space}/${e.dataModelExternalId}/${e.dataModelVersion} has no views`);let r=i.views.map(o=>({space:o.space,externalId:o.externalId,version:o.version}));return(await t.views.retrieve(r,{includeInheritedProperties:!0})).items}a(We,"fetchViews");import{execute as nr,parse as Dn}from"graphql";function Ze(e,t){return async(n,i)=>{let r=await nr({schema:e,document:n,variableValues:i,rootValue:t,fieldResolver:a((s,o,u,d)=>{let p=s[d.fieldName];return typeof p=="function"?p(s,o,u,d):p},"fieldResolver")});if(r.errors?.length)throw r.errors[0];return r.data}}a(Ze,"createDuneRequester");import{CogniteError as gr}from"@cognite/sdk";function et(){return{initialBatchLimit:1e3,maxBatchLimit:5e3,searchLimit:1e3,inFilterChunkSize:100,previewLimit:3,nestedDetailLimit:5,enableRemoveNotConnected:!1,max408Retries:3,max429Retries:5,retryBaseDelayMs:500,maxConcurrentRequests:4,maxNestingDepth:2,maxTotalItems:1e4}}a(et,"defaultPlannerConfig");var fe=class fe extends Error{constructor(t){super(t),this.name="PlannerValidationError"}};a(fe,"PlannerValidationError");var I=fe;function J(e){return e.connections.size===0?0:1+Math.max(...[...e.connections.values()].map(t=>J(t.select)))}a(J,"selectionDepth");function mr(e,t,n){for(let i of t.scalars)if(i!=="*"&&!n.property(e,i))throw new I(`Property "${i}" does not exist on view ${e.externalId}/${e.version}`);for(let[i]of t.connections)if(!n.property(e,i))throw new I(`Connection "${i}" does not exist on view ${e.externalId}/${e.version}`)}a(mr,"validateSelection");function V(e){return{hasData:[e]}}a(V,"hasDataFilter");function rt(e,t){let n=V(t);return e?{and:[e,n]}:n}a(rt,"scopedFilter");function nt(e,t,n,i,r){return{name:"0",kind:"root",view:e,filter:rt(t,e),sort:n&&n.length>0?n:void 0,select:i.length>0?i:["*"],limit:r,queryable:!0}}a(nt,"makeRootStep");function it(e,t,n,i,r,s){return{name:e,from:t.name,kind:"directRelation",view:i,through:{view:t.view,property:n},direction:"outwards",filter:V(i),select:r.length>0?r:["*"],limit:s,queryable:!0,fieldName:n}}a(it,"makeDirectRelationStep");function ot(e,t,n,i,r,s,o){return{name:e,from:t.name,kind:"reverseDirect",view:i,through:{view:i,property:r},direction:"inwards",filter:V(i),select:s.length>0?s:["*"],limit:o,queryable:!0,fieldName:n}}a(ot,"makeReverseDirectStep");function st(e,t,n,i,r,s,o){return{name:e,from:t.name,kind:"reverseList",view:i,through:{view:i,property:r},direction:"inwards",filter:V(i),select:s.length>0?s:["*"],limit:o,queryable:!1,fieldName:n}}a(st,"makeReverseListStep");function at(e,t,n,i,r,s,o,u){let d={name:e,from:n.name,kind:"edgeIntermediate",view:r,direction:s,filter:void 0,select:[],limit:u,limitEach:u,queryable:!0},p={name:t,from:e,kind:"edge",view:r,filter:V(r),select:o.length>0?o:["*"],limit:u,queryable:!0,fieldName:i,chainTo:s==="outwards"?"destination":"source"};return[d,p]}a(at,"makeEdgeSteps");function Y(e){return{type:"view",space:e.space,externalId:e.externalId,version:e.version}}a(Y,"toRef");function P(e,t,n,i,r,s){let o=0;for(let[u,d]of n.connections){let p=r.property(t,u);if(!p)continue;o++;let c=d.limit??i,l=d.select.scalars,m=d.select,f=`${e.name}_${o}`;if(p.kind==="directRelation"){let g=Y(p.targetView),y=it(f,e,u,g,l,c);s.push(y),P(y,g,m,i,r,s)}else if(p.kind==="reverseDirect"){let g=Y(p.sourceView),y=ot(f,e,u,g,p.throughProperty,l,c);s.push(y),P(y,g,m,i,r,s)}else if(p.kind==="reverseList"){let g=Y(p.sourceView),y=st(f,e,u,g,p.throughProperty,l,c);s.push(y),P(y,g,m,i,r,s)}else if(p.kind==="edge"){let g=Y(p.targetView),y=`${e.name}_${o}_e`,[D,M]=at(y,f,e,u,g,p.direction,l,c);s.push(D,M),P(M,g,m,i,r,s)}}}a(P,"addConnectionSteps");function W(e,t,n,i,r,s,o){s&&mr(e,t,s);let u=nt(e,n,i,t.scalars,r),d=[u];return s&&P(u,e,t,o??r,s,d),d}a(W,"buildSteps");function ge(e,t){let n=new Set,i=new Map(e.map(r=>[r.name,r]));for(let r of e){if(r.queryable)continue;let s=r.from;if(!s||s in t)continue;let o=i.get(s);o?.view&&(t[s]={sources:[{source:o.view,properties:["*"]}]},n.add(s))}return n}a(ge,"injectPhantomSelects");function fr(e){let t=e.property.view;return{property:[t.space,`${t.externalId}/${t.version}`,e.property.property],direction:e.direction,nullsFirst:e.nullsFirst??!1}}a(fr,"compileSortClause");function ye(e,t,n){let i={},r={};for(let p of e){if(!p.queryable)continue;if(p.kind==="edgeIntermediate"){let m={edges:{from:p.from,direction:p.direction,maxDistance:1},limit:Math.min(p.limit,n)};p.filter&&(m.edges.filter=p.filter),p.limitEach!=null&&(m.edges.limitEach=p.limitEach),i[p.name]=m,r[p.name]={sources:[]};continue}let c={filter:p.filter};p.from&&(c.from=p.from),p.chainTo?c.chainTo=p.chainTo:p.through?(c.through={view:p.through.view,identifier:p.through.property},c.direction=p.direction):p.direction&&(c.direction=p.direction);let l={limit:Math.min(p.limit,n),nodes:c};p.sort&&p.sort.length>0&&(l.sort=p.sort.map(fr)),i[p.name]=l,r[p.name]={sources:[{source:p.view,properties:p.select}]}}let s=ge(e,r),o={with:i,select:r},u={},d=!1;for(let p of e){if(!p.queryable||p.kind==="edgeIntermediate")continue;let c=t.get(p.name);c!=null&&(u[p.name]=c,d=!0)}return d&&(o.cursors=u),{query:o,tempSelectSteps:s}}a(ye,"compileQuery");function he(e,t){let n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n}a(he,"chunkArray");var we=class we{constructor(t,n){this.dms=t;this.config=n}async run(t,n,i){let{response:r,tempSelectSteps:s,batchLimit:o}=await this.queryWithRetry(t,n,i),u={},d=new Map;for(let[p,c]of Object.entries(r.items))u[p]=c,d.set(p,r.nextCursor[p]??null);return await this.fetchReverseLists(t,u),{batch:u,nextCursors:d,tempSelectSteps:s,batchLimit:o}}async queryWithRetry(t,n,i){let r=i,s=0;for(;;){let{query:o,tempSelectSteps:u}=ye(t,n,r);try{return{response:await this.dms.query({with:o.with,select:o.select,cursors:o.cursors}),tempSelectSteps:u,batchLimit:r}}catch(d){if(d instanceof gr&&d.status===408){if(s>=this.config.max408Retries)throw d;s++,r=Math.max(1,Math.floor(r/2))}else throw d}}}async fetchReverseLists(t,n){let i=t.filter(r=>!r.queryable&&r.from);for(let r of i){let s=n[r.from]??[];if(s.length===0){n[r.name]=[];continue}let o=s.map(l=>({space:l.space,externalId:l.externalId})),u=r.through,d=[u.view.space,`${u.view.externalId}/${u.view.version}`,u.property],p=he(o,this.config.inFilterChunkSize),c=[];for(let l of p){let m=r.limit-c.length;if(m<=0)break;let f=await this.dms.search({view:r.view,filter:{in:{property:d,values:l}},limit:m});c.push(...f.items)}n[r.name]=c}}async fetchQueryableConnections(t,n){let i=t.filter(r=>r.queryable&&r.from&&(r.kind==="directRelation"||r.kind==="reverseDirect"));for(let r of i){let s=n[r.from]??[];if(s.length===0){n[r.name]=[];continue}if(r.kind==="directRelation"){let o=r.through,u=`${o.view.externalId}/${o.view.version}`,d=[],p=new Set;for(let m of s){let f=m.properties?.[o.view.space]?.[u]?.[o.property];if(f&&typeof f=="object"&&"space"in f&&"externalId"in f){let g=f,y=`${g.space}:${g.externalId}`;p.has(y)||(p.add(y),d.push({space:g.space,externalId:g.externalId}))}}if(d.length===0){n[r.name]=[];continue}let c=he(d,this.config.inFilterChunkSize),l=[];for(let m of c){let f=await this.dms.retrieve({items:m.map(g=>({instanceType:"node",...g})),sources:[{source:r.view}]});l.push(...f.items)}n[r.name]=l}else{let o=s.map(l=>({space:l.space,externalId:l.externalId})),u=r.through,d=[u.view.space,`${u.view.externalId}/${u.view.version}`,u.property],p=he(o,this.config.inFilterChunkSize),c=[];for(let l of p){let m=r.limit-c.length;if(m<=0)break;let f=await this.dms.search({view:r.view,filter:{in:{property:d,values:l}},limit:m});c.push(...f.items)}n[r.name]=c}}}async fetchEdgeConnections(t,n){let i=t.filter(r=>r.kind==="edgeIntermediate"&&r.from);for(let r of i){let s=n[r.from]??[],o=t.find(f=>f.kind==="edge"&&f.from===r.name);if(!o)continue;if(s.length===0){n[r.name]=[],n[o.name]=[];continue}let u=`${r.from}__edge_root`,d=s.map(f=>f.externalId),p={nodes:{filter:{in:{property:["node","externalId"],values:d}}},limit:s.length},c={edges:{from:u,direction:r.direction,maxDistance:1},limit:r.limit};r.filter&&(c.edges.filter=r.filter),r.limitEach!=null&&(c.edges.limitEach=r.limitEach);let l={nodes:{from:r.name,chainTo:o.chainTo},limit:o.limit};o.filter&&(l.nodes.filter=o.filter);let m=await this.dms.query({with:{[u]:p,[r.name]:c,[o.name]:l},select:{[u]:{sources:[]},[r.name]:{sources:[]},[o.name]:{sources:[{source:o.view,properties:o.select}]}}});n[r.name]=m.items[r.name]??[],n[o.name]=m.items[o.name]??[]}}};a(we,"QueryExecutor");var q=we;var yr={endCursor:null,hasNextPage:!1};function ct(e){return{items:e,pageInfo:yr}}a(ct,"wrapConnection");function pt(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.space=="string"&&typeof t.externalId=="string"}a(pt,"isDmsRef");function lt(e,t){let n=`${t.externalId}/${t.version}`;return{...e.properties?.[t.space]?.[n]??{},space:e.space,externalId:e.externalId}}a(lt,"extractViewProperties");function Z(e,t,n,i){if(t.length===0)return;let r=[...n.values()].filter(o=>o.from===e.name&&o.fieldName),s=[...n.values()].filter(o=>o.kind==="edge"&&o.fieldName&&o.from!=null&&n.get(o.from)?.from===e.name);for(let o of[...r,...s]){let u=(i[o.name]??[]).map(d=>lt(d,o.view));if(o.kind==="directRelation"){let d=new Map;for(let p of u)d.set(`${p.space}:${p.externalId}`,p);for(let p of t){let c=p[o.fieldName];p[o.fieldName]=pt(c)?d.get(`${c.space}:${c.externalId}`)??null:null}Z(o,u,n,i)}else if(o.kind==="reverseDirect"||o.kind==="reverseList"){let d=o.through.property,p=new Map;for(let c of t)p.set(`${c.space}:${c.externalId}`,[]);for(let c of u){let l=c[d];pt(l)&&p.get(`${l.space}:${l.externalId}`)?.push(c)}for(let c of t){let l=p.get(`${c.space}:${c.externalId}`)??[];c[o.fieldName]=o.kind==="reverseList"?ct(l):l}Z(o,u,n,i)}else if(o.kind==="edge"){let d=i[o.from]??[],p=new Map;for(let l of d){if(l.instanceType!=="edge")continue;let{startNode:m,endNode:f}=l;if(!m||!f)continue;let g=o.chainTo==="destination"?m:f,y=o.chainTo==="destination"?f:m,D=`${g.space}:${g.externalId}`,M=`${y.space}:${y.externalId}`,Ce=p.get(D)??[];Ce.push(M),p.set(D,Ce)}let c=new Map;for(let l of u)c.set(`${l.space}:${l.externalId}`,l);for(let l of t){let m=`${l.space}:${l.externalId}`,g=(p.get(m)??[]).map(y=>c.get(y)).filter(y=>y!==void 0);l[o.fieldName]=ct(g)}Z(o,u,n,i)}}}a(Z,"nestChildrenForStep");function hr(e,t,n){let i=e.find(s=>!s.from);if(!i)return n;let r=new Map(e.map(s=>[s.name,s]));return Z(i,n,r,t),n}a(hr,"nestChildren");function ee(e,t){let n=e.find(r=>!r.from);if(!n)return[];let i=(t[n.name]??[]).map(r=>lt(r,n.view));return hr(e,t,i)}a(ee,"unpack");function Se(e,t){for(let n of e)delete t[n]}a(Se,"stripTempSelects");function xe(e){let t={};for(let[n,i]of e)i!=null&&(t[n]=i);return Object.keys(t).length===0?null:btoa(JSON.stringify(t))}a(xe,"encodeCursors");function Re(e){if(!e)return new Map;try{let t=JSON.parse(atob(e));return new Map(Object.entries(t))}catch{throw new I("Invalid pagination cursor \u2014 the value is malformed or has been modified by the client.")}}a(Re,"decodeCursors");import{CogniteError as wr}from"@cognite/sdk";function ut(){return{max429Retries:5,retryBaseDelayMs:500,maxConcurrentRequests:4}}a(ut,"defaultRetryConfig");function Sr(e){return new Promise(t=>setTimeout(t,e))}a(Sr,"sleep");var Te=class Te{constructor(t){this.queue=[];this.count=t}acquire(){return this.count>0?(this.count--,Promise.resolve()):new Promise(t=>this.queue.push(t))}release(){let t=this.queue.shift();t?t():this.count++}};a(Te,"Semaphore");var Ie=Te,De=class De{constructor(t,n=ut()){this.inner=t;this.config=n;this.semaphore=new Ie(n.maxConcurrentRequests)}query(t){return this.withRetry(()=>this.inner.query(t))}search(t){return this.withRetry(()=>this.inner.search(t))}aggregate(t){return this.withRetry(()=>this.inner.aggregate(t))}retrieve(t){return this.withRetry(()=>this.inner.retrieve(t))}sync(t){return this.withRetry(()=>this.inner.sync(t))}upsert(t){return this.inner.upsert(t)}delete(t){return this.inner.delete(t)}inspect(t){return this.inner.inspect(t)}async withRetry(t){let n=0;for(;;){await this.semaphore.acquire();try{return await t()}catch(i){if(i instanceof wr&&i.status===429){if(n>=this.config.max429Retries)throw i;n++,await Sr(this.config.retryBaseDelayMs*2**(n-1))}else throw i}finally{this.semaphore.release()}}}};a(De,"RetryingDmsClient");var _=De;var Le=class Le{get schemaKnowledge(){return this.schema}constructor(t,n,i){this.schema=n,this.config={...et(),...i},this.dms=new _(t,{max429Retries:this.config.max429Retries,retryBaseDelayMs:this.config.retryBaseDelayMs,maxConcurrentRequests:this.config.maxConcurrentRequests}),this.executor=new q(this.dms,{max408Retries:this.config.max408Retries,inFilterChunkSize:this.config.inFilterChunkSize})}async query(t){let n=J(t.select);if(n>this.config.maxNestingDepth)throw new I(`Query nesting depth ${n} exceeds maximum ${this.config.maxNestingDepth}. Reduce connection depth or raise maxNestingDepth in config.`);let i=t.limit??this.config.initialBatchLimit,r=W(t.view,t.select,t.filter,t.sort,i,this.schema,this.config.previewLimit),s=Re(t.cursor),o={steps:r,tempSelectSteps:new Set,cursors:new Map(s),batchLimit:Math.min(this.config.initialBatchLimit,this.config.maxBatchLimit)},{batch:u,nextCursors:d,tempSelectSteps:p}=await this.executor.run(r,o.cursors,o.batchLimit);Se(p,u);let c=ee(r,u),l=r[0],m=d.get(l.name)??null,f=xe(d),g=m!=null;return{items:c,pageInfo:{endCursor:f,hasNextPage:g}}}async queryAll(t,n){let i=n??this.config.maxTotalItems,r=[],s,o=!0;for(;o;){let u=await this.query({...t,cursor:s});if(r.push(...u.items),o=u.pageInfo.hasNextPage,s=u.pageInfo.endCursor??void 0,r.length>=i){if(n===void 0&&o)throw new I(`listAll reached the hard ceiling of ${i} items. Pass an explicit maxTotal to acknowledge this or raise maxTotalItems in config.`);break}}return r}async search(t){let n=t.limit??this.config.searchLimit,i=await this.dms.search({view:t.view,query:t.query,filter:t.filter,sort:t.sort,limit:n,properties:t.properties}),r=W(t.view,t.select,void 0,void 0,n,this.schema,this.config.previewLimit),s={0:i.items};return await this.executor.fetchReverseLists(r,s),await this.executor.fetchQueryableConnections(r,s),await this.executor.fetchEdgeConnections(r,s),{items:ee(r,s),pageInfo:{endCursor:null,hasNextPage:!1}}}async getByIds(t,n){if(t.length===0)return[];let i=await this.dms.retrieve({items:t.map(s=>({instanceType:"node",space:s.space,externalId:s.externalId})),sources:[{source:n}]}),r=`${n.externalId}/${n.version}`;return i.items.map(s=>({...s.properties?.[n.space]?.[r]??{},space:s.space,externalId:s.externalId}))}async count(t){let i=(await this.dms.aggregate({view:t.view,filter:t.filter,aggregates:[{count:{property:"externalId"}}]})).items[0]?.aggregates[0];return(i?.aggregate!=="histogram"?i?.value:void 0)??0}async aggregate(t){return{items:(await this.dms.aggregate({view:t.view,filter:t.filter,aggregates:t.aggregates,groupBy:t.groupBy,query:t.query})).items}}async*queryPages(t){let n,i=!0;for(;i;){let r=await this.query({...t,cursor:n});yield r,i=r.pageInfo.hasNextPage,n=r.pageInfo.endCursor??void 0}}};a(Le,"QueryRunner");var G=Le;function ve(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}a(ve,"isRecord");function te(e){return typeof e=="string"||typeof e=="number"}a(te,"isScalar");var xr={space:["node","space"],externalId:["node","externalId"]};function Rr(e,t){return xr[t]??[e.space,`${e.externalId}/${e.version}`,t]}a(Rr,"propRef");var Ir={exists:a((e,t)=>typeof t!="boolean"?void 0:t?{exists:{property:e}}:{not:{exists:{property:e}}},"exists"),eq:a((e,t)=>({equals:{property:e,value:t}}),"eq"),in:a((e,t)=>Array.isArray(t)?{in:{property:e,values:t}}:void 0,"in"),isNull:a((e,t)=>typeof t!="boolean"?void 0:t?{not:{exists:{property:e}}}:{exists:{property:e}},"isNull"),prefix:a((e,t)=>typeof t=="string"?{prefix:{property:e,value:t}}:void 0,"prefix"),gte:a((e,t)=>te(t)?{range:{property:e,gte:t}}:void 0,"gte"),gt:a((e,t)=>te(t)?{range:{property:e,gt:t}}:void 0,"gt"),lte:a((e,t)=>te(t)?{range:{property:e,lte:t}}:void 0,"lte"),lt:a((e,t)=>te(t)?{range:{property:e,lt:t}}:void 0,"lt"),containsAny:a((e,t)=>Array.isArray(t)?{containsAny:{property:e,values:t}}:void 0,"containsAny"),containsAll:a((e,t)=>Array.isArray(t)?{containsAll:{property:e,values:t}}:void 0,"containsAll"),overlaps:a((e,t)=>Array.isArray(t)?{containsAny:{property:e,values:t}}:void 0,"overlaps")};function Tr(e,t,n,i){let r=Rr(n,e),s=Object.entries(t).flatMap(([o,u])=>{if(u==null)return[];if(o==="nested"&&i&&ve(u)){let p=i.property(n,e);if(p?.kind==="directRelation"){let c={type:"view",...p.targetView},l=R(u,c,i);if(l)return[{nested:{scope:[n.space,`${n.externalId}/${n.version}`,e],filter:l}}]}return[]}let d=Ir[o]?.(r,u);return d?[d]:[]});if(s.length!==0)return s.length===1?s[0]:{and:s}}a(Tr,"translatePropertyFilter");function Dr(e){if(e.length!==0)return e.length===1?e[0]:{and:e}}a(Dr,"collapse");function R(e,t,n){if(!ve(e))return;let i=Object.entries(e).flatMap(([r,s])=>{if(s==null)return[];if(r==="_not"){let o=R(s,t,n);return o?[{not:o}]:[]}if(r==="hasData"&&typeof s=="boolean"&&s)return[{hasData:[{type:"view",space:t.space,externalId:t.externalId,version:t.version}]}];if(r==="matchAll"&&typeof s=="boolean"&&s)return[{matchAll:{}}];if((r==="_and"||r==="_or")&&Array.isArray(s)){let o=s.flatMap(u=>{let d=R(u,t,n);return d?[d]:[]});return o.length>0?[r==="_and"?{and:o}:{or:o}]:[]}if(ve(s)){let o=Tr(r,s,t,n);return o?[o]:[]}return[]});return Dr(i)}a(R,"buildFilter");function Lr(e){switch(e.function){case"avg":return{avg:{property:e.property}};case"sum":return{sum:{property:e.property}};case"min":return{min:{property:e.property}};case"max":return{max:{property:e.property}};case"histogram":return{histogram:{property:e.property,interval:e.interval}};default:return{count:{property:e.property??"externalId"}}}}a(Lr,"toAggregationDefinition");function dt(e,t){return a(async function(i,r){let{items:s}=await t.aggregate({view:e,filter:R(r.filter,e,t.schemaKnowledge),aggregates:(r.aggregates??[{function:"count"}]).map(Lr),groupBy:r.groupBy,query:r.query});return s.flatMap(o=>o.aggregates.map(u=>{if(u.aggregate==="histogram"){let{aggregate:l,property:m,buckets:f}=u;return{aggregate:l,property:m,value:null,buckets:f,group:o.group??null}}let{aggregate:d,property:p,value:c}=u;return{aggregate:d,property:p,value:c,buckets:null,group:o.group??null}}))},"aggregateResolver")}a(dt,"makeAggregateResolver");function mt(e,t){return a(async function(i,r){let s=R(r.filter,e,t.schemaKnowledge);return t.count({view:e,filter:s})},"countResolver")}a(mt,"makeCountResolver");import{Kind as ke,isObjectType as vr,getNamedType as kr}from"graphql";function re(e,t){let n=[];for(let i of e.selections)if(i.kind===ke.FIELD)n.push(i);else if(i.kind===ke.INLINE_FRAGMENT&&i.selectionSet)n.push(...re(i.selectionSet,t));else if(i.kind===ke.FRAGMENT_SPREAD){let r=t[i.name.value];r&&n.push(...re(r.selectionSet,t))}return n}a(re,"collectFields");var br=new Set(["space","externalId"]);function ft(e,t,n){let i=[],r=new Map;for(let s of re(e,n.fragments)){let o=s.name.value;if(o==="__typename"||br.has(o))continue;if(!s.selectionSet){i.push(o);continue}let u=n.schema.getType(t);if(vr(u)){let d=u.getFields()[o];if(d){let p=kr(d.type).name,c=ft(s.selectionSet,p,n);r.set(o,{select:c});continue}}i.push(o)}return{scalars:i,connections:r}}a(ft,"buildTree");function be(e,t,n){return e?ft(e,t,n):{scalars:[],connections:new Map}}a(be,"buildSelectionTree");function ne(e,t){let n=e.fieldNodes[0]?.selectionSet;if(!n)return{scalars:[],connections:new Map};let i=re(n,e.fragments).find(r=>r.name.value==="items");return be(i?.selectionSet,t,e)}a(ne,"buildSelectionTreeFromListInfo");function gt(e,t,n){return a(async function(r,s,o,u){let{space:d,externalId:p}=s,c=be(u.fieldNodes[0]?.selectionSet,t,u),l={and:[{equals:{property:["node","space"],value:d}},{equals:{property:["node","externalId"],value:p}}]},{items:m}=await n.query({view:e,select:c,filter:l,limit:1});return m[0]??null},"getByIdResolver")}a(gt,"makeGetByIdResolver");function yt(e,t,n){return a(async function(r,s,o,u){let d=ne(u,t),p=R(s.filter,e,n.schemaKnowledge),c=Cr(s.sort,e);return n.query({view:e,select:d,filter:p,sort:c,cursor:s.cursor,limit:s.limit})},"queryResolver")}a(yt,"makeQueryResolver");function Cr(e,t){if(!(!e||e.length===0))return e.map(n=>({property:{view:t,property:n.field},direction:n.direction??"ascending",nullsFirst:n.nullsFirst}))}a(Cr,"parseSortArg");function ht(e,t,n){return a(async function(r,s,o,u){let d=ne(u,t),p={view:e,query:s.query,limit:s.limit,filter:R(s.filter,e,n.schemaKnowledge),sort:s.sort,select:d,properties:s.properties},{items:c,pageInfo:l}=await n.search(p);return{items:c,pageInfo:l}},"searchResolver")}a(ht,"makeSearchResolver");function Nr(e,t){let n={};for(let i of e.filter(O)){let r={type:"view",space:i.space,externalId:i.externalId,version:i.version},s=i.externalId;n[`query${s}`]=yt(r,s,t),n[`get${s}ById`]=gt(r,s,t),n[`count${s}`]=mt(r,t),n[`search${s}`]=ht(r,s,t),n[`aggregate${s}`]=dt(r,t)}return n}a(Nr,"buildRootValue");async function Er(e,t){let n=await We(e,t);return wt(n,t)}a(Er,"createDuneRuntime");function wt(e,t){let{schema:n,schemaKnowledge:i}=Je(e),r=new G(t.instances,i),s=Nr(e,r),o=Ze(n,s);return{schema:n,rootValue:s,runner:r,requester:o}}a(wt,"createDuneRuntimeFromViews");export{Er as a,wt as b};
|
package/dist/chunk-VTE66IK5.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var c=Object.defineProperty;var s=(l,i)=>c(l,"name",{value:i,configurable:!0});import{execFileSync as a}from"child_process";import{createRequire as p}from"module";import{InvalidArgumentError as u}from"commander";var t="https://github.com/cognitedata/builder-skills/tree/data-modeling-runtime-sdk-alpha",e=["claude-code","cursor"],o=e.flatMap(l=>["-a",l]),d=p(import.meta.url).resolve("skills/bin/cli.mjs");function n(l,i={}){a(process.execPath,[d,...l],{stdio:"inherit",cwd:process.cwd(),...i})}s(n,"execSkillsCli");function y(){return["add",t,...o,"--skill","*","-y"]}s(y,"pullAllArgs");function m(l){let i=/^[\w.-]+\/[\w.-]+$/.test(l),r=/^https:\/\/github\.com\/[\w.-]+\/[\w.-]+(\/tree\/[^\s]+)?$/.test(l);if(!i&&!r)throw new u("Expected owner/repo or GitHub URL with optional branch (e.g., cognitedata/builder-skills or https://github.com/cognitedata/builder-skills/tree/alpha)");return l}s(m,"validateSource");function g(l){let i=["add",l.source,...o];return l.skill?i.push("--skill",l.skill):l.interactive||i.push("--skill","*","-y"),l.global&&i.push("--global"),i}s(g,"buildPullArgs");function k(l){console.log(`\u{1F504} Pulling skills from ${l.source}...`),n(g(l)),console.log(`
|
|
2
|
-
\u2705 Skills pulled successfully`)}s(k,"handlePull");function S(l){let i=l.command("skills").summary("Manage AI agent skills for your app").description(`Manage AI agent skills for your app.
|
|
3
|
-
Supports: ${e.join(", ")}`).addHelpText("after",`
|
|
4
|
-
Examples:
|
|
5
|
-
npx @cognite/cli apps skills pull Pull all skills
|
|
6
|
-
npx @cognite/cli apps skills pull --skill create-client-tool Pull a specific skill
|
|
7
|
-
npx @cognite/cli apps skills pull --source https://github.com/cognitedata/builder-skills/tree/alpha Pull from a specific branch
|
|
8
|
-
npx @cognite/cli apps skills list List installed skills`);return i.command("pull").description("Pull all skills into your project").option("--source <owner/repo|url>","Skills repository \u2014 owner/repo shorthand or full GitHub URL (supports /tree/<branch>)",m,t).option("--skill <name>","Pull a specific skill by name").option("-i, --interactive","Interactively select which skills to install",!1).option("--global","Install skills globally",!1).action(k),i.command("list").description("List installed skills").action(()=>{n(["list"])}),i}s(S,"registerSkillsCommand");export{s as a,n as b,y as c,g as d,S as e};
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { ViewReference, FilterDefinition, SearchSort, AggregationDefinition, AggregatedResultItem, InstancesAPI, CogniteClient, ViewDefinition } from '@cognite/sdk';
|
|
2
|
-
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
3
|
-
|
|
4
|
-
interface GenerateSdkConfig {
|
|
5
|
-
name: string;
|
|
6
|
-
space: string;
|
|
7
|
-
dataModelExternalId: string;
|
|
8
|
-
dataModelVersion: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface SharedViewId {
|
|
12
|
-
space: string;
|
|
13
|
-
externalId: string;
|
|
14
|
-
version: string;
|
|
15
|
-
}
|
|
16
|
-
type PropertyDescriptor = {
|
|
17
|
-
kind: 'scalar';
|
|
18
|
-
isList?: boolean;
|
|
19
|
-
graphqlType?: string;
|
|
20
|
-
} | {
|
|
21
|
-
kind: 'enum';
|
|
22
|
-
values: string[];
|
|
23
|
-
valueNames: Record<string, string>;
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'directRelation';
|
|
26
|
-
targetView: SharedViewId;
|
|
27
|
-
} | {
|
|
28
|
-
kind: 'reverseDirect';
|
|
29
|
-
sourceView: SharedViewId;
|
|
30
|
-
throughProperty: string;
|
|
31
|
-
} | {
|
|
32
|
-
kind: 'reverseList';
|
|
33
|
-
sourceView: SharedViewId;
|
|
34
|
-
throughProperty: string;
|
|
35
|
-
} | {
|
|
36
|
-
kind: 'edge';
|
|
37
|
-
targetView: SharedViewId;
|
|
38
|
-
direction: 'outwards' | 'inwards';
|
|
39
|
-
};
|
|
40
|
-
interface SchemaView {
|
|
41
|
-
view: SharedViewId;
|
|
42
|
-
properties: Map<string, PropertyDescriptor>;
|
|
43
|
-
}
|
|
44
|
-
interface SchemaKnowledge {
|
|
45
|
-
view(ref: SharedViewId): SchemaView;
|
|
46
|
-
property(ref: SharedViewId, prop: string): PropertyDescriptor | undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Matches the Requester type emitted by @graphql-codegen/typescript-generic-sdk,
|
|
51
|
-
* so the return of createDuneRequester can be passed directly to getSdk().
|
|
52
|
-
*/
|
|
53
|
-
type DuneRequester = <TData, TVariables>(doc: DocumentNode, variables?: TVariables) => Promise<TData>;
|
|
54
|
-
|
|
55
|
-
interface PropertyRef {
|
|
56
|
-
view: ViewReference;
|
|
57
|
-
property: string;
|
|
58
|
-
}
|
|
59
|
-
interface ConnectionSelection {
|
|
60
|
-
limit?: number;
|
|
61
|
-
select: SelectionTree;
|
|
62
|
-
}
|
|
63
|
-
interface SelectionTree {
|
|
64
|
-
scalars: string[];
|
|
65
|
-
connections: Map<string, ConnectionSelection>;
|
|
66
|
-
}
|
|
67
|
-
interface SortClause {
|
|
68
|
-
property: PropertyRef;
|
|
69
|
-
direction: 'ascending' | 'descending';
|
|
70
|
-
/** When true, nulls sort before non-nulls. Defaults to false. */
|
|
71
|
-
nullsFirst?: boolean;
|
|
72
|
-
}
|
|
73
|
-
/** Pre-translated DMS logical filter (output of translateFilter in resolver layer). */
|
|
74
|
-
type LogicalFilter = FilterDefinition;
|
|
75
|
-
interface QueryInput {
|
|
76
|
-
view: ViewReference;
|
|
77
|
-
filter?: LogicalFilter;
|
|
78
|
-
sort?: SortClause[];
|
|
79
|
-
select: SelectionTree;
|
|
80
|
-
/** Page size. Defaults to INITIAL_BATCH_LIMIT if omitted. */
|
|
81
|
-
limit?: number;
|
|
82
|
-
/** Opaque cursor from a previous ListResult.pageInfo.endCursor. */
|
|
83
|
-
cursor?: string;
|
|
84
|
-
}
|
|
85
|
-
interface ListResult<T = Record<string, unknown>> {
|
|
86
|
-
items: T[];
|
|
87
|
-
pageInfo: {
|
|
88
|
-
endCursor: string | null;
|
|
89
|
-
hasNextPage: boolean;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface SearchInput {
|
|
94
|
-
view: ViewReference;
|
|
95
|
-
/** Full-text search term. */
|
|
96
|
-
query?: string;
|
|
97
|
-
filter?: LogicalFilter;
|
|
98
|
-
sort?: SearchSort[];
|
|
99
|
-
select: SelectionTree;
|
|
100
|
-
/** Max items to return. Defaults to searchLimit config. */
|
|
101
|
-
limit?: number;
|
|
102
|
-
/** Restrict search to specific property names within the view. */
|
|
103
|
-
properties?: string[];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
interface AggregateInput {
|
|
107
|
-
view: ViewReference;
|
|
108
|
-
filter?: LogicalFilter;
|
|
109
|
-
aggregates: AggregationDefinition[];
|
|
110
|
-
groupBy?: string[];
|
|
111
|
-
/** Optional full-text query to scope which instances are aggregated. */
|
|
112
|
-
query?: string;
|
|
113
|
-
}
|
|
114
|
-
interface AggregateOutput {
|
|
115
|
-
items: AggregatedResultItem[];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
type DmsClient = Pick<InstancesAPI, 'query' | 'search' | 'aggregate' | 'retrieve' | 'upsert' | 'delete' | 'sync' | 'inspect'>;
|
|
119
|
-
interface PlannerConfig {
|
|
120
|
-
initialBatchLimit: number;
|
|
121
|
-
maxBatchLimit: number;
|
|
122
|
-
searchLimit: number;
|
|
123
|
-
inFilterChunkSize: number;
|
|
124
|
-
previewLimit: number;
|
|
125
|
-
nestedDetailLimit: number;
|
|
126
|
-
enableRemoveNotConnected: boolean;
|
|
127
|
-
max408Retries: number;
|
|
128
|
-
max429Retries: number;
|
|
129
|
-
retryBaseDelayMs: number;
|
|
130
|
-
maxConcurrentRequests: number;
|
|
131
|
-
/** Maximum SelectionTree nesting depth. Throws PlannerValidationError if exceeded. */
|
|
132
|
-
maxNestingDepth: number;
|
|
133
|
-
/** Hard ceiling for listAll without an explicit maxTotal. Throws rather than silently truncating. */
|
|
134
|
-
maxTotalItems: number;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare class QueryRunner {
|
|
138
|
-
private readonly dms;
|
|
139
|
-
private readonly schema;
|
|
140
|
-
private readonly config;
|
|
141
|
-
private readonly executor;
|
|
142
|
-
get schemaKnowledge(): SchemaKnowledge | undefined;
|
|
143
|
-
constructor(dms: DmsClient, schema?: SchemaKnowledge, config?: Partial<PlannerConfig>);
|
|
144
|
-
query<T = Record<string, unknown>>(input: QueryInput): Promise<ListResult<T>>;
|
|
145
|
-
/**
|
|
146
|
-
* Collects all pages until exhaustion. `input.limit` is the page size.
|
|
147
|
-
* `maxTotal` sets an explicit ceiling — without it, throws at `config.maxTotalItems`
|
|
148
|
-
* to prevent unbounded fetches.
|
|
149
|
-
*/
|
|
150
|
-
queryAll<T = Record<string, unknown>>(input: Omit<QueryInput, 'cursor'>, maxTotal?: number): Promise<T[]>;
|
|
151
|
-
/**
|
|
152
|
-
* Full-text or filter-based search returning a single (non-paginated) result set.
|
|
153
|
-
* Use for top-level discovery; DMS search has eventual consistency — do not use
|
|
154
|
-
* for writes-then-reads or where strong consistency is required.
|
|
155
|
-
*/
|
|
156
|
-
search<T = Record<string, unknown>>(input: SearchInput): Promise<ListResult<T>>;
|
|
157
|
-
/**
|
|
158
|
-
* Fetches specific nodes by space+externalId. Returns an empty array when ids is empty.
|
|
159
|
-
* Extracts view-scoped properties before returning, matching the shape of list results.
|
|
160
|
-
*/
|
|
161
|
-
getByIds<T = Record<string, unknown>>(ids: Array<{
|
|
162
|
-
space: string;
|
|
163
|
-
externalId: string;
|
|
164
|
-
}>, view: ViewReference): Promise<T[]>;
|
|
165
|
-
/**
|
|
166
|
-
* Returns the total count of instances matching the filter.
|
|
167
|
-
* Wraps the filter with hasData so only instances with data in the view are counted.
|
|
168
|
-
*/
|
|
169
|
-
count(input: {
|
|
170
|
-
view: ViewReference;
|
|
171
|
-
filter?: LogicalFilter;
|
|
172
|
-
}): Promise<number>;
|
|
173
|
-
aggregate(input: AggregateInput): Promise<AggregateOutput>;
|
|
174
|
-
/**
|
|
175
|
-
* Async generator — yields one ListResult<T> per page.
|
|
176
|
-
* Lets callers stream results or stop early without fetching remaining pages.
|
|
177
|
-
*/
|
|
178
|
-
queryPages<T = Record<string, unknown>>(input: Omit<QueryInput, 'cursor'>): AsyncGenerator<ListResult<T>>;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
interface DuneRuntime {
|
|
182
|
-
schema: GraphQLSchema;
|
|
183
|
-
rootValue: Record<string, unknown>;
|
|
184
|
-
runner: QueryRunner;
|
|
185
|
-
/** Pass directly to the generated getSdk() function. */
|
|
186
|
-
requester: DuneRequester;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Builds the full runtime from a data model config. Fetches views from CDF,
|
|
190
|
-
* builds the GraphQL schema, wires resolvers, and returns a ready requester.
|
|
191
|
-
*/
|
|
192
|
-
declare function createDuneRuntime(config: GenerateSdkConfig, client: CogniteClient): Promise<DuneRuntime>;
|
|
193
|
-
/**
|
|
194
|
-
* Builds the runtime directly from an array of ViewDefinition objects — skips the
|
|
195
|
-
* data model lookup. Useful when you already have views from sdk.views.list().
|
|
196
|
-
*/
|
|
197
|
-
declare function createDuneRuntimeFromViews(views: ViewDefinition[], client: CogniteClient): DuneRuntime;
|
|
198
|
-
|
|
199
|
-
export { type DuneRuntime, createDuneRuntime, createDuneRuntimeFromViews };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"../chunk-EILVJ2ZW.js";import"../chunk-EI7MMDWY.js";export{a as createDuneRuntime,b as createDuneRuntimeFromViews};
|