@cognite/cli 1.0.0 → 1.1.0-alpha.49
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/README.md +1 -1
- package/_templates/app/new/claude/mcp.json.ejs.t +11 -0
- package/_templates/app/new/cursor/mcp.json.ejs.t +10 -0
- package/_templates/app/new/prompt.js +3 -3
- package/_templates/app/new/root/AGENTS.md.ejs.t +12 -6
- package/_templates/app/new/root/package.json.ejs.t +5 -2
- package/_templates/app/new/vscode/mcp.json.ejs.t +11 -0
- package/_vendor/spec-kit/README.md +8 -8
- package/dist/chunk-EILVJ2ZW.js +1 -0
- package/dist/chunk-HE6P4LDC.js +9 -0
- package/dist/cli/cli.js +155 -37
- package/dist/deploy/index.d.ts +5 -7
- package/dist/deploy/index.js +1 -9
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/sdk-runtime/index.d.ts +199 -0
- package/dist/sdk-runtime/index.js +1 -0
- package/package.json +13 -14
- package/dist/auth/index.d.ts +0 -51
- package/dist/auth/index.js +0 -1
- package/dist/chunk-QGJ3VKXY.js +0 -1
- package/dist/vite/index.d.ts +0 -1
- package/dist/vite/index.js +0 -1
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CogniteClient } from '@cognite/sdk';
|
|
1
|
+
import { CogniteClient, ClientOptions } from '@cognite/sdk';
|
|
2
2
|
|
|
3
3
|
type Deployment = {
|
|
4
4
|
org: string;
|
|
@@ -87,19 +87,17 @@ declare class AppHostingClient {
|
|
|
87
87
|
*
|
|
88
88
|
* Handles packaging of build directories into deployment-ready zip files.
|
|
89
89
|
*/
|
|
90
|
-
interface ApplicationPackagerOptions {
|
|
91
|
-
requireLockFile?: boolean;
|
|
92
|
-
}
|
|
93
90
|
declare class ApplicationPackager {
|
|
94
91
|
private distPath;
|
|
95
92
|
private appRoot;
|
|
96
|
-
|
|
97
|
-
constructor(distDirectory?: string, options?: ApplicationPackagerOptions);
|
|
93
|
+
constructor(distDirectory?: string);
|
|
98
94
|
validateBuildDirectory(): void;
|
|
99
95
|
createZip(outputFilename?: string, verbose?: boolean): Promise<string>;
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
|
|
98
|
+
type Authenticatable = Pick<CogniteClient, 'authenticate'>;
|
|
99
|
+
declare function getSdk(deployment: Deployment, folder: string, env?: NodeJS.ProcessEnv): Promise<CogniteClient>;
|
|
100
|
+
declare function getSdk<C extends Authenticatable>(deployment: Deployment, folder: string, env: NodeJS.ProcessEnv, createClient: (opts: ClientOptions) => C): Promise<C>;
|
|
103
101
|
|
|
104
102
|
/**
|
|
105
103
|
* Get access token for deployment using the appropriate identity provider.
|
package/dist/deploy/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import{a
|
|
2
|
-
See: ${j}`;case 403:return`You don't have the required CDF capabilities. Please contact your CDF admin.
|
|
3
|
-
See: ${j}`;default:return}}s(K,"httpStatusHint");function w(e){let t=e instanceof Error?e:new Error(String(e));if(!S(t))return null;let n=K(t.status);return n?Object.assign(new Error(`${t.message}
|
|
4
|
-
${n}`),{cause:t}):null}s(w,"enrichedHttpError");function W(e){if(!f(e))return null;let t=e.missing;if(Array.isArray(t))return t;let n=e.data;if(f(n)){let r=n.error;if(f(r)&&Array.isArray(r.missing))return r.missing;if(Array.isArray(n.missing))return n.missing}return null}s(W,"findMissingArray");function Z(e,t){if(!S(e)||e.status!==400)return!1;let n=W(e);return n?n.some(r=>f(r)&&typeof r.externalId=="string"&&t.includes(r.externalId)):!1}s(Z,"isMissingExternalIdError");function x(e,t){return S(e)&&e.status===404||Z(e,t)}s(x,"isNotFoundError");var H=["DRAFT","PUBLISHED","DEPRECATED","ARCHIVED"],q=["ACTIVE","PREVIEW"],I=class I extends Error{constructor(t,n){super(`Version ${n} of app ${t} not found`),this.name="AppVersionNotFoundError",this.appExternalId=t,this.version=n}};s(I,"AppVersionNotFoundError");var C=I;function M(e,t){return e.includes(t)}s(M,"includesValue");function X(e){return M(H,e)}s(X,"isAppVersionLifecycleState");function Q(e){return M(q,e)}s(Q,"isAppVersionAlias");function tt(e){return typeof e.version=="string"&&X(e.lifecycleState)&&typeof e.entrypoint=="string"&&typeof e.createdTime=="number"&&typeof e.createdBy=="string"&&typeof e.appExternalId=="string"&&(e.alias===void 0||Q(e.alias))&&(e.comment===void 0||typeof e.comment=="string")}s(tt,"isAppVersion");function N(e){if(!f(e))throw new Error("Invalid version response: not an object");if(!tt(e))throw new Error("Invalid version response: missing or malformed fields");return e}s(N,"parseAppVersion");var T=class T{constructor(t){this.client=t}get appsBasePath(){return`/api/v1/projects/${encodeURIComponent(this.client.project)}/apphosting/apps`}async createApp(t,n,r){try{await this.client.post(this.appsBasePath,{data:{items:[{externalId:t,name:n,description:r}]}})}catch(o){throw w(o)??o}}async uploadVersion(t,n,r,o,i="index.html"){console.log(`\u{1F4E4} Uploading version ${n}...`);let c=new FormData;c.append("file",new Blob([new Uint8Array(r)]),o),c.append("version",n),c.append("entryPath",i);let p=encodeURIComponent(t),a=`${this.appsBasePath}/${p}/versions`,l=await this.client.authenticate(),h=`${this.client.getBaseUrl()}${a}`,d=new AbortController,Y=setTimeout(()=>d.abort(),300*1e3),y;try{y=await fetch(h,{method:"POST",headers:{Authorization:`Bearer ${l}`},body:c,signal:d.signal})}catch(g){throw g instanceof Error&&g.name==="AbortError"?new Error("Upload timed out after 5 minutes"):g}finally{clearTimeout(Y)}if(!y.ok){let g=await y.text(),V=g;try{let $=JSON.parse(g);if(f($)){let A=$.error;if(typeof A=="string")V=A;else if(f(A)){let E=A.message,B=A.code;V=typeof E=="string"?E:B!=null?`Unknown error (code: ${B})`:g}else{let E=$.message;V=typeof E=="string"?E:g}}}catch{}let O=y.headers.get("x-request-id"),G=O?` | X-Request-ID: ${O}`:"",U=Object.assign(new Error(`Upload failed: ${y.status} \u2014 ${V}${G}`),{status:y.status});throw w(U)??U}console.log(`\u2705 Version ${n} uploaded`)}async getVersion(t,n){let r=encodeURIComponent(t),o=encodeURIComponent(n),i=`${this.appsBasePath}/${r}/versions/${o}`;try{let c=await this.client.get(i);return N(c.data)}catch(c){throw x(c,[t,n])?new C(t,n):w(c)??c}}async getActiveVersion(t){let n=encodeURIComponent(t),r=`${this.appsBasePath}/${n}/active`;try{let o=await this.client.get(r);return N(o.data)}catch(o){if(x(o,[t]))return null;throw w(o)??o}}async updateVersions(t,n){let r=encodeURIComponent(t),o=`${this.appsBasePath}/${r}/versions/update`;try{await this.client.post(o,{data:{items:n}})}catch(i){throw w(i)??i}}};s(T,"AppHostingApi");var v=T;var b=class b{constructor(t){this.api=new v(t)}getVersion(t,n){return this.api.getVersion(t,n)}uploadVersion(t,n,r,o,i){return this.api.uploadVersion(t,n,r,o,i)}async ensureApp(t,n,r){console.log("\u{1F50D} Ensuring app exists...");try{await this.api.createApp(t,n,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 publishVersion(t,n){await this.api.updateVersions(t,[{version:n,update:{lifecycleState:{set:"PUBLISHED"}}}])}async publishAndActivate(t,n){console.log(`\u{1F680} Publishing and activating version ${n}...`),await this.api.updateVersions(t,[{version:n,update:{lifecycleState:{set:"PUBLISHED"},alias:{set:"ACTIVE"}}}]),console.log(`\u2705 Version ${n} is now PUBLISHED and ACTIVE`)}async activateVersion(t,n){let r=null;try{r=await this.api.getActiveVersion(t)}catch{r=null}let o=r&&r.version!==n?r.version:void 0;return await this.api.updateVersions(t,[{version:n,update:{alias:{set:"ACTIVE"}}}]),{supersededVersion:o}}async deploy(t,n,r,o,i,c,p=!1){console.log(`
|
|
5
|
-
\u{1F680} Deploying application via App Hosting API...
|
|
6
|
-
`);try{await this.ensureApp(t,n,r),await this.uploadVersion(t,o,i,c),p&&await this.publishAndActivate(t,o),console.log(`
|
|
7
|
-
\u2705 Deployment successful!`)}catch(a){let l=a instanceof Error?a.message:String(a);throw Object.assign(new Error(`Deployment failed: ${l}`),{cause:a})}}};s(b,"AppHostingClient");var P=b;import m from"fs";import u from"path";import{parseAndValidateManifestConfig as et}from"@cognite/app-sdk/vite";import{BlobReader as nt,Uint8ArrayWriter as rt,ZipWriter as ot}from"@zip.js/zip.js";var R="package.json",L="package-lock.json",z="manifest.json",D=class D{constructor(t="dist",n={}){this.distPath=u.isAbsolute(t)?t:u.join(process.cwd(),t),this.appRoot=u.dirname(this.distPath),this.requireLockFile=n.requireLockFile??!1}validateBuildDirectory(){if(!m.existsSync(this.distPath))throw new Error(`Build directory "${this.distPath}" not found. Run build first.`);let t=u.join(this.appRoot,R);if(!m.existsSync(t))throw new Error(`"${t}" not found. It is required for deployment.`);if(this.requireLockFile){let n=u.join(this.appRoot,L);if(!m.existsSync(n))throw new Error(`"${n}" not found. It is required for deployment.`)}}async createZip(t="app.zip",n=!1){this.validateBuildDirectory(),console.log("\u{1F4E6} Packaging application...");let r=new ot(new rt,{level:9}),o=s(async(a,l)=>{await r.add(l,new nt(await m.openAsBlob(a))),n&&console.log(` \u{1F4C4} ${l}`)},"addFile"),i=s(async a=>{let l=await m.promises.readdir(a,{withFileTypes:!0});for(let h of l){let d=u.join(a,h.name);h.isDirectory()?await i(d):await o(d,u.relative(this.distPath,d).replace(/\\/g,"/"))}},"addDir"),c;try{await i(this.distPath),await o(u.join(this.appRoot,R),R);let a=u.join(this.appRoot,z);if(m.existsSync(a)){let l=m.readFileSync(a,"utf-8");et(l,a),await o(a,z)}this.requireLockFile&&await o(u.join(this.appRoot,L),L),c=await r.close()}catch(a){let l=a instanceof Error?a.message:String(a);throw new Error(`Failed to create zip: ${l}`)}await m.promises.writeFile(t,c);let p=(c.byteLength/1024/1024).toFixed(2);return console.log(`\u2705 App packaged: ${t} (${p} MB)`),t}};s(D,"ApplicationPackager");var k=D;import{CogniteClient as lt}from"@cognite/sdk";var st=s(()=>{let e=process.env.DEPLOYMENT_SECRETS;if(!e)return{};try{let t=JSON.parse(e),n={};for(let[r,o]of Object.entries(t))if(typeof o=="string"){let i=r.toLowerCase().replace(/_/g,"-");n[i]=o}return n}catch(t){return console.error("Error parsing DEPLOYMENT_SECRETS:",t),{}}},"loadSecretsFromEnv"),it=s(e=>{let t;if(process.env.DEPLOYMENT_SECRET&&(t=process.env.DEPLOYMENT_SECRET),t||(t=st()[e]),t||(t=process.env[e]),!t)throw new Error(`Secret not found in environment: ${e}`);return t},"getSecretFromEnv"),at=s(e=>{if(!e)return"";try{return new URL(e).hostname.replace(/\.cognitedata\.com$/,"")}catch{let t=e.replace(/^https?:\/\//,"");return t=t.split("/")[0],t=t.split(":")[0],t=t.replace(/\.cognitedata\.com$/,""),t}},"extractClusterFromUrl"),ct=s(async(e,t)=>{let n=`Basic ${btoa(`${e}:${t}`)}`,r=await fetch("https://auth.cognite.com/oauth2/token",{method:"POST",headers:{Authorization:n,"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"),pt=s(async(e,t,n,r)=>{if(!r)throw new Error("Entra ID authentication requires 'baseUrl' to be set in deployment configuration");let o=at(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/${n}/oauth2/v2.0/token`,c=`https://${o}.cognitedata.com/.default`,p=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:e,client_secret:t,scope:c,grant_type:"client_credentials"})});if(!p.ok){let l=await p.text();throw new Error(`Failed to get token from Entra ID: ${p.status} ${p.statusText}
|
|
9
|
-
${l}`)}let a=await p.json();if(!a.access_token)throw new Error("No access token returned from Entra ID authentication");return a.access_token},"getTokenEntra"),_=s(async(e,t=process.env)=>{if(t.COGNITE_TOKEN)return t.COGNITE_TOKEN;let{deployClientId:n,deploySecretName:r,idpType:o="cdf",tenantId:i,baseUrl:c}=e,p=it(r);if(o==="entra_id"){if(!i)throw new Error("Entra ID authentication requires 'tenantId' in deployment configuration");return pt(n,p,i,c)}return ct(n,p)},"getToken");var F=s(async(e,t,n=process.env)=>{let r=await _(e,n),o=n.COGNITE_BASE_URL??e.baseUrl,i=new lt({appId:t,project:e.project,baseUrl:o,oidcTokenProvider:s(async()=>r,"oidcTokenProvider")});return await i.authenticate(),i},"getSdk");var dt=s(async(e,t,n)=>{let r=await new k(`${n}/dist`,{requireLockFile:!0}).createZip("app.zip",!0);try{let{externalId:o,name:i,description:c,versionTag:p}=t,a=await F(e,n),l=new P(a),h=J.readFileSync(r),d=ut.basename(r);await l.deploy(o,i,c,p,h,d,e.published)}finally{try{J.unlinkSync(r)}catch{}}},"deploy");export{P as AppHostingClient,k as ApplicationPackager,dt as deploy,F as getSdk,_ as getToken};
|
|
1
|
+
import{a,b,c,d,e}from"../chunk-HE6P4LDC.js";import"../chunk-EI7MMDWY.js";export{a as AppHostingClient,b as ApplicationPackager,e as deploy,d as getSdk,c as getToken};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
import 'react';
|
|
1
|
+
export { App, AppHostingClient, ApplicationPackager, Deployment, deploy, getSdk, getToken } from './deploy/index.js';
|
|
2
|
+
export { DuneRuntime, createDuneRuntime, createDuneRuntimeFromViews } from './sdk-runtime/index.js';
|
|
4
3
|
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
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m}from"./chunk-HE6P4LDC.js";import{a as p,b as t}from"./chunk-EILVJ2ZW.js";import"./chunk-EI7MMDWY.js";export{o as AppHostingClient,r as ApplicationPackager,p as createDuneRuntime,t as createDuneRuntimeFromViews,m as deploy,f as getSdk,e as getToken};
|
|
@@ -0,0 +1,199 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"../chunk-EILVJ2ZW.js";import"../chunk-EI7MMDWY.js";export{a as createDuneRuntime,b as createDuneRuntimeFromViews};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognite/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-alpha.49",
|
|
4
4
|
"description": "CLI for Cognite Data Fusion",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Cognite",
|
|
@@ -18,21 +18,15 @@
|
|
|
18
18
|
"import": "./dist/index.js",
|
|
19
19
|
"default": "./dist/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./auth": {
|
|
22
|
-
"types": "./dist/auth/index.d.ts",
|
|
23
|
-
"import": "./dist/auth/index.js",
|
|
24
|
-
"default": "./dist/auth/index.js"
|
|
25
|
-
},
|
|
26
21
|
"./deploy": {
|
|
27
22
|
"types": "./dist/deploy/index.d.ts",
|
|
28
23
|
"import": "./dist/deploy/index.js",
|
|
29
24
|
"default": "./dist/deploy/index.js"
|
|
30
25
|
},
|
|
31
|
-
"./
|
|
32
|
-
"types": "./dist/
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"default": "./dist/vite/index.js"
|
|
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"
|
|
36
30
|
}
|
|
37
31
|
},
|
|
38
32
|
"bin": {
|
|
@@ -57,6 +51,10 @@
|
|
|
57
51
|
"dependencies": {
|
|
58
52
|
"@cognite/app-sdk": "^0.4.0",
|
|
59
53
|
"@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",
|
|
60
58
|
"@sentry/node": "^10.51.0",
|
|
61
59
|
"@zip.js/zip.js": "^2.7.0",
|
|
62
60
|
"chalk": "^5.6.2",
|
|
@@ -64,6 +62,7 @@
|
|
|
64
62
|
"dotenv": "^17.4.2",
|
|
65
63
|
"enquirer": "^2.4.1",
|
|
66
64
|
"execa": "^5.1.1",
|
|
65
|
+
"graphql": "^16.13.2",
|
|
67
66
|
"hygen": "^6.2.11",
|
|
68
67
|
"jose": "^6.2.2",
|
|
69
68
|
"mixpanel": "^0.21.0",
|
|
@@ -86,21 +85,21 @@
|
|
|
86
85
|
}
|
|
87
86
|
},
|
|
88
87
|
"devDependencies": {
|
|
89
|
-
"@types/ejs": "^3.1.5",
|
|
90
|
-
"ejs": "^3.1.10",
|
|
91
88
|
"@mswjs/http-middleware": "^0.10.3",
|
|
89
|
+
"@types/ejs": "^3.1.5",
|
|
92
90
|
"@types/express": "^5.0.6",
|
|
93
91
|
"@types/node": "^24.10.1",
|
|
94
92
|
"@types/react": "^19.2.6",
|
|
95
93
|
"@types/react-dom": "^19.2.3",
|
|
96
94
|
"@types/semver": "^7.7.0",
|
|
95
|
+
"ejs": "^3.1.10",
|
|
97
96
|
"express": "^5.2.1",
|
|
98
97
|
"msw": "^2.13.6",
|
|
99
98
|
"react": "^19.2.6",
|
|
100
99
|
"react-dom": "^19.2.6",
|
|
101
100
|
"tsup": "^8.4.0",
|
|
102
101
|
"typescript": "^5.0.0",
|
|
103
|
-
"vitest": "^2.
|
|
102
|
+
"vitest": "^3.2.4"
|
|
104
103
|
},
|
|
105
104
|
"engines": {
|
|
106
105
|
"node": ">=20"
|
package/dist/auth/index.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as react from 'react';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
import { CogniteClient } from '@cognite/sdk';
|
|
5
|
-
|
|
6
|
-
interface AppSdkAuthProviderProps {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
loadingComponent?: ReactNode;
|
|
9
|
-
errorComponent?: (error: string) => ReactNode;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Auth provider for apps running in the new Fusion app host (dune-app-host).
|
|
13
|
-
* Uses @cognite/app-sdk's Comlink handshake to connect to the host and obtain
|
|
14
|
-
* tokens on-demand. Exposes the same DuneContextValue ({ sdk, isLoading,
|
|
15
|
-
* error }) as DuneAuthProvider so useDune() works unchanged.
|
|
16
|
-
*/
|
|
17
|
-
declare const AppSdkAuthProvider: ({ children, loadingComponent, errorComponent, }: AppSdkAuthProviderProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
-
|
|
19
|
-
interface DuneContextValue {
|
|
20
|
-
sdk: CogniteClient;
|
|
21
|
-
isLoading: boolean;
|
|
22
|
-
error?: string;
|
|
23
|
-
}
|
|
24
|
-
declare const DuneAuthProviderContext: react.Context<DuneContextValue>;
|
|
25
|
-
interface DuneAuthProviderProps {
|
|
26
|
-
children: ReactNode;
|
|
27
|
-
useIFrameAuthentication?: boolean;
|
|
28
|
-
useLocalConfiguration?: {
|
|
29
|
-
org: string;
|
|
30
|
-
project: string;
|
|
31
|
-
baseUrl: string;
|
|
32
|
-
};
|
|
33
|
-
loadingComponent?: ReactNode;
|
|
34
|
-
errorComponent?: (error: string) => ReactNode;
|
|
35
|
-
}
|
|
36
|
-
declare const DuneAuthProvider: ({ children, loadingComponent, errorComponent, }: DuneAuthProviderProps) => react_jsx_runtime.JSX.Element;
|
|
37
|
-
|
|
38
|
-
declare const useDune: () => DuneContextValue;
|
|
39
|
-
|
|
40
|
-
interface CDFConfig {
|
|
41
|
-
project: string;
|
|
42
|
-
baseUrl: string;
|
|
43
|
-
clientId: string;
|
|
44
|
-
clientSecret: string;
|
|
45
|
-
appId?: string;
|
|
46
|
-
}
|
|
47
|
-
declare const getToken: (clientId: string, clientSecret: string) => Promise<any>;
|
|
48
|
-
declare const createCDFSDK: (config: CDFConfig) => Promise<CogniteClient>;
|
|
49
|
-
declare const EMPTY_SDK: CogniteClient;
|
|
50
|
-
|
|
51
|
-
export { AppSdkAuthProvider, type CDFConfig, DuneAuthProvider, DuneAuthProviderContext, type DuneAuthProviderProps, type DuneContextValue, EMPTY_SDK, createCDFSDK, getToken, useDune };
|
package/dist/auth/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g}from"../chunk-QGJ3VKXY.js";import"../chunk-EI7MMDWY.js";export{f as AppSdkAuthProvider,e as DuneAuthProvider,d as DuneAuthProviderContext,c as EMPTY_SDK,b as createCDFSDK,a as getToken,g as useDune};
|
package/dist/chunk-QGJ3VKXY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-EI7MMDWY.js";import{connectToHostApp as b}from"@cognite/app-sdk";import{CogniteClient as U}from"@cognite/sdk";import{useEffect as N,useState as v}from"react";import{CogniteClient as R}from"@cognite/sdk";import{createContext as I,useEffect as L,useState as P}from"react";import{CogniteClient as A}from"@cognite/sdk";var D=t(async(n,e)=>{let o=`Basic ${btoa(`${n}:${e}`)}`;return(await(await fetch("https://auth.cognite.com/oauth2/token",{method:"POST",headers:{Authorization:o,"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"client_credentials"})})).json()).access_token},"getToken"),T=t(async n=>{let{project:e,baseUrl:o,clientId:r,clientSecret:d,appId:c="cdf-authentication-package"}=n;if(!e||!o||!r||!d)throw new Error("Missing required configuration. Please provide: project, baseUrl, clientId, clientSecret");let u=new A({appId:c,project:e,baseUrl:o,oidcTokenProvider:t(async()=>await D(r,d),"oidcTokenProvider")});return await u.authenticate(),u},"createCDFSDK"),p=new A({appId:"cdf-authentication-package",project:"",oidcTokenProvider:t(async()=>"","oidcTokenProvider")}),E=t(()=>{console.log("\u{1F511} Requesting credentials from parent..."),window.parent&&window.parent!==window&&window.parent.postMessage({type:"REQUEST_CREDENTIALS"},"*")},"requestCredentials"),S=t(n=>{if(n.data?.type==="PROVIDE_CREDENTIALS"&&n.data?.credentials){let e=n.data.credentials;if(e.token&&e.baseUrl&&e.project)return console.log("\u{1F389} useCredentials received credentials:",{hasToken:!!e.token,tokenLength:e.token?.length||0,project:e.project,baseUrl:e.baseUrl}),e}},"handleCredentialsResponse");import{Fragment as w,jsx as l,jsxs as x}from"react/jsx-runtime";var g=I({sdk:p,isLoading:!1}),y=t(({children:n,loadingComponent:e=l("div",{children:"Loading CDF authentication..."}),errorComponent:o=t(r=>x("div",{children:["Authentication error: ",r]}),"errorComponent")})=>l(_,{loadingComponent:e,errorComponent:o,children:n}),"DuneAuthProvider"),_=t(({children:n,loadingComponent:e=l("div",{children:"Loading CDF authentication..."}),errorComponent:o=t(r=>x("div",{children:["Authentication error: ",r]}),"errorComponent")})=>{let[r,d]=P(!0),[c,u]=P(p),[s]=P();return L(()=>{E();let f=t(async i=>{console.log("\u{1F50D} Handling message from Fusion");let a=S(i);if(!a)return;let h=new R({appId:"dune-app",project:a.project,baseUrl:a.baseUrl,oidcTokenProvider:t(async()=>a.token,"oidcTokenProvider")});await h.authenticate(),u(h),d(!1)},"handleMessage");return console.log("\u{1F50D} Adding message listener"),window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[]),console.log("\u{1F50D} CDFIframeAuthenticationInnerProvider",c,r,s),s&&o?l(w,{children:o(s)}):r&&e?l(w,{children:e}):l(g.Provider,{value:{sdk:c,isLoading:r,error:s},children:n})},"FusionIframeAuthenticationInnerProvider");import{Fragment as k,jsx as C,jsxs as j}from"react/jsx-runtime";var F=t(({children:n,loadingComponent:e=C("div",{children:"Loading CDF authentication..."}),errorComponent:o=t(r=>j("div",{children:["Authentication error: ",r]}),"errorComponent")})=>{let[r,d]=v(p),[c,u]=v(!0),[s,f]=v();return N(()=>{b().then(async({api:i})=>{let[a,h]=await Promise.all([i.getProject(),i.getBaseUrl()]),m=new U({appId:"dune-app",project:a,baseUrl:h,oidcTokenProvider:t(async()=>i.getAccessToken(),"oidcTokenProvider")});await m.authenticate(),d(m),f(void 0)}).catch(i=>{let a=i instanceof Error?i.message:String(i);f(a)}).finally(()=>{u(!1)})},[]),s&&o?C(k,{children:o(s)}):c&&e?C(k,{children:e}):C(g.Provider,{value:{sdk:r,isLoading:c,error:s},children:n})},"AppSdkAuthProvider");import{useContext as M}from"react";var Y=t(()=>{let n=M(g);if(!n)throw new Error("useDune must be used within a DuneAuthProvider");return n},"useDune");export{D as a,T as b,p as c,g as d,y as e,F as f,Y as g};
|
package/dist/vite/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CspFetchDirective, MANIFEST_VERSION, ManifestConfig, NetworkAllowlistRule, buildFrameAncestors, buildHostedAppContentSecurityPolicy, fusionOpenPlugin, getManifestNetworkRules, loadManifestConfig, manifestCspPlugin, parseAndValidateManifestConfig, validateManifestConfig } from '@cognite/app-sdk/vite';
|
package/dist/vite/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"../chunk-EI7MMDWY.js";import{fusionOpenPlugin as i,manifestCspPlugin as n,buildFrameAncestors as o,buildHostedAppContentSecurityPolicy as s,getManifestNetworkRules as a,loadManifestConfig as l,MANIFEST_VERSION as f,parseAndValidateManifestConfig as p,validateManifestConfig as r}from"@cognite/app-sdk/vite";export{f as MANIFEST_VERSION,o as buildFrameAncestors,s as buildHostedAppContentSecurityPolicy,i as fusionOpenPlugin,a as getManifestNetworkRules,l as loadManifestConfig,n as manifestCspPlugin,p as parseAndValidateManifestConfig,r as validateManifestConfig};
|