@clarigen/cli 4.0.1 → 4.0.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,322 +1,252 @@
1
- import { ClarityAbi, ClarityAbiFunction, ClarityAbiMap, ClarityAbiVariable, ClarityAbiArg, ClarityAbiType } from '@clarigen/core';
2
- import * as arktype_internal_variants_object_ts from 'arktype/internal/variants/object.ts';
3
- import { Simnet } from '@stacks/clarinet-sdk';
4
- import { inspect, InspectOptions } from 'util';
1
+ /// <reference types="node" />
2
+ import { ClarityAbi, ClarityAbiArg, ClarityAbiFunction, ClarityAbiMap, ClarityAbiType, ClarityAbiVariable, DeploymentPlan } from "@clarigen/core";
3
+ import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
4
+ import { Simnet } from "@stacks/clarinet-sdk";
5
+ import { InspectOptions } from "util";
5
6
 
7
+ //#region src/session.d.ts
6
8
  interface SessionContract {
7
- contract_id: string;
8
- contract_interface: ClarityAbi;
9
- source: string;
9
+ contract_id: string;
10
+ contract_interface: ClarityAbi;
11
+ source: string;
10
12
  }
11
13
  type EpochType = ClarityAbi;
12
14
  type SessionAccount = {
13
- address: string;
14
- balance: string;
15
- name: string;
15
+ address: string;
16
+ balance: string;
17
+ name: string;
16
18
  };
17
19
  interface Session {
18
- session_id: number;
19
- accounts: SessionAccount[];
20
- contracts: SessionContract[];
20
+ session_id: number;
21
+ accounts: SessionAccount[];
22
+ contracts: SessionContract[];
21
23
  }
