@cognite/cli 1.3.4-alpha.selfsigned → 1.4.0-alpha.sdk-gen
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/LICENSE.md +6 -0
- package/README.md +12 -0
- package/_templates/app/new/claude/mcp.json.ejs.t +11 -0
- package/_templates/app/new/config/vite.config.ts.ejs.t +6 -3
- package/_templates/app/new/config/vitest.config.ts.ejs.t +5 -0
- package/_templates/app/new/cursor/mcp.json.ejs.t +10 -0
- package/_templates/app/new/root/.npmrc.ejs.t +1 -1
- package/_templates/app/new/root/AGENTS.md.ejs.t +157 -14
- package/_templates/app/new/root/SPEC.md.ejs.t +17 -15
- package/_templates/app/new/root/gitignore.ejs.t +7 -0
- package/_templates/app/new/root/package.json.ejs.t +8 -3
- package/_templates/app/new/src/App.test.tsx.ejs.t +37 -11
- package/_templates/app/new/src/App.tsx.ejs.t +46 -64
- package/_templates/app/new/vscode/mcp.json.ejs.t +11 -0
- package/dist/chunk-EI7MMDWY.js +1 -0
- package/dist/chunk-FEYVYSNN.js +1 -0
- package/dist/chunk-VTE66IK5.js +8 -0
- package/dist/chunk-Z24V7VPI.js +13 -0
- package/dist/cli/cli.js +212 -66
- package/dist/deploy/index.d.ts +100 -31
- package/dist/deploy/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/sdk-runtime/index.d.ts +209 -0
- package/dist/sdk-runtime/index.js +1 -0
- package/dist/{skills-GQ5TZKCM.js → skills-SV7BPHAZ.js} +1 -1
- package/package.json +15 -4
- package/dist/chunk-A5ASLC6T.js +0 -7
- package/dist/chunk-BXCPVUBR.js +0 -9
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
import { CogniteClient } from '@cognite/sdk';
|
|
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
|
-
* OAuth scope for Entra ID authentication. When set, overrides the scope
|
|
16
|
-
* that would otherwise be derived from baseUrl
|
|
17
|
-
* (e.g. "https://<cluster>.cognitedata.com/.default").
|
|
18
|
-
* Use this for non-standard CDF environments such as private-link deployments.
|
|
19
|
-
*/
|
|
20
|
-
scope?: string;
|
|
21
|
-
};
|
|
22
|
-
type App = {
|
|
23
|
-
externalId: string;
|
|
24
|
-
name: string;
|
|
25
|
-
description: string;
|
|
26
|
-
versionTag: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
declare const deploy: (deployment: Deployment, app: App, folder: string) => Promise<void>;
|
|
1
|
+
import { CogniteClient, ClientOptions } from '@cognite/sdk';
|
|
30
2
|
|
|
31
3
|
/**
|
|
32
4
|
* App Hosting HTTP API layer.
|
|
@@ -52,6 +24,18 @@ interface AppVersion {
|
|
|
52
24
|
createdBy: string;
|
|
53
25
|
appExternalId: string;
|
|
54
26
|
}
|
|
27
|
+
declare const SIGNATURE_STATUSES: readonly ["VALID", "REVOKED", "EXPIRED", "SIGNED_BEFORE_KEY_ISSUED", "IAT_IN_FUTURE", "BUNDLE_TOO_OLD", "KEY_NOT_IN_REGISTRY"];
|
|
28
|
+
type SignatureStatus = (typeof SIGNATURE_STATUSES)[number];
|
|
29
|
+
declare const SIGNER_ROLES: readonly ["developer", "certifier"];
|
|
30
|
+
type SignerRole = (typeof SIGNER_ROLES)[number];
|
|
31
|
+
type StoredSignature = {
|
|
32
|
+
signerKid: string;
|
|
33
|
+
signerRole: SignerRole;
|
|
34
|
+
signatureIat: number;
|
|
35
|
+
receivedAt: number;
|
|
36
|
+
createdTime: number;
|
|
37
|
+
status: SignatureStatus;
|
|
38
|
+
};
|
|
55
39
|
|
|
56
40
|
declare class AppHostingClient {
|
|
57
41
|
private api;
|
|
@@ -63,10 +47,22 @@ declare class AppHostingClient {
|
|
|
63
47
|
* success so the call is safe to repeat.
|
|
64
48
|
*/
|
|
65
49
|
ensureApp(externalId: string, name: string, description: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Submit verified compact-JWS signatures for a version uploaded earlier.
|
|
52
|
+
* No-op when `items` is empty so callers can wire it unconditionally.
|
|
53
|
+
* The backend accepts and stores well-formed tokens; tier-policy
|
|
54
|
+
* verification happens on the subsequent publish step.
|
|
55
|
+
*/
|
|
56
|
+
submitSignatures(appExternalId: string, version: string, items: string[]): Promise<void>;
|
|
57
|
+
/** Fetch the stored signatures for a version. Returns [] when none stored. */
|
|
58
|
+
listSignatures(appExternalId: string, version: string): Promise<StoredSignature[]>;
|
|
66
59
|
/** Transition a version from DRAFT to PUBLISHED. */
|
|
67
60
|
publishVersion(appExternalId: string, version: string): Promise<void>;
|
|
68
61
|
/** Publish the version and immediately set it as the ACTIVE alias. */
|
|
69
62
|
publishAndActivate(appExternalId: string, version: string): Promise<void>;
|
|
63
|
+
getActiveVersion(appExternalId: string): Promise<AppVersion | null>;
|
|
64
|
+
/** Remove the ACTIVE alias from a version, taking it out of service without changing its lifecycle state. */
|
|
65
|
+
deactivateVersion(appExternalId: string, version: string): Promise<void>;
|
|
70
66
|
/**
|
|
71
67
|
* Set the ACTIVE alias on a version. Returns the version that was
|
|
72
68
|
* previously active (if any) so callers can surface "Superseded X"
|
|
@@ -89,6 +85,42 @@ declare class AppHostingClient {
|
|
|
89
85
|
deploy(appExternalId: string, name: string, description: string, versionTag: string, fileContent: Buffer, fileName: string, published?: boolean): Promise<void>;
|
|
90
86
|
}
|
|
91
87
|
|
|
88
|
+
type Deployment = {
|
|
89
|
+
org: string;
|
|
90
|
+
project: string;
|
|
91
|
+
baseUrl: string;
|
|
92
|
+
deployClientId: string;
|
|
93
|
+
deploySecretName: string;
|
|
94
|
+
published: boolean;
|
|
95
|
+
/** Identity provider type. Defaults to "cdf" if not specified */
|
|
96
|
+
idpType?: 'cdf' | 'entra_id';
|
|
97
|
+
/** Tenant ID for Entra ID authentication. Required when idpType is "entra_id" */
|
|
98
|
+
tenantId?: string;
|
|
99
|
+
};
|
|
100
|
+
type App = {
|
|
101
|
+
externalId: string;
|
|
102
|
+
name: string;
|
|
103
|
+
description: string;
|
|
104
|
+
versionTag: string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Package `dist/` into `<folder>/.cognite-bundles/<externalId>-<versionTag>.zip`
|
|
109
|
+
* and upload it via an already-authenticated `AppHostingClient`. Both deploy
|
|
110
|
+
* entry points (programmatic `deploy()` and the CLI's interactive path) reuse
|
|
111
|
+
* this so packaging/upload behaviour stays in one place.
|
|
112
|
+
*
|
|
113
|
+
* The bundle file is intentionally left on disk so the follow-on
|
|
114
|
+
* `cognite apps sign` + `cognite apps publish` flow can operate on the
|
|
115
|
+
* exact bytes the backend received.
|
|
116
|
+
*/
|
|
117
|
+
declare function packageAndUpload(client: AppHostingApiClient, app: App, folder: string, published: boolean): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Programmatic deploy used by CI scripts: resolves an SDK from the
|
|
120
|
+
* deployment's env-var credentials, then runs `packageAndUpload`.
|
|
121
|
+
*/
|
|
122
|
+
declare const deploy: (deployment: Deployment, app: App, folder: string) => Promise<void>;
|
|
123
|
+
|
|
92
124
|
/**
|
|
93
125
|
* Application Packaging
|
|
94
126
|
*
|
|
@@ -100,9 +132,13 @@ declare class ApplicationPackager {
|
|
|
100
132
|
constructor(distDirectory?: string);
|
|
101
133
|
validateBuildDirectory(): void;
|
|
102
134
|
createZip(outputFilename?: string, verbose?: boolean): Promise<string>;
|
|
135
|
+
createSourceArchive(outputPath: string): Promise<string>;
|
|
136
|
+
private validateNoSensitiveFiles;
|
|
103
137
|
}
|
|
104
138
|
|
|
105
|
-
|
|
139
|
+
type Authenticatable = Pick<CogniteClient, 'authenticate'>;
|
|
140
|
+
declare function getSdk(deployment: Deployment, folder: string, env?: NodeJS.ProcessEnv): Promise<CogniteClient>;
|
|
141
|
+
declare function getSdk<C extends Authenticatable>(deployment: Deployment, folder: string, env: NodeJS.ProcessEnv, createClient: (opts: ClientOptions) => C): Promise<C>;
|
|
106
142
|
|
|
107
143
|
/**
|
|
108
144
|
* Get access token for deployment using the appropriate identity provider.
|
|
@@ -113,4 +149,37 @@ declare const getSdk: (deployment: Deployment, folder: string, env?: NodeJS.Proc
|
|
|
113
149
|
*/
|
|
114
150
|
declare const getToken: (deployment: Deployment, env?: NodeJS.ProcessEnv) => Promise<string>;
|
|
115
151
|
|
|
116
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Sibling-file discovery for bundle signatures written by `cognite sign`.
|
|
154
|
+
*
|
|
155
|
+
* <bundle>.dev.sig — developer signature
|
|
156
|
+
* <bundle>.cert.sig — certifier counter-signature (`--as-certifier`)
|
|
157
|
+
*
|
|
158
|
+
* Tokens are passed verbatim to the App Hosting `/signatures` endpoint; the
|
|
159
|
+
* backend verifies them against its key registry and tier policy.
|
|
160
|
+
*
|
|
161
|
+
* Collaborators are injected via `deps` so tests can stub fs without `vi.mock`.
|
|
162
|
+
*/
|
|
163
|
+
declare const SIGNATURE_SUFFIXES: readonly [".dev.sig", ".cert.sig"];
|
|
164
|
+
type DiscoverSignaturesDeps = {
|
|
165
|
+
existsSync?: (path: string) => boolean;
|
|
166
|
+
readFileSync?: (path: string, encoding: 'utf8') => string;
|
|
167
|
+
};
|
|
168
|
+
declare function discoverSignatures(bundlePath: string, deps?: DiscoverSignaturesDeps): string[];
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Stable on-disk location for a packaged app bundle, keyed on app + version.
|
|
172
|
+
*
|
|
173
|
+
* `cognite apps deploy` writes the zip here and leaves it in place, so the
|
|
174
|
+
* subsequent `cognite apps sign` + `cognite apps publish` steps operate on
|
|
175
|
+
* the *exact bytes* that were uploaded — the bundle SHA in the signed
|
|
176
|
+
* payload matches what the backend has on hand.
|
|
177
|
+
*
|
|
178
|
+
* Lives under a single gitignored folder (`.cognite-bundles/`) so signed
|
|
179
|
+
* artefacts don't accidentally land in version control.
|
|
180
|
+
*/
|
|
181
|
+
declare const BUNDLE_DIR = ".cognite-bundles";
|
|
182
|
+
declare function bundleFileName(externalId: string, versionTag: string): string;
|
|
183
|
+
declare function bundlePath(cwd: string, externalId: string, versionTag: string): string;
|
|
184
|
+
|
|
185
|
+
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}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-Z24V7VPI.js";import"../chunk-EI7MMDWY.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,2 +1,4 @@
|
|
|
1
|
-
export { App, AppHostingClient, ApplicationPackager, Deployment, deploy, getSdk, getToken } from './deploy/index.js';
|
|
1
|
+
export { App, AppHostingClient, ApplicationPackager, BUNDLE_DIR, Deployment, SIGNATURE_SUFFIXES, bundleFileName, bundlePath, deploy, discoverSignatures, getSdk, getToken, packageAndUpload } from './deploy/index.js';
|
|
2
|
+
export { DuneRuntime, ViewDefinition, ViewDefinitionProperty, createDuneRuntime, createDuneRuntimeFromViews } from './sdk-runtime/index.js';
|
|
2
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}from"./chunk-
|
|
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-Z24V7VPI.js";import{a as d,b as g}from"./chunk-FEYVYSNN.js";import"./chunk-EI7MMDWY.js";export{o as AppHostingClient,r as ApplicationPackager,e as BUNDLE_DIR,b as SIGNATURE_SUFFIXES,f as bundleFileName,m as bundlePath,d as createDuneRuntime,g as createDuneRuntimeFromViews,a as deploy,c as discoverSignatures,t as getSdk,p as getToken,x as packageAndUpload};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ViewDefinition as ViewDefinition$1, ViewDefinitionProperty as ViewDefinitionProperty$1, ViewReference, FilterDefinition, SearchSort, AggregationDefinition, AggregatedResultItem, InstancesAPI, CogniteClient } 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: 'directRelationList';
|
|
29
|
+
targetView: SharedViewId;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'reverseDirect';
|
|
32
|
+
sourceView: SharedViewId;
|
|
33
|
+
throughProperty: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'reverseList';
|
|
36
|
+
sourceView: SharedViewId;
|
|
37
|
+
throughProperty: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'edge';
|
|
40
|
+
targetView: SharedViewId;
|
|
41
|
+
direction: 'outwards' | 'inwards';
|
|
42
|
+
};
|
|
43
|
+
interface SchemaView {
|
|
44
|
+
view: SharedViewId;
|
|
45
|
+
properties: Map<string, PropertyDescriptor>;
|
|
46
|
+
}
|
|
47
|
+
interface SchemaKnowledge {
|
|
48
|
+
view(ref: SharedViewId): SchemaView;
|
|
49
|
+
property(ref: SharedViewId, prop: string): PropertyDescriptor | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type ViewDefinitionProperty = ViewDefinitionProperty$1 & {
|
|
53
|
+
constraintState?: Record<string, unknown>;
|
|
54
|
+
};
|
|
55
|
+
type ViewDefinition = Omit<ViewDefinition$1, 'properties'> & {
|
|
56
|
+
properties: Record<string, ViewDefinitionProperty>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Matches the Requester type emitted by @graphql-codegen/typescript-generic-sdk,
|
|
61
|
+
* so the return of createDuneRequester can be passed directly to getSdk().
|
|
62
|
+
*/
|
|
63
|
+
type DuneRequester = <TData, TVariables>(doc: DocumentNode, variables?: TVariables) => Promise<TData>;
|
|
64
|
+
|
|
65
|
+
interface PropertyRef {
|
|
66
|
+
view: ViewReference;
|
|
67
|
+
property: string;
|
|
68
|
+
}
|
|
69
|
+
interface ConnectionSelection {
|
|
70
|
+
limit?: number;
|
|
71
|
+
select: SelectionTree;
|
|
72
|
+
}
|
|
73
|
+
interface SelectionTree {
|
|
74
|
+
scalars: string[];
|
|
75
|
+
connections: Map<string, ConnectionSelection>;
|
|
76
|
+
}
|
|
77
|
+
interface SortClause {
|
|
78
|
+
property: PropertyRef;
|
|
79
|
+
direction: 'ascending' | 'descending';
|
|
80
|
+
/** When true, nulls sort before non-nulls. Defaults to false. */
|
|
81
|
+
nullsFirst?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** Pre-translated DMS logical filter (output of translateFilter in resolver layer). */
|
|
84
|
+
type LogicalFilter = FilterDefinition;
|
|
85
|
+
interface QueryInput {
|
|
86
|
+
view: ViewReference;
|
|
87
|
+
filter?: LogicalFilter;
|
|
88
|
+
sort?: SortClause[];
|
|
89
|
+
select: SelectionTree;
|
|
90
|
+
/** Page size. Defaults to INITIAL_BATCH_LIMIT if omitted. */
|
|
91
|
+
limit?: number;
|
|
92
|
+
/** Opaque cursor from a previous ListResult.pageInfo.endCursor. */
|
|
93
|
+
cursor?: string;
|
|
94
|
+
}
|
|
95
|
+
interface ListResult<T = Record<string, unknown>> {
|
|
96
|
+
items: T[];
|
|
97
|
+
pageInfo: {
|
|
98
|
+
endCursor: string | null;
|
|
99
|
+
hasNextPage: boolean;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface SearchInput {
|
|
104
|
+
view: ViewReference;
|
|
105
|
+
/** Full-text search term. */
|
|
106
|
+
query?: string;
|
|
107
|
+
filter?: LogicalFilter;
|
|
108
|
+
sort?: SearchSort[];
|
|
109
|
+
select: SelectionTree;
|
|
110
|
+
/** Max items to return. Defaults to searchLimit config. */
|
|
111
|
+
limit?: number;
|
|
112
|
+
/** Restrict search to specific property names within the view. */
|
|
113
|
+
properties?: string[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface AggregateInput {
|
|
117
|
+
view: ViewReference;
|
|
118
|
+
filter?: LogicalFilter;
|
|
119
|
+
aggregates: AggregationDefinition[];
|
|
120
|
+
groupBy?: string[];
|
|
121
|
+
/** Optional full-text query to scope which instances are aggregated. */
|
|
122
|
+
query?: string;
|
|
123
|
+
}
|
|
124
|
+
interface AggregateOutput {
|
|
125
|
+
items: AggregatedResultItem[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type DmsClient = Pick<InstancesAPI, 'query' | 'search' | 'aggregate' | 'retrieve' | 'upsert' | 'delete' | 'sync' | 'inspect'>;
|
|
129
|
+
interface PlannerConfig {
|
|
130
|
+
initialBatchLimit: number;
|
|
131
|
+
maxBatchLimit: number;
|
|
132
|
+
searchLimit: number;
|
|
133
|
+
inFilterChunkSize: number;
|
|
134
|
+
previewLimit: number;
|
|
135
|
+
nestedDetailLimit: number;
|
|
136
|
+
enableRemoveNotConnected: boolean;
|
|
137
|
+
max408Retries: number;
|
|
138
|
+
max429Retries: number;
|
|
139
|
+
retryBaseDelayMs: number;
|
|
140
|
+
maxConcurrentRequests: number;
|
|
141
|
+
/** Maximum SelectionTree nesting depth. Throws PlannerValidationError if exceeded. */
|
|
142
|
+
maxNestingDepth: number;
|
|
143
|
+
/** Hard ceiling for listAll without an explicit maxTotal. Throws rather than silently truncating. */
|
|
144
|
+
maxTotalItems: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare class QueryRunner {
|
|
148
|
+
private readonly dms;
|
|
149
|
+
private readonly schema;
|
|
150
|
+
private readonly config;
|
|
151
|
+
private readonly executor;
|
|
152
|
+
get schemaKnowledge(): SchemaKnowledge | undefined;
|
|
153
|
+
constructor(dms: DmsClient, schema?: SchemaKnowledge, config?: Partial<PlannerConfig>);
|
|
154
|
+
query<T = Record<string, unknown>>(input: QueryInput): Promise<ListResult<T>>;
|
|
155
|
+
/**
|
|
156
|
+
* Collects all pages until exhaustion. `input.limit` is the page size.
|
|
157
|
+
* `maxTotal` sets an explicit ceiling — without it, throws at `config.maxTotalItems`
|
|
158
|
+
* to prevent unbounded fetches.
|
|
159
|
+
*/
|
|
160
|
+
queryAll<T = Record<string, unknown>>(input: Omit<QueryInput, 'cursor'>, maxTotal?: number): Promise<T[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Full-text or filter-based search returning a single (non-paginated) result set.
|
|
163
|
+
* Use for top-level discovery; DMS search has eventual consistency — do not use
|
|
164
|
+
* for writes-then-reads or where strong consistency is required.
|
|
165
|
+
*/
|
|
166
|
+
search<T = Record<string, unknown>>(input: SearchInput): Promise<ListResult<T>>;
|
|
167
|
+
/**
|
|
168
|
+
* Fetches specific nodes by space+externalId. Returns an empty array when ids is empty.
|
|
169
|
+
* Extracts view-scoped properties before returning, matching the shape of list results.
|
|
170
|
+
*/
|
|
171
|
+
getByIds<T = Record<string, unknown>>(ids: Array<{
|
|
172
|
+
space: string;
|
|
173
|
+
externalId: string;
|
|
174
|
+
}>, view: ViewReference): Promise<T[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Returns the total count of instances matching the filter.
|
|
177
|
+
* Wraps the filter with hasData so only instances with data in the view are counted.
|
|
178
|
+
*/
|
|
179
|
+
count(input: {
|
|
180
|
+
view: ViewReference;
|
|
181
|
+
filter?: LogicalFilter;
|
|
182
|
+
}): Promise<number>;
|
|
183
|
+
aggregate(input: AggregateInput): Promise<AggregateOutput>;
|
|
184
|
+
/**
|
|
185
|
+
* Async generator — yields one ListResult<T> per page.
|
|
186
|
+
* Lets callers stream results or stop early without fetching remaining pages.
|
|
187
|
+
*/
|
|
188
|
+
queryPages<T = Record<string, unknown>>(input: Omit<QueryInput, 'cursor'>): AsyncGenerator<ListResult<T>>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface DuneRuntime {
|
|
192
|
+
schema: GraphQLSchema;
|
|
193
|
+
rootValue: Record<string, unknown>;
|
|
194
|
+
runner: QueryRunner;
|
|
195
|
+
/** Pass directly to the generated getSdk() function. */
|
|
196
|
+
requester: DuneRequester;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Builds the full runtime from a data model config. Fetches views from CDF,
|
|
200
|
+
* builds the GraphQL schema, wires resolvers, and returns a ready requester.
|
|
201
|
+
*/
|
|
202
|
+
declare function createDuneRuntime(config: GenerateSdkConfig, client: CogniteClient): Promise<DuneRuntime>;
|
|
203
|
+
/**
|
|
204
|
+
* Builds the runtime directly from an array of ViewDefinition objects — skips the
|
|
205
|
+
* data model lookup. Useful when you already have views from sdk.views.list().
|
|
206
|
+
*/
|
|
207
|
+
declare function createDuneRuntimeFromViews(views: ViewDefinition[], client: CogniteClient): DuneRuntime;
|
|
208
|
+
|
|
209
|
+
export { type DuneRuntime, type ViewDefinition, type ViewDefinitionProperty, createDuneRuntime, createDuneRuntimeFromViews };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"../chunk-FEYVYSNN.js";import"../chunk-EI7MMDWY.js";export{a as createDuneRuntime,b as createDuneRuntimeFromViews};
|
|
@@ -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-VTE66IK5.js";export{c as buildPullArgs,a as execSkillsCli,b as pullAllArgs,d as registerSkillsCommand};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognite/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-alpha.sdk-gen",
|
|
4
4
|
"description": "CLI for Cognite Data Fusion",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Cognite",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -22,6 +22,11 @@
|
|
|
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"
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
32
|
"bin": {
|
|
@@ -34,6 +39,7 @@
|
|
|
34
39
|
],
|
|
35
40
|
"scripts": {
|
|
36
41
|
"build": "tsup",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
37
43
|
"prepare": "tsup",
|
|
38
44
|
"prepack": "pnpm run build",
|
|
39
45
|
"prepublishOnly": "pnpm run build",
|
|
@@ -44,21 +50,26 @@
|
|
|
44
50
|
"refresh-spec-kit": "bash scripts/refresh-spec-kit.sh"
|
|
45
51
|
},
|
|
46
52
|
"dependencies": {
|
|
47
|
-
"@cognite/app-sdk": "^0.
|
|
53
|
+
"@cognite/app-sdk": "^0.5.1",
|
|
48
54
|
"@cognite/sdk": "^10.10.0",
|
|
55
|
+
"@graphql-codegen/cli": "^7.0.0",
|
|
56
|
+
"@graphql-codegen/typescript": "^6.0.1",
|
|
57
|
+
"@graphql-codegen/typescript-generic-sdk": "^5.0.1",
|
|
58
|
+
"@graphql-codegen/typescript-operations": "^6.0.2",
|
|
49
59
|
"@sentry/node": "^10.51.0",
|
|
50
60
|
"@zip.js/zip.js": "^2.7.0",
|
|
51
61
|
"chalk": "^5.6.2",
|
|
62
|
+
"clipboardy": "5.3.1",
|
|
52
63
|
"commander": "^14.0.3",
|
|
53
64
|
"dotenv": "^17.4.2",
|
|
54
65
|
"enquirer": "^2.4.1",
|
|
55
66
|
"execa": "^5.1.1",
|
|
67
|
+
"graphql": "^16.13.2",
|
|
56
68
|
"hygen": "^6.2.11",
|
|
57
69
|
"jose": "^6.2.2",
|
|
58
70
|
"mixpanel": "^0.21.0",
|
|
59
71
|
"open": "^10.1.0",
|
|
60
72
|
"openid-client": "^6.8.3",
|
|
61
|
-
"selfsigned": "^5.5.0",
|
|
62
73
|
"semver": "^7.7.0",
|
|
63
74
|
"skills": "^1.4.3",
|
|
64
75
|
"valibot": "^1.3.1"
|
package/dist/chunk-A5ASLC6T.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
var r=Object.defineProperty;var s=(l,i)=>r(l,"name",{value:i,configurable:!0});import{execFileSync as c}from"child_process";import{createRequire as a}from"module";import{InvalidArgumentError as p}from"commander";var e="cognitedata/builder-skills",o=["claude-code","cursor"],t=o.flatMap(l=>["-a",l]),u=a(import.meta.url).resolve("skills/bin/cli.mjs");function n(l,i={}){c(process.execPath,[u,...l],{stdio:"inherit",cwd:process.cwd(),...i})}s(n,"execSkillsCli");function S(){return["add",e,...t,"--skill","*","-y"]}s(S,"pullAllArgs");function d(l){if(!/^[\w.-]+\/[\w.-]+$/.test(l))throw new p("Expected owner/repo format (e.g., cognitedata/builder-skills)");return l}s(d,"validateSource");function m(l){let i=["add",l.source,...t];return l.skill?i.push("--skill",l.skill):l.interactive||i.push("--skill","*","-y"),l.global&&i.push("--global"),i}s(m,"buildPullArgs");function k(l){console.log(`\u{1F504} Pulling skills from ${l.source}...`),n(m(l)),console.log(`
|
|
2
|
-
\u2705 Skills pulled successfully`)}s(k,"handlePull");function P(l){let i=l.command("skills").summary("Manage AI agent skills for your app").description(`Manage AI agent skills for your app.
|
|
3
|
-
Supports: ${o.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 list List installed skills`);return i.command("pull").description("Pull all skills into your project").option("--source <owner/repo>","Skills repository",d,e).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(P,"registerSkillsCommand");export{s as a,n as b,S as c,m as d,P as e};
|
package/dist/chunk-BXCPVUBR.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var W=Object.defineProperty;var s=(e,t)=>W(e,"name",{value:t,configurable:!0});import Y from"fs";import gt from"path";var N="https://docs.cognite.com/cdf/access/";function m(e){return e!==null&&typeof e=="object"}s(m,"isRecord");function S(e){return e instanceof Error&&"status"in e&&typeof e.status=="number"}s(S,"isHttpError");function Z(e){switch(e){case 401:return`Your credentials are invalid or expired. Check your client ID and secret.
|
|
2
|
-
See: ${N}`;case 403:return`You don't have the required CDF capabilities. Please contact your CDF admin.
|
|
3
|
-
See: ${N}`;default:return}}s(Z,"httpStatusHint");function w(e){let t=e instanceof Error?e:new Error(String(e));if(!S(t))return null;let n=Z(t.status);return n?Object.assign(new Error(`${t.message}
|
|
4
|
-
${n}`),{cause:t}):null}s(w,"enrichedHttpError");function X(e){if(!m(e))return null;let t=e.missing;if(Array.isArray(t))return t;let n=e.data;if(m(n)){let r=n.error;if(m(r)&&Array.isArray(r.missing))return r.missing;if(Array.isArray(n.missing))return n.missing}return null}s(X,"findMissingArray");function Q(e,t){if(!S(e)||e.status!==400)return!1;let n=X(e);return n?n.some(r=>m(r)&&typeof r.externalId=="string"&&t.includes(r.externalId)):!1}s(Q,"isMissingExternalIdError");function v(e,t){return S(e)&&e.status===404||Q(e,t)}s(v,"isNotFoundError");var M=["DRAFT","PUBLISHED","DEPRECATED","ARCHIVED"],J=["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 q(e,t){return e.includes(t)}s(q,"includesValue");function tt(e){return q(M,e)}s(tt,"isAppVersionLifecycleState");function et(e){return q(J,e)}s(et,"isAppVersionAlias");function nt(e){return typeof e.version=="string"&&tt(e.lifecycleState)&&typeof e.entrypoint=="string"&&typeof e.createdTime=="number"&&typeof e.createdBy=="string"&&typeof e.appExternalId=="string"&&(e.alias===void 0||et(e.alias))&&(e.comment===void 0||typeof e.comment=="string")}s(nt,"isAppVersion");function H(e){if(!m(e))throw new Error("Invalid version response: not an object");if(!nt(e))throw new Error("Invalid version response: missing or malformed fields");return e}s(H,"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 l=encodeURIComponent(t),a=`${this.appsBasePath}/${l}/versions`,p=await this.client.authenticate(),g=`${this.client.getBaseUrl()}${a}`,u=new AbortController,G=setTimeout(()=>u.abort(),300*1e3),y;try{y=await fetch(g,{method:"POST",headers:{Authorization:`Bearer ${p}`},body:c,signal:u.signal})}catch(f){throw f instanceof Error&&f.name==="AbortError"?new Error("Upload timed out after 5 minutes"):f}finally{clearTimeout(G)}if(!y.ok){let f=await y.text(),k=f;try{let $=JSON.parse(f);if(m($)){let A=$.error;if(typeof A=="string")k=A;else if(m(A)){let E=A.message,F=A.code;k=typeof E=="string"?E:F!=null?`Unknown error (code: ${F})`:f}else{let E=$.message;k=typeof E=="string"?E:f}}}catch{}let j=y.headers.get("x-request-id"),K=j?` | X-Request-ID: ${j}`:"",B=Object.assign(new Error(`Upload failed: ${y.status} \u2014 ${k}${K}`),{status:y.status});throw w(B)??B}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 H(c.data)}catch(c){throw v(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 H(o.data)}catch(o){if(v(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 x=T;var b=class b{constructor(t){this.api=new x(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,l=!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),l&&await this.publishAndActivate(t,o),console.log(`
|
|
7
|
-
\u2705 Deployment successful!`)}catch(a){let p=a instanceof Error?a.message:String(a);throw Object.assign(new Error(`Deployment failed: ${p}`),{cause:a})}}};s(b,"AppHostingClient");var P=b;import h 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",L=class L{constructor(t="dist"){this.distPath=d.isAbsolute(t)?t:d.join(process.cwd(),t),this.appRoot=d.dirname(this.distPath)}validateBuildDirectory(){if(!h.existsSync(this.distPath))throw new Error(`Build directory "${this.distPath}" not found. Run build first.`);let t=d.join(this.appRoot,R);if(!h.existsSync(t))throw new Error(`"${t}" not found. It is required for deployment.`);let n=d.join(this.appRoot,D);if(!h.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 it(new st,{level:9}),o=s(async(a,p)=>{await r.add(p,new ot(await h.openAsBlob(a))),n&&console.log(` \u{1F4C4} ${p}`)},"addFile"),i=s(async a=>{let p=await h.promises.readdir(a,{withFileTypes:!0});for(let g of p){let u=d.join(a,g.name);g.isDirectory()?await i(u):await o(u,d.relative(this.distPath,u).replace(/\\/g,"/"))}},"addDir"),c;try{await i(this.distPath);let a=d.join(this.appRoot,R);await o(a,d.posix.join(_,R));let p=d.join(this.appRoot,z);if(h.existsSync(p)){let u=h.readFileSync(p,"utf-8");rt(u,p),await o(p,d.posix.join(_,z))}let g=d.join(this.appRoot,D);await o(g,d.posix.join(_,D)),c=await r.close()}catch(a){let p=a instanceof Error?a.message:String(a);throw new Error(`Failed to create zip: ${p}`)}await h.promises.writeFile(t,c);let l=(c.byteLength/1024/1024).toFixed(2);return console.log(`\u2705 App packaged: ${t} (${l} MB)`),t}};s(L,"ApplicationPackager");var V=L;import{CogniteClient as ut}from"@cognite/sdk";var at=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"),ct=s(e=>{let t;if(process.env.DEPLOYMENT_SECRET&&(t=process.env.DEPLOYMENT_SECRET),t||(t=at()[e]),t||(t=process.env[e]),!t)throw new Error(`Secret not found in environment: ${e}`);return t},"getSecretFromEnv"),pt=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"),lt=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"),dt=s(async(e,t,n,r,o)=>{let i;if(o)i=o;else{if(!r)throw new Error("Entra ID authentication requires 'baseUrl' to be set in deployment configuration");let p=pt(r);if(!p)throw new Error(`Entra ID authentication requires 'baseUrl' to be a valid CDF URL (e.g., https://cluster.cognitedata.com), got: ${r}`);i=`https://${p}.cognitedata.com/.default`}let c=`https://login.microsoftonline.com/${n}/oauth2/v2.0/token`,l=await fetch(c,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:e,client_secret:t,scope:i,grant_type:"client_credentials"})});if(!l.ok){let p=await l.text();throw new Error(`Failed to get token from Entra ID: ${l.status} ${l.statusText}
|
|
9
|
-
${p}`)}let a=await l.json();if(!a.access_token)throw new Error("No access token returned from Entra ID authentication");return a.access_token},"getTokenEntra"),U=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,scope:l}=e,a=ct(r);if(o==="entra_id"){if(!i)throw new Error("Entra ID authentication requires 'tenantId' in deployment configuration");return dt(n,a,i,c,l)}return lt(n,a)},"getToken");var O=s(async(e,t,n=process.env)=>{let r=await U(e,n),o=n.COGNITE_BASE_URL??e.baseUrl,i=new ut({appId:t,project:e.project,baseUrl:o,oidcTokenProvider:s(async()=>r,"oidcTokenProvider")});return await i.authenticate(),i},"getSdk");var ft=s(async(e,t,n)=>{let r=await new V(`${n}/dist`).createZip("app.zip",!0);try{let{externalId:o,name:i,description:c,versionTag:l}=t,a=await O(e,n),p=new P(a),g=Y.readFileSync(r),u=gt.basename(r);await p.deploy(o,i,c,l,g,u,e.published)}finally{try{Y.unlinkSync(r)}catch{}}},"deploy");export{P as a,V as b,U as c,O as d,ft as e};
|