@algorandfoundation/algokit-client-generator 2.6.0 → 2.6.1-beta.1
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/bin/cli.mjs +4 -0
- package/cli.cjs +75 -0
- package/cli.d.ts +0 -1
- package/cli.mjs +54 -0
- package/client/app-types.cjs +152 -0
- package/client/app-types.d.ts +0 -1
- package/client/app-types.mjs +131 -0
- package/client/call-client.cjs +332 -0
- package/client/call-client.d.ts +0 -1
- package/client/{call-client.js → call-client.mjs} +107 -135
- package/client/call-composer-types.cjs +141 -0
- package/client/call-composer-types.d.ts +0 -1
- package/client/{call-composer-types.js → call-composer-types.mjs} +33 -58
- package/client/call-composer.cjs +145 -0
- package/client/call-composer.d.ts +0 -1
- package/client/call-composer.mjs +124 -0
- package/client/call-factory.cjs +138 -0
- package/client/call-factory.d.ts +0 -1
- package/client/{call-factory.js → call-factory.mjs} +31 -56
- package/client/deploy-types.cjs +94 -0
- package/client/deploy-types.d.ts +0 -1
- package/client/deploy-types.mjs +91 -0
- package/client/generate.cjs +37 -0
- package/client/generate.d.ts +0 -1
- package/client/generate.mjs +35 -0
- package/client/generator-context.cjs +37 -0
- package/client/generator-context.d.ts +0 -1
- package/client/generator-context.mjs +16 -0
- package/client/helpers/{get-call-config-summary.js → get-call-config-summary.cjs} +7 -25
- package/client/helpers/get-call-config-summary.d.ts +1 -2
- package/client/helpers/get-call-config-summary.mjs +54 -0
- package/client/helpers/{get-equivalent-type.js → get-equivalent-type.cjs} +20 -20
- package/client/helpers/get-equivalent-type.d.ts +0 -1
- package/client/helpers/get-equivalent-type.mjs +56 -0
- package/client/{imports.js → imports.cjs} +3 -4
- package/client/imports.d.ts +0 -1
- package/client/imports.mjs +27 -0
- package/client/{utility-types.js → utility-types.cjs} +26 -25
- package/client/utility-types.d.ts +0 -1
- package/client/utility-types.mjs +47 -0
- package/dev.d.ts +0 -1
- package/index.cjs +13 -0
- package/index.d.ts +0 -1
- package/index.mjs +3 -0
- package/output/{writer.js → writer.cjs} +44 -38
- package/output/writer.d.ts +0 -1
- package/output/writer.mjs +139 -0
- package/package.json +7 -4
- package/schema/application.schema.json.cjs +374 -0
- package/schema/application.schema.json.mjs +363 -0
- package/schema/contract.schema.json.cjs +159 -0
- package/schema/contract.schema.json.mjs +148 -0
- package/schema/load.cjs +25 -0
- package/schema/load.d.ts +0 -1
- package/schema/load.mjs +22 -0
- package/tests/approval-tests.spec.d.ts +0 -1
- package/tests/util.d.ts +1 -0
- package/util/boom.cjs +7 -0
- package/util/boom.d.ts +0 -1
- package/util/boom.mjs +5 -0
- package/util/color-console.cjs +18 -0
- package/util/color-console.d.ts +0 -1
- package/util/color-console.mjs +16 -0
- package/util/not-falsy.d.ts +0 -1
- package/util/sanitization.cjs +17 -0
- package/util/sanitization.d.ts +0 -1
- package/util/sanitization.mjs +11 -0
- package/bin/cli.js +0 -4
- package/cli.d.ts.map +0 -1
- package/cli.js +0 -79
- package/cli.js.map +0 -1
- package/client/app-types.d.ts.map +0 -1
- package/client/app-types.js +0 -161
- package/client/app-types.js.map +0 -1
- package/client/call-client.d.ts.map +0 -1
- package/client/call-client.js.map +0 -1
- package/client/call-composer-types.d.ts.map +0 -1
- package/client/call-composer-types.js.map +0 -1
- package/client/call-composer.d.ts.map +0 -1
- package/client/call-composer.js +0 -151
- package/client/call-composer.js.map +0 -1
- package/client/call-factory.d.ts.map +0 -1
- package/client/call-factory.js.map +0 -1
- package/client/deploy-types.d.ts.map +0 -1
- package/client/deploy-types.js +0 -95
- package/client/deploy-types.js.map +0 -1
- package/client/generate.d.ts.map +0 -1
- package/client/generate.js +0 -37
- package/client/generate.js.map +0 -1
- package/client/generator-context.d.ts.map +0 -1
- package/client/generator-context.js +0 -41
- package/client/generator-context.js.map +0 -1
- package/client/helpers/get-call-config-summary.d.ts.map +0 -1
- package/client/helpers/get-call-config-summary.js.map +0 -1
- package/client/helpers/get-equivalent-type.d.ts.map +0 -1
- package/client/helpers/get-equivalent-type.js.map +0 -1
- package/client/imports.d.ts.map +0 -1
- package/client/imports.js.map +0 -1
- package/client/utility-types.d.ts.map +0 -1
- package/client/utility-types.js.map +0 -1
- package/dev.d.ts.map +0 -1
- package/dev.js +0 -5
- package/dev.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js +0 -12
- package/index.js.map +0 -1
- package/output/writer.d.ts.map +0 -1
- package/output/writer.js.map +0 -1
- package/schema/application.schema.json +0 -354
- package/schema/contract.schema.json +0 -139
- package/schema/load.d.ts.map +0 -1
- package/schema/load.js +0 -51
- package/schema/load.js.map +0 -1
- package/tests/approval-tests.spec.d.ts.map +0 -1
- package/tests/approval-tests.spec.js +0 -24
- package/tests/approval-tests.spec.js.map +0 -1
- package/util/boom.d.ts.map +0 -1
- package/util/boom.js +0 -8
- package/util/boom.js.map +0 -1
- package/util/color-console.d.ts.map +0 -1
- package/util/color-console.js +0 -20
- package/util/color-console.js.map +0 -1
- package/util/not-falsy.d.ts.map +0 -1
- package/util/not-falsy.js +0 -6
- package/util/not-falsy.js.map +0 -1
- package/util/sanitization.d.ts.map +0 -1
- package/util/sanitization.js +0 -17
- package/util/sanitization.js.map +0 -1
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var algosdk = require('algosdk');
|
|
4
|
+
|
|
5
5
|
function getEquivalentType(abiTypeStr, ioType) {
|
|
6
6
|
if (abiTypeStr == 'void') {
|
|
7
7
|
return 'void';
|
|
8
8
|
}
|
|
9
|
-
if (
|
|
9
|
+
if (algosdk.abiTypeIsTransaction(abiTypeStr)) {
|
|
10
10
|
return 'TransactionToSign | Transaction | Promise<SendTransactionResult>';
|
|
11
11
|
}
|
|
12
|
-
if (abiTypeStr ==
|
|
12
|
+
if (abiTypeStr == algosdk.ABIReferenceType.account) {
|
|
13
13
|
return 'string | Uint8Array';
|
|
14
14
|
}
|
|
15
|
-
if (abiTypeStr ==
|
|
15
|
+
if (abiTypeStr == algosdk.ABIReferenceType.application || abiTypeStr == algosdk.ABIReferenceType.asset) {
|
|
16
16
|
return 'number | bigint';
|
|
17
17
|
}
|
|
18
|
-
const abiType =
|
|
18
|
+
const abiType = algosdk.ABIType.from(abiTypeStr);
|
|
19
19
|
return abiTypeToTs(abiType, ioType);
|
|
20
20
|
function abiTypeToTs(abiType, ioType) {
|
|
21
|
-
if (abiType instanceof
|
|
21
|
+
if (abiType instanceof algosdk.ABIUintType) {
|
|
22
22
|
if (abiType.bitSize <= 51)
|
|
23
23
|
return 'number';
|
|
24
24
|
return ioType === 'input' ? 'bigint | number' : 'bigint';
|
|
25
25
|
}
|
|
26
|
-
if (abiType instanceof
|
|
27
|
-
if (abiType.childType instanceof
|
|
26
|
+
if (abiType instanceof algosdk.ABIArrayDynamicType) {
|
|
27
|
+
if (abiType.childType instanceof algosdk.ABIByteType)
|
|
28
28
|
return 'Uint8Array';
|
|
29
29
|
return `${abiTypeToTs(abiType.childType, ioType)}[]`;
|
|
30
30
|
}
|
|
31
|
-
if (abiType instanceof
|
|
32
|
-
if (abiType.childType instanceof
|
|
31
|
+
if (abiType instanceof algosdk.ABIArrayStaticType) {
|
|
32
|
+
if (abiType.childType instanceof algosdk.ABIByteType)
|
|
33
33
|
return 'Uint8Array';
|
|
34
34
|
return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`;
|
|
35
35
|
}
|
|
36
|
-
if (abiType instanceof
|
|
36
|
+
if (abiType instanceof algosdk.ABIAddressType) {
|
|
37
37
|
return 'string';
|
|
38
38
|
}
|
|
39
|
-
if (abiType instanceof
|
|
39
|
+
if (abiType instanceof algosdk.ABIBoolType) {
|
|
40
40
|
return 'boolean';
|
|
41
41
|
}
|
|
42
|
-
if (abiType instanceof
|
|
42
|
+
if (abiType instanceof algosdk.ABIUfixedType) {
|
|
43
43
|
return 'number';
|
|
44
44
|
}
|
|
45
|
-
if (abiType instanceof
|
|
45
|
+
if (abiType instanceof algosdk.ABITupleType) {
|
|
46
46
|
return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`;
|
|
47
47
|
}
|
|
48
|
-
if (abiType instanceof
|
|
48
|
+
if (abiType instanceof algosdk.ABIByteType) {
|
|
49
49
|
return 'number';
|
|
50
50
|
}
|
|
51
|
-
if (abiType instanceof
|
|
51
|
+
if (abiType instanceof algosdk.ABIStringType) {
|
|
52
52
|
return 'string';
|
|
53
53
|
}
|
|
54
54
|
return 'unknown';
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
|
|
57
58
|
exports.getEquivalentType = getEquivalentType;
|
|
58
|
-
//# sourceMappingURL=get-equivalent-type.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { abiTypeIsTransaction, ABIReferenceType, ABIType, ABIUintType, ABIArrayDynamicType, ABIByteType, ABIArrayStaticType, ABIAddressType, ABIBoolType, ABIUfixedType, ABITupleType, ABIStringType } from 'algosdk';
|
|
2
|
+
|
|
3
|
+
function getEquivalentType(abiTypeStr, ioType) {
|
|
4
|
+
if (abiTypeStr == 'void') {
|
|
5
|
+
return 'void';
|
|
6
|
+
}
|
|
7
|
+
if (abiTypeIsTransaction(abiTypeStr)) {
|
|
8
|
+
return 'TransactionToSign | Transaction | Promise<SendTransactionResult>';
|
|
9
|
+
}
|
|
10
|
+
if (abiTypeStr == ABIReferenceType.account) {
|
|
11
|
+
return 'string | Uint8Array';
|
|
12
|
+
}
|
|
13
|
+
if (abiTypeStr == ABIReferenceType.application || abiTypeStr == ABIReferenceType.asset) {
|
|
14
|
+
return 'number | bigint';
|
|
15
|
+
}
|
|
16
|
+
const abiType = ABIType.from(abiTypeStr);
|
|
17
|
+
return abiTypeToTs(abiType, ioType);
|
|
18
|
+
function abiTypeToTs(abiType, ioType) {
|
|
19
|
+
if (abiType instanceof ABIUintType) {
|
|
20
|
+
if (abiType.bitSize <= 51)
|
|
21
|
+
return 'number';
|
|
22
|
+
return ioType === 'input' ? 'bigint | number' : 'bigint';
|
|
23
|
+
}
|
|
24
|
+
if (abiType instanceof ABIArrayDynamicType) {
|
|
25
|
+
if (abiType.childType instanceof ABIByteType)
|
|
26
|
+
return 'Uint8Array';
|
|
27
|
+
return `${abiTypeToTs(abiType.childType, ioType)}[]`;
|
|
28
|
+
}
|
|
29
|
+
if (abiType instanceof ABIArrayStaticType) {
|
|
30
|
+
if (abiType.childType instanceof ABIByteType)
|
|
31
|
+
return 'Uint8Array';
|
|
32
|
+
return `[${new Array(abiType.staticLength).fill(abiTypeToTs(abiType.childType, ioType)).join(', ')}]`;
|
|
33
|
+
}
|
|
34
|
+
if (abiType instanceof ABIAddressType) {
|
|
35
|
+
return 'string';
|
|
36
|
+
}
|
|
37
|
+
if (abiType instanceof ABIBoolType) {
|
|
38
|
+
return 'boolean';
|
|
39
|
+
}
|
|
40
|
+
if (abiType instanceof ABIUfixedType) {
|
|
41
|
+
return 'number';
|
|
42
|
+
}
|
|
43
|
+
if (abiType instanceof ABITupleType) {
|
|
44
|
+
return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType)).join(', ')}]`;
|
|
45
|
+
}
|
|
46
|
+
if (abiType instanceof ABIByteType) {
|
|
47
|
+
return 'number';
|
|
48
|
+
}
|
|
49
|
+
if (abiType instanceof ABIStringType) {
|
|
50
|
+
return 'string';
|
|
51
|
+
}
|
|
52
|
+
return 'unknown';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { getEquivalentType };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.imports = void 0;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
function* imports() {
|
|
5
4
|
yield `import * as algokit from '@algorandfoundation/algokit-utils'
|
|
6
5
|
import type {
|
|
@@ -26,5 +25,5 @@ import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, Sen
|
|
|
26
25
|
import type { ABIResult, TransactionWithSigner } from 'algosdk'
|
|
27
26
|
import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk'`;
|
|
28
27
|
}
|
|
28
|
+
|
|
29
29
|
exports.imports = imports;
|
|
30
|
-
//# sourceMappingURL=imports.js.map
|
package/client/imports.d.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function* imports() {
|
|
2
|
+
yield `import * as algokit from '@algorandfoundation/algokit-utils'
|
|
3
|
+
import type {
|
|
4
|
+
ABIAppCallArg,
|
|
5
|
+
AppCallTransactionResult,
|
|
6
|
+
AppCallTransactionResultOfType,
|
|
7
|
+
AppCompilationResult,
|
|
8
|
+
AppReference,
|
|
9
|
+
AppState,
|
|
10
|
+
CoreAppCallArgs,
|
|
11
|
+
RawAppCallArgs,
|
|
12
|
+
TealTemplateParams,
|
|
13
|
+
} from '@algorandfoundation/algokit-utils/types/app'
|
|
14
|
+
import type {
|
|
15
|
+
AppClientCallCoreParams,
|
|
16
|
+
AppClientCompilationParams,
|
|
17
|
+
AppClientDeployCoreParams,
|
|
18
|
+
AppDetails,
|
|
19
|
+
ApplicationClient,
|
|
20
|
+
} from '@algorandfoundation/algokit-utils/types/app-client'
|
|
21
|
+
import type { AppSpec } from '@algorandfoundation/algokit-utils/types/app-spec'
|
|
22
|
+
import type { SendTransactionResult, TransactionToSign, SendTransactionFrom, SendTransactionParams } from '@algorandfoundation/algokit-utils/types/transaction'
|
|
23
|
+
import type { ABIResult, TransactionWithSigner } from 'algosdk'
|
|
24
|
+
import { Algodv2, OnApplicationComplete, Transaction, AtomicTransactionComposer, modelsv2 } from 'algosdk'`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { imports };
|
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var writer = require('../output/writer.cjs');
|
|
4
|
+
|
|
5
5
|
function* utilityTypes() {
|
|
6
|
-
yield*
|
|
6
|
+
yield* writer.jsDoc(`Defines an onCompletionAction of 'no_op'`);
|
|
7
7
|
yield `export type OnCompleteNoOp = { onCompleteAction?: 'no_op' | OnApplicationComplete.NoOpOC }`;
|
|
8
|
-
yield*
|
|
8
|
+
yield* writer.jsDoc(`Defines an onCompletionAction of 'opt_in'`);
|
|
9
9
|
yield `export type OnCompleteOptIn = { onCompleteAction: 'opt_in' | OnApplicationComplete.OptInOC }`;
|
|
10
|
-
yield*
|
|
10
|
+
yield* writer.jsDoc(`Defines an onCompletionAction of 'close_out'`);
|
|
11
11
|
yield `export type OnCompleteCloseOut = { onCompleteAction: 'close_out' | OnApplicationComplete.CloseOutOC }`;
|
|
12
|
-
yield*
|
|
12
|
+
yield* writer.jsDoc(`Defines an onCompletionAction of 'delete_application'`);
|
|
13
13
|
yield `export type OnCompleteDelApp = { onCompleteAction: 'delete_application' | OnApplicationComplete.DeleteApplicationOC }`;
|
|
14
|
-
yield*
|
|
14
|
+
yield* writer.jsDoc(`Defines an onCompletionAction of 'update_application'`);
|
|
15
15
|
yield `export type OnCompleteUpdApp = { onCompleteAction: 'update_application' | OnApplicationComplete.UpdateApplicationOC }`;
|
|
16
|
-
yield*
|
|
16
|
+
yield* writer.jsDoc('A state record containing a single unsigned integer');
|
|
17
17
|
yield `export type IntegerState = {`;
|
|
18
|
-
yield
|
|
19
|
-
yield*
|
|
18
|
+
yield writer.IncIndent;
|
|
19
|
+
yield* writer.jsDoc('Gets the state value as a BigInt.');
|
|
20
20
|
yield `asBigInt(): bigint`;
|
|
21
|
-
yield*
|
|
21
|
+
yield* writer.jsDoc('Gets the state value as a number.');
|
|
22
22
|
yield `asNumber(): number`;
|
|
23
|
-
yield
|
|
24
|
-
yield*
|
|
23
|
+
yield writer.DecIndentAndCloseBlock;
|
|
24
|
+
yield* writer.jsDoc('A state record containing binary data');
|
|
25
25
|
yield `export type BinaryState = {`;
|
|
26
|
-
yield
|
|
27
|
-
yield*
|
|
26
|
+
yield writer.IncIndent;
|
|
27
|
+
yield* writer.jsDoc('Gets the state value as a Uint8Array');
|
|
28
28
|
yield `asByteArray(): Uint8Array`;
|
|
29
|
-
yield*
|
|
29
|
+
yield* writer.jsDoc('Gets the state value as a string');
|
|
30
30
|
yield `asString(): string`;
|
|
31
|
-
yield
|
|
32
|
-
yield
|
|
31
|
+
yield writer.DecIndentAndCloseBlock;
|
|
32
|
+
yield writer.NewLine;
|
|
33
33
|
yield `export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult> & AppReference`;
|
|
34
34
|
yield `export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult>`;
|
|
35
|
-
yield
|
|
35
|
+
yield writer.NewLine;
|
|
36
36
|
yield `export type AppClientComposeCallCoreParams = Omit<AppClientCallCoreParams, 'sendParams'> & {`;
|
|
37
|
-
yield*
|
|
37
|
+
yield* writer.indent(`sendParams?: Omit<SendTransactionParams, 'skipSending' | 'atc' | 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources'>`);
|
|
38
38
|
yield `}`;
|
|
39
39
|
yield `export type AppClientComposeExecuteParams = Pick<SendTransactionParams, 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources' | 'suppressLog'>`;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
exports.OnCompleteCodeMap = {
|
|
41
|
+
const OnCompleteCodeMap = {
|
|
43
42
|
no_op: 'OnCompleteNoOp',
|
|
44
43
|
opt_in: 'OnCompleteOptIn',
|
|
45
44
|
close_out: 'OnCompleteCloseOut',
|
|
46
45
|
delete_application: 'OnCompleteDelApp',
|
|
47
46
|
update_application: 'OnCompleteUpdApp',
|
|
48
47
|
};
|
|
49
|
-
|
|
48
|
+
|
|
49
|
+
exports.OnCompleteCodeMap = OnCompleteCodeMap;
|
|
50
|
+
exports.utilityTypes = utilityTypes;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsDoc, IncIndent, DecIndentAndCloseBlock, NewLine, indent } from '../output/writer.mjs';
|
|
2
|
+
|
|
3
|
+
function* utilityTypes() {
|
|
4
|
+
yield* jsDoc(`Defines an onCompletionAction of 'no_op'`);
|
|
5
|
+
yield `export type OnCompleteNoOp = { onCompleteAction?: 'no_op' | OnApplicationComplete.NoOpOC }`;
|
|
6
|
+
yield* jsDoc(`Defines an onCompletionAction of 'opt_in'`);
|
|
7
|
+
yield `export type OnCompleteOptIn = { onCompleteAction: 'opt_in' | OnApplicationComplete.OptInOC }`;
|
|
8
|
+
yield* jsDoc(`Defines an onCompletionAction of 'close_out'`);
|
|
9
|
+
yield `export type OnCompleteCloseOut = { onCompleteAction: 'close_out' | OnApplicationComplete.CloseOutOC }`;
|
|
10
|
+
yield* jsDoc(`Defines an onCompletionAction of 'delete_application'`);
|
|
11
|
+
yield `export type OnCompleteDelApp = { onCompleteAction: 'delete_application' | OnApplicationComplete.DeleteApplicationOC }`;
|
|
12
|
+
yield* jsDoc(`Defines an onCompletionAction of 'update_application'`);
|
|
13
|
+
yield `export type OnCompleteUpdApp = { onCompleteAction: 'update_application' | OnApplicationComplete.UpdateApplicationOC }`;
|
|
14
|
+
yield* jsDoc('A state record containing a single unsigned integer');
|
|
15
|
+
yield `export type IntegerState = {`;
|
|
16
|
+
yield IncIndent;
|
|
17
|
+
yield* jsDoc('Gets the state value as a BigInt.');
|
|
18
|
+
yield `asBigInt(): bigint`;
|
|
19
|
+
yield* jsDoc('Gets the state value as a number.');
|
|
20
|
+
yield `asNumber(): number`;
|
|
21
|
+
yield DecIndentAndCloseBlock;
|
|
22
|
+
yield* jsDoc('A state record containing binary data');
|
|
23
|
+
yield `export type BinaryState = {`;
|
|
24
|
+
yield IncIndent;
|
|
25
|
+
yield* jsDoc('Gets the state value as a Uint8Array');
|
|
26
|
+
yield `asByteArray(): Uint8Array`;
|
|
27
|
+
yield* jsDoc('Gets the state value as a string');
|
|
28
|
+
yield `asString(): string`;
|
|
29
|
+
yield DecIndentAndCloseBlock;
|
|
30
|
+
yield NewLine;
|
|
31
|
+
yield `export type AppCreateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult> & AppReference`;
|
|
32
|
+
yield `export type AppUpdateCallTransactionResult = AppCallTransactionResult & Partial<AppCompilationResult>`;
|
|
33
|
+
yield NewLine;
|
|
34
|
+
yield `export type AppClientComposeCallCoreParams = Omit<AppClientCallCoreParams, 'sendParams'> & {`;
|
|
35
|
+
yield* indent(`sendParams?: Omit<SendTransactionParams, 'skipSending' | 'atc' | 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources'>`);
|
|
36
|
+
yield `}`;
|
|
37
|
+
yield `export type AppClientComposeExecuteParams = Pick<SendTransactionParams, 'skipWaiting' | 'maxRoundsToWaitForConfirmation' | 'populateAppCallResources' | 'suppressLog'>`;
|
|
38
|
+
}
|
|
39
|
+
const OnCompleteCodeMap = {
|
|
40
|
+
no_op: 'OnCompleteNoOp',
|
|
41
|
+
opt_in: 'OnCompleteOptIn',
|
|
42
|
+
close_out: 'OnCompleteCloseOut',
|
|
43
|
+
delete_application: 'OnCompleteDelApp',
|
|
44
|
+
update_application: 'OnCompleteUpdApp',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { OnCompleteCodeMap, utilityTypes };
|
package/dev.d.ts
CHANGED
package/index.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var load = require('./schema/load.cjs');
|
|
4
|
+
var generate = require('./client/generate.cjs');
|
|
5
|
+
var writer = require('./output/writer.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.loadApplicationJson = load.loadApplicationJson;
|
|
10
|
+
exports.validateApplicationJson = load.validateApplicationJson;
|
|
11
|
+
exports.generate = generate.generate;
|
|
12
|
+
exports.writeDocumentPartsToStream = writer.writeDocumentPartsToStream;
|
|
13
|
+
exports.writeDocumentPartsToString = writer.writeDocumentPartsToString;
|
package/index.d.ts
CHANGED
package/index.mjs
ADDED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.NewLine = Symbol('New Line');
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const IncIndent = Symbol('Increase Indent');
|
|
4
|
+
const DecIndent = Symbol('Decrease Indent');
|
|
5
|
+
const DecIndentAndCloseBlock = Symbol('Decrease Indent and write a closing brace');
|
|
6
|
+
const NewLineMode = Symbol('New Line Mode');
|
|
7
|
+
const RestoreLineMode = Symbol('Restore Line Mode');
|
|
8
|
+
const PropertyDelimiter = Symbol('Property Delimiter');
|
|
9
|
+
const InlineMode = Symbol('Inline Mode');
|
|
10
|
+
const NewLine = Symbol('New Line');
|
|
12
11
|
function writeDocumentPartsToStream(document, stream, options = {}) {
|
|
13
12
|
const writer = {
|
|
14
13
|
_last: '',
|
|
@@ -22,7 +21,6 @@ function writeDocumentPartsToStream(document, stream, options = {}) {
|
|
|
22
21
|
};
|
|
23
22
|
writeDocumentPartsTo(document, options, writer);
|
|
24
23
|
}
|
|
25
|
-
exports.writeDocumentPartsToStream = writeDocumentPartsToStream;
|
|
26
24
|
function writeDocumentPartsToString(document, options = {}) {
|
|
27
25
|
const writer = {
|
|
28
26
|
result: [],
|
|
@@ -41,31 +39,27 @@ function writeDocumentPartsToString(document, options = {}) {
|
|
|
41
39
|
writeDocumentPartsTo(document, options, writer);
|
|
42
40
|
return writer.toString();
|
|
43
41
|
}
|
|
44
|
-
exports.writeDocumentPartsToString = writeDocumentPartsToString;
|
|
45
42
|
function* inline(...parts) {
|
|
46
|
-
yield
|
|
43
|
+
yield InlineMode;
|
|
47
44
|
for (const part of parts) {
|
|
48
45
|
if (typeof part === 'string' || typeof part === 'symbol')
|
|
49
46
|
yield part;
|
|
50
47
|
else
|
|
51
48
|
yield* part;
|
|
52
49
|
}
|
|
53
|
-
yield
|
|
50
|
+
yield RestoreLineMode;
|
|
54
51
|
}
|
|
55
|
-
exports.inline = inline;
|
|
56
52
|
function* indent(...parts) {
|
|
57
|
-
yield
|
|
53
|
+
yield IncIndent;
|
|
58
54
|
for (const part of parts) {
|
|
59
55
|
if (typeof part === 'string' || typeof part === 'symbol')
|
|
60
56
|
yield part;
|
|
61
57
|
else
|
|
62
58
|
yield* part;
|
|
63
59
|
}
|
|
64
|
-
yield
|
|
60
|
+
yield DecIndent;
|
|
65
61
|
}
|
|
66
|
-
exports.indent = indent;
|
|
67
62
|
function* jsDoc(docs) {
|
|
68
|
-
var _a;
|
|
69
63
|
yield `/**`;
|
|
70
64
|
if (typeof docs === 'string') {
|
|
71
65
|
yield ` * ${docs}`;
|
|
@@ -79,7 +73,7 @@ function* jsDoc(docs) {
|
|
|
79
73
|
if (docs.params || docs.returns) {
|
|
80
74
|
yield ' *';
|
|
81
75
|
}
|
|
82
|
-
for (const [paramName, paramDesc] of Object.entries(
|
|
76
|
+
for (const [paramName, paramDesc] of Object.entries(docs.params ?? {})) {
|
|
83
77
|
yield ` * @param ${paramName} ${paramDesc}`;
|
|
84
78
|
}
|
|
85
79
|
if (docs.returns)
|
|
@@ -87,61 +81,73 @@ function* jsDoc(docs) {
|
|
|
87
81
|
}
|
|
88
82
|
yield ' */';
|
|
89
83
|
}
|
|
90
|
-
exports.jsDoc = jsDoc;
|
|
91
84
|
function writeDocumentPartsTo(document, { indent = ' ', ...options }, writer) {
|
|
92
85
|
if (options.header)
|
|
93
86
|
writer.write(`${options.header}\n`);
|
|
94
87
|
if (options.disableEslint)
|
|
95
88
|
writer.write('/* eslint-disable */\n');
|
|
96
|
-
const lineModes = [
|
|
97
|
-
const currentLineMode = () =>
|
|
89
|
+
const lineModes = [NewLineMode];
|
|
90
|
+
const currentLineMode = () => lineModes.at(-1) ?? NewLineMode;
|
|
98
91
|
let curIndent = '';
|
|
99
92
|
for (const part of document) {
|
|
100
93
|
switch (part) {
|
|
101
|
-
case
|
|
94
|
+
case IncIndent:
|
|
102
95
|
curIndent += indent;
|
|
103
96
|
break;
|
|
104
|
-
case
|
|
97
|
+
case DecIndent:
|
|
105
98
|
curIndent = curIndent.slice(0, -indent.length);
|
|
106
99
|
break;
|
|
107
|
-
case
|
|
100
|
+
case DecIndentAndCloseBlock:
|
|
108
101
|
curIndent = curIndent.slice(0, -indent.length);
|
|
109
102
|
writer.write(`${curIndent}}\n`);
|
|
110
103
|
break;
|
|
111
|
-
case
|
|
112
|
-
lineModes.push(
|
|
104
|
+
case NewLineMode:
|
|
105
|
+
lineModes.push(NewLineMode);
|
|
113
106
|
if (writer.last.slice(-1)[0] !== '\n') {
|
|
114
107
|
writer.write('\n');
|
|
115
108
|
}
|
|
116
109
|
break;
|
|
117
|
-
case
|
|
118
|
-
lineModes.push(
|
|
110
|
+
case InlineMode:
|
|
111
|
+
lineModes.push(InlineMode);
|
|
119
112
|
break;
|
|
120
|
-
case
|
|
113
|
+
case RestoreLineMode:
|
|
121
114
|
lineModes.pop();
|
|
122
|
-
if (currentLineMode() ===
|
|
115
|
+
if (currentLineMode() === NewLineMode && writer.last.slice(-1)[0] !== '\n') {
|
|
123
116
|
writer.write('\n');
|
|
124
117
|
}
|
|
125
118
|
break;
|
|
126
|
-
case
|
|
127
|
-
if (currentLineMode() ===
|
|
119
|
+
case PropertyDelimiter:
|
|
120
|
+
if (currentLineMode() === NewLineMode) {
|
|
128
121
|
writer.write('\n');
|
|
129
122
|
}
|
|
130
123
|
else {
|
|
131
124
|
writer.write(', ');
|
|
132
125
|
}
|
|
133
126
|
break;
|
|
134
|
-
case
|
|
127
|
+
case NewLine:
|
|
135
128
|
writer.write('\n');
|
|
136
129
|
break;
|
|
137
130
|
default:
|
|
138
131
|
if (writer.last.slice(-1)[0] === '\n')
|
|
139
132
|
writer.write(curIndent);
|
|
140
133
|
writer.write(part);
|
|
141
|
-
if (currentLineMode() ===
|
|
134
|
+
if (currentLineMode() === NewLineMode)
|
|
142
135
|
writer.write('\n');
|
|
143
136
|
break;
|
|
144
137
|
}
|
|
145
138
|
}
|
|
146
139
|
}
|
|
147
|
-
|
|
140
|
+
|
|
141
|
+
exports.DecIndent = DecIndent;
|
|
142
|
+
exports.DecIndentAndCloseBlock = DecIndentAndCloseBlock;
|
|
143
|
+
exports.IncIndent = IncIndent;
|
|
144
|
+
exports.InlineMode = InlineMode;
|
|
145
|
+
exports.NewLine = NewLine;
|
|
146
|
+
exports.NewLineMode = NewLineMode;
|
|
147
|
+
exports.PropertyDelimiter = PropertyDelimiter;
|
|
148
|
+
exports.RestoreLineMode = RestoreLineMode;
|
|
149
|
+
exports.indent = indent;
|
|
150
|
+
exports.inline = inline;
|
|
151
|
+
exports.jsDoc = jsDoc;
|
|
152
|
+
exports.writeDocumentPartsToStream = writeDocumentPartsToStream;
|
|
153
|
+
exports.writeDocumentPartsToString = writeDocumentPartsToString;
|
package/output/writer.d.ts
CHANGED