22
24
  interface SessionWithVariables extends Session {
23
- variables: string[];
24
- }
25
-
26
- declare const ClarinetConfig: arktype_internal_variants_object_ts.ObjectType<{
27
- project: {
28
- requirements?: {
29
- contract_id: string;
30
- }[] | undefined;
31
- cache_location?: {
32
- path: string;
33
- } | undefined;
34
- };
35
- contracts?: {
36
- [x: string]: {
37
- path: string;
38
- };
25
+ variables: string[];
26
+ }
27
+ //#endregion
28
+ //#region src/clarinet-config.d.ts
29
+ declare const ClarinetConfig: arktype_internal_variants_object_ts0.ObjectType<{
30
+ project: {
31
+ requirements?: {
32
+ contract_id: string;
33
+ }[] | undefined;
34
+ cache_location?: {
35
+ path: string;
39
36
  } | undefined;
37
+ };
38
+ contracts?: {
39
+ [x: string]: {
40
+ path: string;
41
+ };
42
+ } | undefined;
40
43
  }, {}>;
41
44
  type ClarinetConfig = typeof ClarinetConfig.infer;
42
45
  declare function getClarinetConfig(path: string): Promise<ClarinetConfig>;
43
-
46
+ //#endregion
47
+ //#region src/config.d.ts
44
48
  declare const CONFIG_FILE: "Clarigen.toml";
45
49
  declare enum OutputType {
46
- ESM = "types",
47
- ESM_OLD = "esm",
48
- Docs = "docs"
49
- }
50
- declare const ConfigFile: arktype_internal_variants_object_ts.ObjectType<{
51
- clarinet: string;
52
- types?: {
53
- output?: string | undefined;
54
- outputs?: string[] | undefined;
55
- include_accounts?: boolean | undefined;
56
- after?: string | undefined;
57
- include_boot_contracts?: boolean | undefined;
58
- watch_folders?: string[] | undefined;
59
- } | undefined;
60
- esm?: {
61
- output?: string | undefined;
62
- outputs?: string[] | undefined;
63
- include_accounts?: boolean | undefined;
64
- after?: string | undefined;
65
- include_boot_contracts?: boolean | undefined;
66
- watch_folders?: string[] | undefined;
67
- } | undefined;
68
- docs?: {
69
- output?: string | undefined;
70
- outputs?: string[] | undefined;
71
- exclude?: string[] | undefined;
72
- after?: string | undefined;
73
- } | undefined;
50
+ ESM = "types",
51
+ ESM_OLD = "esm",
52
+ Docs = "docs",
53
+ }
54
+ declare const ConfigFile: arktype_internal_variants_object_ts0.ObjectType<{
55
+ clarinet: string;
56
+ types?: {
57
+ output?: string | undefined;
58
+ outputs?: string[] | undefined;
59
+ include_accounts?: boolean | undefined;
60
+ after?: string | undefined;
61
+ include_boot_contracts?: boolean | undefined;
62
+ watch_folders?: string[] | undefined;
63
+ } | undefined;
64
+ esm?: {
65
+ output?: string | undefined;
66
+ outputs?: string[] | undefined;
67
+ include_accounts?: boolean | undefined;
68
+ after?: string | undefined;
69
+ include_boot_contracts?: boolean | undefined;
70
+ watch_folders?: string[] | undefined;
71
+ } | undefined;
72
+ docs?: {
73
+ output?: string | undefined;
74
+ outputs?: string[] | undefined;
75
+ exclude?: string[] | undefined;
76
+ after?: string | undefined;
77
+ } | undefined;
74
78
  }, {}>;
75
79
  type ConfigFile = typeof ConfigFile.infer;
76
80
  declare const defaultConfigFile: ConfigFile;
77
81
  declare class Config {
78
- configFile: ConfigFile;
79
- clarinet: ClarinetConfig;
80
- cwd: string;
81
- constructor(config: ConfigFile, clarinet: ClarinetConfig, cwd?: string);
82
- static load(cwd?: string): Promise<Config>;
83
- getOutputs(type: OutputType): string[];
84
- outputResolve(type: OutputType, filePath?: string): string[] | null;
85
- writeOutput(type: OutputType, contents: string, filePath?: string): Promise<string[] | null>;
86
- supports(type: OutputType): boolean;
87
- type(type: OutputType): {
88
- output?: string | undefined;
89
- outputs?: string[] | undefined;
90
- include_accounts?: boolean | undefined;
91
- after?: string | undefined;
92
- include_boot_contracts?: boolean | undefined;
93
- watch_folders?: string[] | undefined;
94
- } | {
95
- output?: string | undefined;
96
- outputs?: string[] | undefined;
97
- exclude?: string[] | undefined;
98
- after?: string | undefined;
99
- } | undefined;
100
- get esm(): {
101
- output?: string | undefined;
102
- outputs?: string[] | undefined;
103
- include_accounts?: boolean | undefined;
104
- after?: string | undefined;
105
- include_boot_contracts?: boolean | undefined;
106
- watch_folders?: string[] | undefined;
107
- } | undefined;
108
- get docs(): {
109
- output?: string | undefined;
110
- outputs?: string[] | undefined;
111
- exclude?: string[] | undefined;
112
- after?: string | undefined;
113
- } | undefined;
114
- clarinetFile(): string;
115
- joinFromClarinet(filePath: string): string;
82
+ configFile: ConfigFile;
83
+ clarinet: ClarinetConfig;
84
+ cwd: string;
85
+ constructor(config: ConfigFile, clarinet: ClarinetConfig, cwd?: string);
86
+ static load(cwd?: string): Promise<Config>;
87
+ getOutputs(type: OutputType): string[];
88
+ outputResolve(type: OutputType, filePath?: string): string[] | null;
89
+ writeOutput(type: OutputType, contents: string, filePath?: string): Promise<string[] | null>;
90
+ supports(type: OutputType): boolean;
91
+ type(type: OutputType): {
92
+ output?: string | undefined;
93
+ outputs?: string[] | undefined;
94
+ include_accounts?: boolean | undefined;
95
+ after?: string | undefined;
96
+ include_boot_contracts?: boolean | undefined;
97
+ watch_folders?: string[] | undefined;
98
+ } | {
99
+ output?: string | undefined;
100
+ outputs?: string[] | undefined;
101
+ exclude?: string[] | undefined;
102
+ after?: string | undefined;
103
+ } | undefined;
104
+ get esm(): {
105
+ output?: string | undefined;
106
+ outputs?: string[] | undefined;
107
+ include_accounts?: boolean | undefined;
108
+ after?: string | undefined;
109
+ include_boot_contracts?: boolean | undefined;
110
+ watch_folders?: string[] | undefined;
111
+ } | undefined;
112
+ get docs(): {
113
+ output?: string | undefined;
114
+ outputs?: string[] | undefined;
115
+ exclude?: string[] | undefined;
116
+ after?: string | undefined;
117
+ } | undefined;
118
+ clarinetFile(): string;
119
+ joinFromClarinet(filePath: string): string;
116
120
  }
117
121
  declare function configFilePath(cwd?: string): string;
118
122
  declare function saveConfig(config: ConfigFile): Promise<void>;
119
123
  declare function getConfig(cwd?: string): Promise<ConfigFile>;
120
-
124
+ //#endregion
125
+ //#region src/docs/index.d.ts
121
126
  declare const FN_TYPES: readonly ["read-only", "public", "private"];
122
127
  declare const VAR_TYPES: readonly ["map", "data-var", "constant"];
123
128
  type ClarityAbiItem = ClarityAbiFunction | ClarityAbiMap | ClarityAbiVariable;
124
129
  type ClaridocItemType<T extends ClarityAbiItem> = {
125
- abi: T;
126
- comments: Comments;
127
- startLine: number;
128
- source: string[];
130
+ abi: T;
131
+ comments: Comments;
132
+ startLine: number;
133
+ source: string[];
129
134
  };
130
135
  type ClaridocFunction = ClaridocItemType<ClarityAbiFunction>;
131
136
  type ClaridocMap = ClaridocItemType<ClarityAbiMap>;
132
137
  type ClaridocVariable = ClaridocItemType<ClarityAbiVariable>;
133
138
  interface ClaridocItem {
134
- abi: ClarityAbiItem;
135
- comments: Comments;
136
- startLine: number;
137
- source: string[];
139
+ abi: ClarityAbiItem;
140
+ comments: Comments;
141
+ startLine: number;
142
+ source: string[];
138
143
  }
139
144
  interface Comments {
140
- params: Record<string, ClaridocParam>;
141
- text: string[];
145
+ params: Record<string, ClaridocParam>;
146
+ text: string[];
142
147
  }
143
148
  interface ClaridocContract {
144
- functions: ClaridocFunction[];
145
- maps: ClaridocMap[];
146
- variables: ClaridocVariable[];
147
- comments: string[];
149
+ functions: ClaridocFunction[];
150
+ maps: ClaridocMap[];
151
+ variables: ClaridocVariable[];
152
+ comments: string[];
148
153
  }
149
154
  interface ClaridocParam {
150
- abi: ClarityAbiArg;
151
- comments: string[];
152
- }
153
- declare function createContractDocInfo({ contractSrc, abi, }: {
154
- contractSrc: string;
155
- abi: ClarityAbi;
155
+ abi: ClarityAbiArg;
156
+ comments: string[];
157
+ }
158
+ declare function createContractDocInfo({
159
+ contractSrc,
160
+ abi
161
+ }: {
162
+ contractSrc: string;
163
+ abi: ClarityAbi;
156
164
  }): ClaridocContract;
157
165
  declare function isComment(line: string): boolean;
158
166
  declare function getFnName(line: string): string | undefined;
159
167
  declare function traceParens(line: string, count: number): number;
160
168
  declare function parseComments(comments: string[], abi: ClarityAbiItem): Comments;
161
169
  declare function afterDocs(config: Config): Promise<void>;
162
-
163
- declare function generateMarkdown({ contract, contractFile, withToc, }: {
164
- contract: SessionContract;
165
- contractFile?: string;
166
- withToc?: boolean;
170
+ //#endregion
171
+ //#region src/docs/markdown.d.ts
172
+ declare function generateMarkdown({
173
+ contract,
174
+ contractFile,
175
+ withToc
176
+ }: {
177
+ contract: SessionContract;
178
+ contractFile?: string;
179
+ withToc?: boolean;
167
180
  }): string;
168
181
  declare function markdownFunction(fn: ClaridocFunction, contractFile?: string): string;
169
182
  declare function generateReadme(session: Session, excluded: Record<string, boolean>): string;
170
-
171
- declare function generateDocs({ session, config, }: {
172
- session: SessionWithVariables;
173
- config: Config;
183
+ //#endregion
184
+ //#region src/files/docs.d.ts
185
+ declare function generateDocs({
186
+ session,
187
+ config
188
+ }: {
189
+ session: SessionWithVariables;
190
+ config: Config;
174
191
  }): Promise<void>;
175
-
192
+ //#endregion
193
+ //#region src/files/variables.d.ts
176
194
  declare function getVariablesV2(contract: SessionContract, simnet: Simnet, verbose?: boolean): any;
177
195
  declare function mapVariables(session: Session, simnet: Simnet): string[];
178
-
196
+ //#endregion
197
+ //#region src/files/base.d.ts
179
198
  declare function generateContractMeta(contract: SessionContract, constants: string): string;
180
199
  declare const TYPE_IMPORTS = "import type { TypedAbiArg, TypedAbiFunction, TypedAbiMap, TypedAbiVariable, Response } from '@clarigen/core';";
181
200
  declare function generateBaseFile(session: SessionWithVariables): string;
182
201
  declare function encodeVariables(variables: ClarityAbiVariable[]): string[];
183
202
  declare global {
184
- interface Uint8Array {
185
- [inspect.custom](depth: number, options: InspectOptions): string;
186
- }
203
+ interface Uint8Array {
204
+ [inspect.custom](depth: number, options: InspectOptions): string;
205
+ }
187
206
  }
188
207
  declare function serialize(obj: any): string;
189
-
190
- interface EmulatedContractPublishTransaction {
191
- 'emulated-contract-publish': {
192
- 'contract-name': string;
193
- 'emulated-sender': string;
194
- path: string;
195
- };
196
- }
197
- interface RequirementPublishTransaction {
198
- 'requirement-publish': {
199
- 'contract-id': string;
200
- 'remap-sender': string;
201
- 'remap-principals': Record<string, string>;
202
- path: string;
203
- };
204
- }
205
- interface ContractPublishTransaction {
206
- 'contract-publish': {
207
- 'contract-name': string;
208
- 'expected-sender': string;
209
- path: string;
210
- };
211
- }
212
- interface ContractCallTransaction {
213
- 'contract-call': {
214
- 'contract-id': string;
215
- 'expected-sender': string;
216
- parameters: Readonly<string[]>;
217
- method: string;
218
- };
219
- }
220
- interface EmulatedContractCallTransaction {
221
- 'emulated-contract-call': {
222
- 'contract-id': string;
223
- 'emulated-sender': string;
224
- parameters: Readonly<string[]>;
225
- method: string;
226
- };
227
- }
228
- interface BtcTransferTransaction {
229
- 'btc-transfer': {
230
- 'expected-sender': string;
231
- recipient: string;
232
- 'sats-per-byte': string;
233
- 'sats-amount': string;
234
- };
235
- }
236
- type Transaction = EmulatedContractPublishTransaction | RequirementPublishTransaction | ContractPublishTransaction | EmulatedContractCallTransaction | BtcTransferTransaction | ContractCallTransaction;
237
- type ContractTransaction = EmulatedContractPublishTransaction | RequirementPublishTransaction | ContractPublishTransaction;
238
- interface Batch<T extends Transaction> {
239
- id: number;
240
- transactions: Readonly<T[]>;
241
- }
242
- interface SimnetAccount {
243
- address: string;
244
- name: string;
245
- balance: string;
246
- }
247
- interface SimnetAccountDeployer extends SimnetAccount {
248
- name: 'deployer';
249
- }
250
- interface SimnetDeploymentPlan {
251
- network: 'simnet';
252
- genesis: {
253
- wallets: Readonly<[SimnetAccountDeployer, ...SimnetAccount[]]>;
254
- contracts: Readonly<string[]>;
255
- };
256
- plan: {
257
- batches: Readonly<Batch<EmulatedContractPublishTransaction | EmulatedContractCallTransaction>[]>;
258
- };
259
- }
260
- interface DevnetDeploymentPlan {
261
- network: 'devnet';
262
- plan: {
263
- batches: Readonly<Batch<RequirementPublishTransaction | ContractPublishTransaction | ContractCallTransaction | BtcTransferTransaction>[]>;
264
- };
265
- }
266
- type TestnetDeploymentPlan = Omit<DevnetDeploymentPlan, 'network'> & {
267
- network: 'testnet';
268
- };
269
- interface MainnetDeploymentPlan {
270
- network: 'mainnet';
271
- plan: {
272
- batches: Readonly<Batch<ContractPublishTransaction | ContractCallTransaction | BtcTransferTransaction>[]>;
273
- };
274
- }
275
- type DeploymentPlan = SimnetDeploymentPlan | DevnetDeploymentPlan | TestnetDeploymentPlan | MainnetDeploymentPlan;
276
- declare function flatBatch<T extends Transaction>(batches: Batch<T>[]): T[];
277
- declare function getContractTxs(batches: Batch<Transaction>[]): ContractTransaction[];
278
- declare function getDeploymentContract(contractName: string, deployment: DeploymentPlan): ContractTransaction;
279
- declare function getDeploymentTxPath(tx: ContractTransaction): string;
280
- declare function getIdentifier(tx: ContractTransaction): string;
281
- declare function isContractTx(tx: Transaction): tx is ContractTransaction;
282
-
208
+ //#endregion
209
+ //#region src/files/esm.d.ts
283
210
  declare function parseDeployment(path: string): Promise<Plan>;
284
211
  declare const DEPLOYMENT_NETWORKS: readonly ["devnet", "simnet", "testnet", "mainnet"];
285
212
  type DeploymentNetwork = (typeof DEPLOYMENT_NETWORKS)[number];
286
213
  type Plan = DeploymentPlan | undefined;
287
- type DeploymentsMap = {
288
- [key in DeploymentNetwork]: Plan;
289
- };
214
+ type DeploymentsMap = { [key in DeploymentNetwork]: Plan };
290
215
  declare function getDeployments(config: Config): Promise<DeploymentsMap>;
291
- declare function generateESMFile({ baseFile, session, config, }: {
292
- baseFile: string;
293
- session: Session;
294
- config: Config;
216
+ declare function generateESMFile({
217
+ baseFile,
218
+ session,
219
+ config
220
+ }: {
221
+ baseFile: string;
222
+ session: Session;
223
+ config: Config;
295
224
  }): Promise<string>;
296
- type ContractDeployments = {
297
- [key in DeploymentNetwork]: string | null;
298
- };
225
+ type ContractDeployments = { [key in DeploymentNetwork]: string | null };
299
226
  type FullContractDeployments = {
300
- [contractName: string]: ContractDeployments;
227
+ [contractName: string]: ContractDeployments;
301
228
  };
302
229
  declare function collectContractDeployments(session: Session, deployments: DeploymentsMap, config: Config): FullContractDeployments;
303
230
  declare function collectDeploymentFiles(deployments: DeploymentsMap, clarinetFolder: string, cwd: string): {
304
- identifier: string;
305
- file: string;
231
+ identifier: string;
232
+ file: string;
306
233
  }[];
307
234
  declare function afterESM(config: Config): Promise<void>;
308
-
235
+ //#endregion
236
+ //#region src/declaration.d.ts
309
237
  declare const jsTypeFromAbiType: (val: ClarityAbiType, isArgument?: boolean) => string;
310
238
  declare function abiArgType(arg: ClarityAbiArg): string;
311
239
  declare function abiFunctionType(abiFunction: ClarityAbiFunction): string;
312
240
  declare function getArgName(name: string): string;
313
-
241
+ //#endregion
242
+ //#region src/utils.d.ts
314
243
  declare function encodeVariableName(name: string): string;
315
244
  declare function fileExists(filename: string): Promise<boolean>;
316
245
  declare function writeFile(path: string, contents: string): Promise<string>;
317
246
  declare function cwdRelative(path: string): string;
318
247
  declare function sortContracts<T extends {
319
- contract_id: string;
248
+ contract_id: string;
320
249
  }>(contracts: T[]): T[];
321
-
322
- export { type Batch, CONFIG_FILE, type ClaridocContract, type ClaridocFunction, type ClaridocItem, type ClaridocMap, type ClaridocParam, type ClaridocVariable, ClarinetConfig, type Comments, Config, ConfigFile, type ContractDeployments, type ContractTransaction, DEPLOYMENT_NETWORKS, type DeploymentNetwork, type DeploymentPlan, type DevnetDeploymentPlan, type EpochType, FN_TYPES, type FullContractDeployments, type MainnetDeploymentPlan, OutputType, type Session, type SessionAccount, type SessionContract, type SessionWithVariables, type SimnetAccountDeployer, type SimnetDeploymentPlan, TYPE_IMPORTS, type TestnetDeploymentPlan, type Transaction, VAR_TYPES, abiArgType, abiFunctionType, afterDocs, afterESM, collectContractDeployments, collectDeploymentFiles, configFilePath, createContractDocInfo, cwdRelative, defaultConfigFile, encodeVariableName, encodeVariables, fileExists, flatBatch, generateBaseFile, generateContractMeta, generateDocs, generateESMFile, generateMarkdown, generateReadme, getArgName, getClarinetConfig, getConfig, getContractTxs, getDeploymentContract, getDeploymentTxPath, getDeployments, getFnName, getIdentifier, getVariablesV2, isComment, isContractTx, jsTypeFromAbiType, mapVariables, markdownFunction, parseComments, parseDeployment, saveConfig, serialize, sortContracts, traceParens, writeFile };
250
+ //#endregion
251
+ export { CONFIG_FILE, ClaridocContract, ClaridocFunction, ClaridocItem, ClaridocMap, ClaridocParam, ClaridocVariable, ClarinetConfig, Comments, Config, ConfigFile, ContractDeployments, DEPLOYMENT_NETWORKS, DeploymentNetwork, EpochType, FN_TYPES, FullContractDeployments, OutputType, Session, SessionAccount, SessionContract, SessionWithVariables, TYPE_IMPORTS, VAR_TYPES, abiArgType, abiFunctionType, afterDocs, afterESM, collectContractDeployments, collectDeploymentFiles, configFilePath, createContractDocInfo, cwdRelative, defaultConfigFile, encodeVariableName, encodeVariables, fileExists, generateBaseFile, generateContractMeta, generateDocs, generateESMFile, generateMarkdown, generateReadme, getArgName, getClarinetConfig, getConfig, getDeployments, getFnName, getVariablesV2, isComment, jsTypeFromAbiType, mapVariables, markdownFunction, parseComments, parseDeployment, saveConfig, serialize, sortContracts, traceParens, writeFile };
252
+ //# sourceMappingURL=index.d.cts.map