@algorandfoundation/algokit-client-generator 6.0.2-beta.1 → 7.0.0-alpha.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.
Files changed (156) hide show
  1. package/client/app-client-context.d.ts +122 -0
  2. package/client/deploy-types.d.ts +1 -11
  3. package/client/generate.d.ts +1 -1
  4. package/client/generator-context.d.ts +3 -5
  5. package/client/helpers/contains-non-void-method.d.ts +2 -2
  6. package/client/helpers/get-equivalent-type.d.ts +3 -5
  7. package/client/imports.d.ts +1 -2
  8. package/package.json +2 -3
  9. package/schema/load.d.ts +1 -1
  10. package/src/cli.js.map +1 -0
  11. package/src/cli.mjs.map +1 -0
  12. package/src/client/app-client-context.js +211 -0
  13. package/src/client/app-client-context.js.map +1 -0
  14. package/src/client/app-client-context.mjs +208 -0
  15. package/src/client/app-client-context.mjs.map +1 -0
  16. package/{client → src/client}/app-client.js +29 -51
  17. package/src/client/app-client.js.map +1 -0
  18. package/{client → src/client}/app-client.mjs +29 -51
  19. package/src/client/app-client.mjs.map +1 -0
  20. package/{client → src/client}/app-factory.js +23 -27
  21. package/src/client/app-factory.js.map +1 -0
  22. package/{client → src/client}/app-factory.mjs +23 -27
  23. package/src/client/app-factory.mjs.map +1 -0
  24. package/{client → src/client}/app-types.js +31 -60
  25. package/src/client/app-types.js.map +1 -0
  26. package/{client → src/client}/app-types.mjs +32 -61
  27. package/src/client/app-types.mjs.map +1 -0
  28. package/{client → src/client}/call-composer-types.js +31 -34
  29. package/src/client/call-composer-types.js.map +1 -0
  30. package/{client → src/client}/call-composer-types.mjs +31 -34
  31. package/src/client/call-composer-types.mjs.map +1 -0
  32. package/{client → src/client}/call-composer.js +24 -31
  33. package/src/client/call-composer.js.map +1 -0
  34. package/{client → src/client}/call-composer.mjs +24 -31
  35. package/src/client/call-composer.mjs.map +1 -0
  36. package/{client → src/client}/deploy-types.js +28 -53
  37. package/src/client/deploy-types.js.map +1 -0
  38. package/{client → src/client}/deploy-types.mjs +29 -52
  39. package/src/client/deploy-types.mjs.map +1 -0
  40. package/{client → src/client}/generate.js +2 -2
  41. package/src/client/generate.js.map +1 -0
  42. package/{client → src/client}/generate.mjs +2 -2
  43. package/src/client/generate.mjs.map +1 -0
  44. package/src/client/generator-context.js +24 -0
  45. package/src/client/generator-context.js.map +1 -0
  46. package/src/client/generator-context.mjs +21 -0
  47. package/src/client/generator-context.mjs.map +1 -0
  48. package/{client → src/client}/helpers/contains-non-void-method.js +3 -2
  49. package/src/client/helpers/contains-non-void-method.js.map +1 -0
  50. package/{client → src/client}/helpers/contains-non-void-method.mjs +3 -2
  51. package/src/client/helpers/contains-non-void-method.mjs.map +1 -0
  52. package/src/client/helpers/get-equivalent-type.js +80 -0
  53. package/src/client/helpers/get-equivalent-type.js.map +1 -0
  54. package/src/client/helpers/get-equivalent-type.mjs +77 -0
  55. package/src/client/helpers/get-equivalent-type.mjs.map +1 -0
  56. package/src/client/imports.js +18 -0
  57. package/src/client/imports.js.map +1 -0
  58. package/src/client/imports.mjs +16 -0
  59. package/src/client/imports.mjs.map +1 -0
  60. package/src/client/params-factory.js +125 -0
  61. package/src/client/params-factory.js.map +1 -0
  62. package/src/client/params-factory.mjs +123 -0
  63. package/src/client/params-factory.mjs.map +1 -0
  64. package/src/client/utility-types.js.map +1 -0
  65. package/src/client/utility-types.mjs.map +1 -0
  66. package/src/output/writer.js.map +1 -0
  67. package/src/output/writer.mjs.map +1 -0
  68. package/src/schema/load.js.map +1 -0
  69. package/src/schema/load.mjs.map +1 -0
  70. package/src/util/boom.js.map +1 -0
  71. package/src/util/boom.mjs.map +1 -0
  72. package/src/util/color-console.js.map +1 -0
  73. package/src/util/color-console.mjs.map +1 -0
  74. package/src/util/sanitization.js.map +1 -0
  75. package/src/util/sanitization.mjs.map +1 -0
  76. package/cli.js.map +0 -1
  77. package/cli.mjs.map +0 -1
  78. package/client/app-client.js.map +0 -1
  79. package/client/app-client.mjs.map +0 -1
  80. package/client/app-factory.js.map +0 -1
  81. package/client/app-factory.mjs.map +0 -1
  82. package/client/app-types.js.map +0 -1
  83. package/client/app-types.mjs.map +0 -1
  84. package/client/call-composer-types.js.map +0 -1
  85. package/client/call-composer-types.mjs.map +0 -1
  86. package/client/call-composer.js.map +0 -1
  87. package/client/call-composer.mjs.map +0 -1
  88. package/client/deploy-types.js.map +0 -1
  89. package/client/deploy-types.mjs.map +0 -1
  90. package/client/generate.js.map +0 -1
  91. package/client/generate.mjs.map +0 -1
  92. package/client/generator-context.js +0 -30
  93. package/client/generator-context.js.map +0 -1
  94. package/client/generator-context.mjs +0 -27
  95. package/client/generator-context.mjs.map +0 -1
  96. package/client/helpers/contains-non-void-method.js.map +0 -1
  97. package/client/helpers/contains-non-void-method.mjs.map +0 -1
  98. package/client/helpers/get-call-config-summary.d.ts +0 -19
  99. package/client/helpers/get-call-config-summary.js +0 -60
  100. package/client/helpers/get-call-config-summary.js.map +0 -1
  101. package/client/helpers/get-call-config-summary.mjs +0 -57
  102. package/client/helpers/get-call-config-summary.mjs.map +0 -1
  103. package/client/helpers/get-equivalent-type.js +0 -81
  104. package/client/helpers/get-equivalent-type.js.map +0 -1
  105. package/client/helpers/get-equivalent-type.mjs +0 -79
  106. package/client/helpers/get-equivalent-type.mjs.map +0 -1
  107. package/client/imports.js +0 -27
  108. package/client/imports.js.map +0 -1
  109. package/client/imports.mjs +0 -25
  110. package/client/imports.mjs.map +0 -1
  111. package/client/params-factory.js +0 -128
  112. package/client/params-factory.js.map +0 -1
  113. package/client/params-factory.mjs +0 -126
  114. package/client/params-factory.mjs.map +0 -1
  115. package/client/utility-types.js.map +0 -1
  116. package/client/utility-types.mjs.map +0 -1
  117. package/output/writer.js.map +0 -1
  118. package/output/writer.mjs.map +0 -1
  119. package/schema/load.js.map +0 -1
  120. package/schema/load.mjs.map +0 -1
  121. package/util/boom.js.map +0 -1
  122. package/util/boom.mjs.map +0 -1
  123. package/util/color-console.js.map +0 -1
  124. package/util/color-console.mjs.map +0 -1
  125. package/util/sanitization.js.map +0 -1
  126. package/util/sanitization.mjs.map +0 -1
  127. /package/{cli.js → src/cli.js} +0 -0
  128. /package/{cli.mjs → src/cli.mjs} +0 -0
  129. /package/{client → src/client}/utility-types.js +0 -0
  130. /package/{client → src/client}/utility-types.mjs +0 -0
  131. /package/{index.js → src/index.js} +0 -0
  132. /package/{index.js.map → src/index.js.map} +0 -0
  133. /package/{index.mjs → src/index.mjs} +0 -0
  134. /package/{index.mjs.map → src/index.mjs.map} +0 -0
  135. /package/{output → src/output}/writer.js +0 -0
  136. /package/{output → src/output}/writer.mjs +0 -0
  137. /package/{schema → src/schema}/application.schema.json.js +0 -0
  138. /package/{schema → src/schema}/application.schema.json.js.map +0 -0
  139. /package/{schema → src/schema}/application.schema.json.mjs +0 -0
  140. /package/{schema → src/schema}/application.schema.json.mjs.map +0 -0
  141. /package/{schema → src/schema}/arc56.schema.json.js +0 -0
  142. /package/{schema → src/schema}/arc56.schema.json.js.map +0 -0
  143. /package/{schema → src/schema}/arc56.schema.json.mjs +0 -0
  144. /package/{schema → src/schema}/arc56.schema.json.mjs.map +0 -0
  145. /package/{schema → src/schema}/contract.schema.json.js +0 -0
  146. /package/{schema → src/schema}/contract.schema.json.js.map +0 -0
  147. /package/{schema → src/schema}/contract.schema.json.mjs +0 -0
  148. /package/{schema → src/schema}/contract.schema.json.mjs.map +0 -0
  149. /package/{schema → src/schema}/load.js +0 -0
  150. /package/{schema → src/schema}/load.mjs +0 -0
  151. /package/{util → src/util}/boom.js +0 -0
  152. /package/{util → src/util}/boom.mjs +0 -0
  153. /package/{util → src/util}/color-console.js +0 -0
  154. /package/{util → src/util}/color-console.mjs +0 -0
  155. /package/{util → src/util}/sanitization.js +0 -0
  156. /package/{util → src/util}/sanitization.mjs +0 -0
@@ -0,0 +1,77 @@
1
+ import { argTypeIsTransaction, ABIReferenceType, ABIStructType, ABIUintType, ABIArrayDynamicType, ABIByteType, ABIArrayStaticType, ABIAddressType, ABIBoolType, ABIUfixedType, ABITupleType, ABIStringType } from '@algorandfoundation/algokit-utils/abi';
2
+
3
+ const bigIntOrNumberType = 'bigint | number';
4
+ const bytesOrStringType = 'Uint8Array | string';
5
+ function getEquivalentType(algoType, ioType, sanitizer) {
6
+ if (algoType == 'void') {
7
+ return 'void';
8
+ }
9
+ if (algoType == 'AVMBytes') {
10
+ return ioType === 'input' ? bytesOrStringType : 'Uint8Array';
11
+ }
12
+ if (algoType == 'AVMString') {
13
+ return 'string';
14
+ }
15
+ if (algoType == 'AVMUint64') {
16
+ return 'bigint';
17
+ }
18
+ if (argTypeIsTransaction(algoType)) {
19
+ return 'AppMethodCallTransactionArgument';
20
+ }
21
+ if (algoType == ABIReferenceType.Account) {
22
+ return bytesOrStringType;
23
+ }
24
+ if (algoType == ABIReferenceType.Application || algoType == ABIReferenceType.Asset) {
25
+ return 'bigint';
26
+ }
27
+ return abiTypeToTs(algoType, ioType, sanitizer);
28
+ }
29
+ function abiTypeToTs(abiType, ioType, sanitizer) {
30
+ if (abiType instanceof ABIStructType) {
31
+ return sanitizer.makeSafeTypeIdentifier(abiType.structName);
32
+ }
33
+ if (abiType instanceof ABIUintType) {
34
+ if (abiType.bitSize < 53)
35
+ return ioType === 'input' ? bigIntOrNumberType : 'number';
36
+ return ioType === 'input' ? bigIntOrNumberType : 'bigint';
37
+ }
38
+ if (abiType instanceof ABIArrayDynamicType) {
39
+ if (abiType.childType instanceof ABIByteType)
40
+ return 'Uint8Array';
41
+ const childTsType = abiTypeToTs(abiType.childType, ioType, sanitizer);
42
+ if (childTsType === bigIntOrNumberType) {
43
+ return 'bigint[] | number[]';
44
+ }
45
+ else if (childTsType === bytesOrStringType) {
46
+ return 'Uint8Array[] | string[]';
47
+ }
48
+ return `${childTsType}[]`;
49
+ }
50
+ if (abiType instanceof ABIArrayStaticType) {
51
+ if (abiType.childType instanceof ABIByteType)
52
+ return 'Uint8Array';
53
+ return `[${new Array(abiType.length).fill(abiTypeToTs(abiType.childType, ioType, sanitizer)).join(', ')}]`;
54
+ }
55
+ if (abiType instanceof ABIAddressType) {
56
+ return 'string';
57
+ }
58
+ if (abiType instanceof ABIBoolType) {
59
+ return 'boolean';
60
+ }
61
+ if (abiType instanceof ABIUfixedType) {
62
+ return 'number';
63
+ }
64
+ if (abiType instanceof ABITupleType) {
65
+ return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType, sanitizer)).join(', ')}]`;
66
+ }
67
+ if (abiType instanceof ABIByteType) {
68
+ return 'number';
69
+ }
70
+ if (abiType instanceof ABIStringType) {
71
+ return 'string';
72
+ }
73
+ return 'unknown';
74
+ }
75
+
76
+ export { abiTypeToTs, getEquivalentType };
77
+ //# sourceMappingURL=get-equivalent-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-equivalent-type.mjs","sources":["../../../../src/client/helpers/get-equivalent-type.ts"],"sourcesContent":["import {\n ABIAddressType,\n ABIArrayDynamicType,\n ABIArrayStaticType,\n ABIBoolType,\n ABIByteType,\n ABIReferenceType,\n ABIStringType,\n ABITupleType,\n ABIType,\n ABIStructType,\n ABIUfixedType,\n ABIUintType,\n AVMType,\n argTypeIsTransaction,\n ABITransactionType,\n} from '@algorandfoundation/algokit-utils/abi'\n\nimport { Sanitizer } from '../../util/sanitization'\n\nconst bigIntOrNumberType = 'bigint | number'\nconst bytesOrStringType = 'Uint8Array | string'\n\nexport function getEquivalentType(\n algoType: ABIType | ABIReferenceType | ABITransactionType | AVMType | 'void',\n ioType: 'input' | 'output',\n sanitizer: Sanitizer,\n): string {\n if (algoType == 'void') {\n return 'void'\n }\n if (algoType == 'AVMBytes') {\n return ioType === 'input' ? bytesOrStringType : 'Uint8Array'\n }\n if (algoType == 'AVMString') {\n return 'string'\n }\n if (algoType == 'AVMUint64') {\n return 'bigint'\n }\n if (argTypeIsTransaction(algoType)) {\n return 'AppMethodCallTransactionArgument'\n }\n if (algoType == ABIReferenceType.Account) {\n return bytesOrStringType\n }\n if (algoType == ABIReferenceType.Application || algoType == ABIReferenceType.Asset) {\n return 'bigint'\n }\n\n return abiTypeToTs(algoType, ioType, sanitizer)\n}\n\nexport function abiTypeToTs(abiType: ABIType, ioType: 'input' | 'output', sanitizer: Sanitizer): string {\n if (abiType instanceof ABIStructType) {\n return sanitizer.makeSafeTypeIdentifier(abiType.structName)\n }\n\n if (abiType instanceof ABIUintType) {\n if (abiType.bitSize < 53) return ioType === 'input' ? bigIntOrNumberType : 'number'\n return ioType === 'input' ? bigIntOrNumberType : 'bigint'\n }\n if (abiType instanceof ABIArrayDynamicType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n\n const childTsType = abiTypeToTs(abiType.childType, ioType, sanitizer)\n if (childTsType === bigIntOrNumberType) {\n return 'bigint[] | number[]'\n } else if (childTsType === bytesOrStringType) {\n return 'Uint8Array[] | string[]'\n }\n\n return `${childTsType}[]`\n }\n if (abiType instanceof ABIArrayStaticType) {\n if (abiType.childType instanceof ABIByteType) return 'Uint8Array'\n return `[${new Array(abiType.length).fill(abiTypeToTs(abiType.childType, ioType, sanitizer)).join(', ')}]`\n }\n if (abiType instanceof ABIAddressType) {\n return 'string'\n }\n if (abiType instanceof ABIBoolType) {\n return 'boolean'\n }\n if (abiType instanceof ABIUfixedType) {\n return 'number'\n }\n if (abiType instanceof ABITupleType) {\n return `[${abiType.childTypes.map((c) => abiTypeToTs(c, ioType, sanitizer)).join(', ')}]`\n }\n if (abiType instanceof ABIByteType) {\n return 'number'\n }\n if (abiType instanceof ABIStringType) {\n return 'string'\n }\n return 'unknown'\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,kBAAkB,GAAG,iBAAiB;AAC5C,MAAM,iBAAiB,GAAG,qBAAqB;SAE/B,iBAAiB,CAC/B,QAA4E,EAC5E,MAA0B,EAC1B,SAAoB,EAAA;AAEpB,IAAA,IAAI,QAAQ,IAAI,MAAM,EAAE;AACtB,QAAA,OAAO,MAAM;IACf;AACA,IAAA,IAAI,QAAQ,IAAI,UAAU,EAAE;QAC1B,OAAO,MAAM,KA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;AAAO,aAAA,IAAI,WAAW,KAAK,iBAAiB,EAAE;AAC5C,YAAA,OAAO,yBAAyB;QAClC;QAEA,OAAO,CAAA,EAAG,WAAW,CAAA,EAAA,CAAI;IAC3B;AACA,IAAA,IAAI,OAAO,YAAY,kBAAkB,EAAE;AACzC,QAAA,IAAI,OAAO,CAAC,SAAS,YAAY,WAAW;AAAE,YAAA,OAAO,YAAY;AACjE,QAAA,OAAO,CAAA,CAAA,EAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;IAC5G;AACA,IAAA,IAAI,OAAO,YAAY,cAAc,EAAE;AACrC,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,OAAO,YAAY,WAAW,EAAE;AAClC,QAAA,OAAO,SAAS;IAClB;AACA,IAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,OAAO,YAAY,YAAY,EAAE;QACnC,OAAO,CAAA,CAAA,EAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAA,CAAG;IAC3F;AACA,IAAA,IAAI,OAAO,YAAY,WAAW,EAAE;AAClC,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,OAAO,YAAY,aAAa,EAAE;AACpC,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,OAAO,SAAS;AAClB;;;;"}
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ function* imports() {
4
+ yield `
5
+ import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
6
+ import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
7
+ import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
8
+ import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
9
+ import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
10
+ import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
11
+ import { SendParams,SendTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
12
+ import { AppFactoryCreateMethodCallParams, AppFactoryAppClientParams, AppFactoryDeployParams, AppFactoryParams, AppFactory as _AppFactory, AppFactoryResolveAppClientByCreatorAndNameParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
13
+ import { TransactionComposer, TransactionComposerConfig, SkipSignaturesSimulateOptions, RawSimulateOptions, SimulateOptions, AppMethodCallTransactionArgument } from '@algorandfoundation/algokit-utils/types/composer'
14
+ `;
15
+ }
16
+
17
+ exports.imports = imports;
18
+ //# sourceMappingURL=imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.js","sources":["../../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\n\nexport function* imports(): DocumentParts {\n yield `\nimport { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\nimport { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'\nimport { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'\nimport { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'\nimport { Address, encodeAddress } from '@algorandfoundation/algokit-utils'\nimport { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'\nimport { SendParams,SendTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\nimport { AppFactoryCreateMethodCallParams, AppFactoryAppClientParams, AppFactoryDeployParams, AppFactoryParams, AppFactory as _AppFactory, AppFactoryResolveAppClientByCreatorAndNameParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'\nimport { TransactionComposer, TransactionComposerConfig, SkipSignaturesSimulateOptions, RawSimulateOptions, SimulateOptions, AppMethodCallTransactionArgument } from '@algorandfoundation/algokit-utils/types/composer'\n `\n}\n"],"names":[],"mappings":";;AAEM,UAAW,OAAO,GAAA;IACtB,MAAM;;;;;;;;;;GAUL;AACH;;;;"}
@@ -0,0 +1,16 @@
1
+ function* imports() {
2
+ yield `
3
+ import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
4
+ import { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'
5
+ import { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'
6
+ import { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'
7
+ import { Address, encodeAddress } from '@algorandfoundation/algokit-utils'
8
+ import { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'
9
+ import { SendParams,SendTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
10
+ import { AppFactoryCreateMethodCallParams, AppFactoryAppClientParams, AppFactoryDeployParams, AppFactoryParams, AppFactory as _AppFactory, AppFactoryResolveAppClientByCreatorAndNameParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
11
+ import { TransactionComposer, TransactionComposerConfig, SkipSignaturesSimulateOptions, RawSimulateOptions, SimulateOptions, AppMethodCallTransactionArgument } from '@algorandfoundation/algokit-utils/types/composer'
12
+ `;
13
+ }
14
+
15
+ export { imports };
16
+ //# sourceMappingURL=imports.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imports.mjs","sources":["../../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\n\nexport function* imports(): DocumentParts {\n yield `\nimport { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\nimport { ABIReturn, Arc56Contract } from '@algorandfoundation/algokit-utils/abi'\nimport { OnApplicationComplete, TransactionSigner, Transaction } from '@algorandfoundation/algokit-utils/transact'\nimport { SimulateResponse } from '@algorandfoundation/algokit-utils/algod-client'\nimport { Address, encodeAddress } from '@algorandfoundation/algokit-utils'\nimport { AppClientMethodCallParams, AppClientCompilationParams, AppClientDeployParams, CallOnComplete, AppClient as _AppClient, AppClientParams, ResolveAppClientByCreatorAndName, ResolveAppClientByNetwork, AppClientBareCallParams, CloneAppClientParams } from '@algorandfoundation/algokit-utils/types/app-client'\nimport { SendParams,SendTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\nimport { AppFactoryCreateMethodCallParams, AppFactoryAppClientParams, AppFactoryDeployParams, AppFactoryParams, AppFactory as _AppFactory, AppFactoryResolveAppClientByCreatorAndNameParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'\nimport { TransactionComposer, TransactionComposerConfig, SkipSignaturesSimulateOptions, RawSimulateOptions, SimulateOptions, AppMethodCallTransactionArgument } from '@algorandfoundation/algokit-utils/types/composer'\n `\n}\n"],"names":[],"mappings":"AAEM,UAAW,OAAO,GAAA;IACtB,MAAM;;;;;;;;;;GAUL;AACH;;;;"}
@@ -0,0 +1,125 @@
1
+ 'use strict';
2
+
3
+ var writer = require('../output/writer.js');
4
+ var appClientContext = require('./app-client-context.js');
5
+
6
+ function* paramsFactory(ctx) {
7
+ yield* writer.jsDoc(`Exposes methods for constructing \`AppClient\` params objects for ABI calls to the ${ctx.app.name.original} smart contract`);
8
+ yield `export abstract class ${ctx.app.name.makeSafeTypeIdentifier}ParamsFactory {`;
9
+ yield writer.IncIndent;
10
+ yield* opMethods(ctx);
11
+ for (const method of ctx.app.methods) {
12
+ if (!method.callActions.noOp)
13
+ continue;
14
+ yield* callFactoryMethod(ctx, method);
15
+ }
16
+ yield writer.DecIndent;
17
+ yield '}';
18
+ }
19
+ function* opMethods(ctx) {
20
+ const { app } = ctx;
21
+ if (ctx.mode === 'full') {
22
+ yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, app.createMethods, 'create', true);
23
+ yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, app.updateMethods, 'update', true);
24
+ yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, app.deleteMethods, 'delete');
25
+ }
26
+ yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, app.optInMethods, 'optIn');
27
+ yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, app.closeOutMethods, 'closeOut');
28
+ }
29
+ function* operationMethod(ctx, description, methods, verb, includeCompilation) {
30
+ const { app, sanitizer, name } = ctx;
31
+ if (methods.some((m) => !m.isBare)) {
32
+ yield* writer.jsDoc(`Gets available ${verb} ABI call param factories`);
33
+ yield `static get ${verb}() {`;
34
+ yield writer.IncIndent;
35
+ yield `return {`;
36
+ yield writer.IncIndent;
37
+ if (['create', 'update', 'delete'].includes(verb)) {
38
+ yield `_resolveByMethod<TParams extends ${app.name.makeSafeTypeIdentifier}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`;
39
+ yield writer.IncIndent;
40
+ yield `switch(params.method) {`;
41
+ yield writer.IncIndent;
42
+ for (const method of methods) {
43
+ if (!appClientContext.isAbiMethod(method))
44
+ continue;
45
+ if (method.baseNameIsUnique) {
46
+ yield `case '${method.name.makeSafeStringTypeLiteral}':`;
47
+ }
48
+ yield `case '${sanitizer.makeSafeStringTypeLiteral(method.signature)}':`;
49
+ yield* writer.indent(`return ${app.name.makeSafeTypeIdentifier}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(method.uniqueName.original))}(params)`);
50
+ }
51
+ yield writer.DecIndentAndCloseBlock;
52
+ // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never
53
+ yield `throw new Error(\`Unknown ' + verb + ' method\`)`;
54
+ yield writer.DecIndent;
55
+ yield '},';
56
+ yield writer.NewLine;
57
+ }
58
+ for (const method of methods) {
59
+ if (!appClientContext.isAbiMethod(method))
60
+ continue;
61
+ const onComplete = verb === 'create' ? method.createActions.inputType : undefined;
62
+ const uniqueName = method.uniqueName.original;
63
+ yield* writer.jsDoc({
64
+ description: `${description} using the ${method.signature} ABI method`,
65
+ params: {
66
+ params: `Parameters for the call`,
67
+ },
68
+ returns: 'An `AppClientMethodCallParams` object for the call',
69
+ });
70
+ yield* factoryMethod({
71
+ isNested: true,
72
+ sanitizer,
73
+ name: sanitizer.makeSafeMethodIdentifier(uniqueName),
74
+ signature: method.signature,
75
+ args: method.args,
76
+ additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}`,
77
+ contractName: name,
78
+ });
79
+ }
80
+ yield writer.DecIndentAndCloseBlock;
81
+ yield writer.DecIndentAndCloseBlock;
82
+ yield writer.NewLine;
83
+ }
84
+ }
85
+ function* callFactoryMethod({ sanitizer, name }, method) {
86
+ if (!method.callActions.any || !appClientContext.isAbiMethod(method))
87
+ return;
88
+ yield* writer.jsDoc({
89
+ description: `Constructs a no op call for the ${method.signature} ABI method`,
90
+ abiDescription: method.desc,
91
+ params: {
92
+ params: `Parameters for the call`,
93
+ },
94
+ returns: 'An `AppClientMethodCallParams` object for the call',
95
+ });
96
+ yield* factoryMethod({
97
+ isNested: false,
98
+ sanitizer,
99
+ name: method.uniqueName.makeSafeMethodIdentifier,
100
+ signature: method.signature,
101
+ args: method.args,
102
+ additionalParamTypes: ' & CallOnComplete',
103
+ contractName: name,
104
+ });
105
+ }
106
+ function* factoryMethod(m) {
107
+ const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m;
108
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature);
109
+ yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`;
110
+ yield writer.IncIndent;
111
+ yield `return {`;
112
+ yield writer.IncIndent;
113
+ yield '...params,';
114
+ yield `method: '${methodSigSafe}' as const,`;
115
+ yield `args: Array.isArray(params.args) ? params.args : [${args
116
+ .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(a.name?.makeSafePropertyIdentifier ?? `arg${i + 1}`)}`)
117
+ .join(', ')}],`;
118
+ yield writer.DecIndent;
119
+ yield '}';
120
+ yield writer.DecIndent;
121
+ yield `}${isNested ? ',' : ''}`;
122
+ }
123
+
124
+ exports.paramsFactory = paramsFactory;
125
+ //# sourceMappingURL=params-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-factory.js","sources":["../../../src/client/params-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { Sanitizer } from '../util/sanitization'\nimport { AppClientMethodContext, MethodArgClientContext, isAbiMethod } from './app-client-context'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.app.name.original} smart contract`)\n yield `export abstract class ${ctx.app.name.makeSafeTypeIdentifier}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n if (!method.callActions.noOp) continue\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, app.createMethods, 'create', true)\n yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, app.updateMethods, 'update', true)\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, app.deleteMethods, 'delete')\n }\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, app.optInMethods, 'optIn')\n yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, app.closeOutMethods, 'closeOut')\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: AppClientMethodContext[],\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, sanitizer, name } = ctx\n if (methods.some((m) => !m.isBare)) {\n yield* jsDoc(`Gets available ${verb} ABI call param factories`)\n yield `static get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n\n if (['create', 'update', 'delete'].includes(verb)) {\n yield `_resolveByMethod<TParams extends ${app.name.makeSafeTypeIdentifier}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`\n yield IncIndent\n yield `switch(params.method) {`\n yield IncIndent\n\n for (const method of methods) {\n if (!isAbiMethod(method)) continue\n if (method.baseNameIsUnique) {\n yield `case '${method.name.makeSafeStringTypeLiteral}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(method.signature)}':`\n yield* indent(\n `return ${app.name.makeSafeTypeIdentifier}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(method.uniqueName.original))}(params)`,\n )\n }\n yield DecIndentAndCloseBlock\n\n // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never\n yield `throw new Error(\\`Unknown ' + verb + ' method\\`)`\n yield DecIndent\n yield '},'\n yield NewLine\n }\n\n for (const method of methods) {\n if (!isAbiMethod(method)) continue\n const onComplete = verb === 'create' ? method.createActions.inputType : undefined\n\n const uniqueName = method.uniqueName.original\n yield* jsDoc({\n description: `${description} using the ${method.signature} ABI method`,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: true,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(uniqueName),\n signature: method.signature,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''\n }`,\n contractName: name,\n })\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ sanitizer, name }: GeneratorContext, method: AppClientMethodContext) {\n if (!method.callActions.any || !isAbiMethod(method)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${method.signature} ABI method`,\n abiDescription: method.desc,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: false,\n sanitizer,\n name: method.uniqueName.makeSafeMethodIdentifier,\n signature: method.signature,\n args: method.args,\n additionalParamTypes: ' & CallOnComplete',\n contractName: name,\n })\n}\n\nfunction* factoryMethod(m: {\n isNested: boolean\n name?: string\n signature: string\n args: MethodArgClientContext[]\n additionalParamTypes?: string\n sanitizer: Sanitizer\n contractName: string\n}) {\n const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature)\n yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield '...params,'\n yield `method: '${methodSigSafe}' as const,`\n yield `args: Array.isArray(params.args) ? params.args : [${args\n .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(a.name?.makeSafePropertyIdentifier ?? `arg${i + 1}`)}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":["jsDoc","IncIndent","DecIndent","isAbiMethod","indent","DecIndentAndCloseBlock","NewLine"],"mappings":";;;;;AAKM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,OAAOA,YAAK,CAAC,sFAAsF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAA,eAAA,CAAiB,CAAC;IAC1I,MAAM,CAAA,sBAAA,EAAyB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAA,eAAA,CAAiB;AACnF,IAAA,MAAMC,gBAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;AACpC,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI;YAAE;QAC9B,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;IACvC;AAEA,IAAA,MAAMC,gBAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EAAA;AACvC,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG;AAEnB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;QACvB,OAAO,eAAe,CAAC,GAAG,EAAE,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;QACtI,OAAO,eAAe,CAAC,GAAG,EAAE,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,EAA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ACJ;AAEA,UAAU,aAAa,CAAC,CAQvB,EAAA;AACC,IAAA,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC;IAC5F,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC;IACpE,MAAM,CAAA,EAAG,QAAQ,GAAG,EAAE,GAAG,SAAS,CAAA,EAAG,IAAI,uBAAuB,YAAY,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,YAAY,CAAA,eAAA,EAAkB,aAAa,CAAA,GAAA,EAAM,oBAAoB,CAAA,4BAAA,EAA+B,oBAAoB,CAAA,EAAA,CAAI;AAC7O,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,UAAU;AAChB,IAAA,MAAMA,gBAAS;AACf,IAAA,MAAM,YAAY;IAClB,MAAM,CAAA,SAAA,EAAY,aAAa,CAAA,WAAA,CAAa;AAC5C,IAAA,MAAM,qDAAqD;SACxD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAA,WAAA,EAAc,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,EAAE,0BAA0B,IAAI,CAAA,GAAA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAA,CAAE;AAClH,SAAA,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CAAI;AACjB,IAAA,MAAMC,gBAAS;AACf,IAAA,MAAM,GAAG;AACT,IAAA,MAAMA,gBAAS;IACf,MAAM,CAAA,CAAA,EAAI,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAA,CAAE;AACjC;;;;"}
@@ -0,0 +1,123 @@
1
+ import { jsDoc, IncIndent, DecIndent, indent, DecIndentAndCloseBlock, NewLine } from '../output/writer.mjs';
2
+ import { isAbiMethod } from './app-client-context.mjs';
3
+
4
+ function* paramsFactory(ctx) {
5
+ yield* jsDoc(`Exposes methods for constructing \`AppClient\` params objects for ABI calls to the ${ctx.app.name.original} smart contract`);
6
+ yield `export abstract class ${ctx.app.name.makeSafeTypeIdentifier}ParamsFactory {`;
7
+ yield IncIndent;
8
+ yield* opMethods(ctx);
9
+ for (const method of ctx.app.methods) {
10
+ if (!method.callActions.noOp)
11
+ continue;
12
+ yield* callFactoryMethod(ctx, method);
13
+ }
14
+ yield DecIndent;
15
+ yield '}';
16
+ }
17
+ function* opMethods(ctx) {
18
+ const { app } = ctx;
19
+ if (ctx.mode === 'full') {
20
+ yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, app.createMethods, 'create', true);
21
+ yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, app.updateMethods, 'update', true);
22
+ yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, app.deleteMethods, 'delete');
23
+ }
24
+ yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, app.optInMethods, 'optIn');
25
+ yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, app.closeOutMethods, 'closeOut');
26
+ }
27
+ function* operationMethod(ctx, description, methods, verb, includeCompilation) {
28
+ const { app, sanitizer, name } = ctx;
29
+ if (methods.some((m) => !m.isBare)) {
30
+ yield* jsDoc(`Gets available ${verb} ABI call param factories`);
31
+ yield `static get ${verb}() {`;
32
+ yield IncIndent;
33
+ yield `return {`;
34
+ yield IncIndent;
35
+ if (['create', 'update', 'delete'].includes(verb)) {
36
+ yield `_resolveByMethod<TParams extends ${app.name.makeSafeTypeIdentifier}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`;
37
+ yield IncIndent;
38
+ yield `switch(params.method) {`;
39
+ yield IncIndent;
40
+ for (const method of methods) {
41
+ if (!isAbiMethod(method))
42
+ continue;
43
+ if (method.baseNameIsUnique) {
44
+ yield `case '${method.name.makeSafeStringTypeLiteral}':`;
45
+ }
46
+ yield `case '${sanitizer.makeSafeStringTypeLiteral(method.signature)}':`;
47
+ yield* indent(`return ${app.name.makeSafeTypeIdentifier}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(method.uniqueName.original))}(params)`);
48
+ }
49
+ yield DecIndentAndCloseBlock;
50
+ // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never
51
+ yield `throw new Error(\`Unknown ' + verb + ' method\`)`;
52
+ yield DecIndent;
53
+ yield '},';
54
+ yield NewLine;
55
+ }
56
+ for (const method of methods) {
57
+ if (!isAbiMethod(method))
58
+ continue;
59
+ const onComplete = verb === 'create' ? method.createActions.inputType : undefined;
60
+ const uniqueName = method.uniqueName.original;
61
+ yield* jsDoc({
62
+ description: `${description} using the ${method.signature} ABI method`,
63
+ params: {
64
+ params: `Parameters for the call`,
65
+ },
66
+ returns: 'An `AppClientMethodCallParams` object for the call',
67
+ });
68
+ yield* factoryMethod({
69
+ isNested: true,
70
+ sanitizer,
71
+ name: sanitizer.makeSafeMethodIdentifier(uniqueName),
72
+ signature: method.signature,
73
+ args: method.args,
74
+ additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''}`,
75
+ contractName: name,
76
+ });
77
+ }
78
+ yield DecIndentAndCloseBlock;
79
+ yield DecIndentAndCloseBlock;
80
+ yield NewLine;
81
+ }
82
+ }
83
+ function* callFactoryMethod({ sanitizer, name }, method) {
84
+ if (!method.callActions.any || !isAbiMethod(method))
85
+ return;
86
+ yield* jsDoc({
87
+ description: `Constructs a no op call for the ${method.signature} ABI method`,
88
+ abiDescription: method.desc,
89
+ params: {
90
+ params: `Parameters for the call`,
91
+ },
92
+ returns: 'An `AppClientMethodCallParams` object for the call',
93
+ });
94
+ yield* factoryMethod({
95
+ isNested: false,
96
+ sanitizer,
97
+ name: method.uniqueName.makeSafeMethodIdentifier,
98
+ signature: method.signature,
99
+ args: method.args,
100
+ additionalParamTypes: ' & CallOnComplete',
101
+ contractName: name,
102
+ });
103
+ }
104
+ function* factoryMethod(m) {
105
+ const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m;
106
+ const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature);
107
+ yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`;
108
+ yield IncIndent;
109
+ yield `return {`;
110
+ yield IncIndent;
111
+ yield '...params,';
112
+ yield `method: '${methodSigSafe}' as const,`;
113
+ yield `args: Array.isArray(params.args) ? params.args : [${args
114
+ .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(a.name?.makeSafePropertyIdentifier ?? `arg${i + 1}`)}`)
115
+ .join(', ')}],`;
116
+ yield DecIndent;
117
+ yield '}';
118
+ yield DecIndent;
119
+ yield `}${isNested ? ',' : ''}`;
120
+ }
121
+
122
+ export { paramsFactory };
123
+ //# sourceMappingURL=params-factory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-factory.mjs","sources":["../../../src/client/params-factory.ts"],"sourcesContent":["import { DecIndent, DecIndentAndCloseBlock, DocumentParts, IncIndent, indent, jsDoc, NewLine } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\nimport { Sanitizer } from '../util/sanitization'\nimport { AppClientMethodContext, MethodArgClientContext, isAbiMethod } from './app-client-context'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.app.name.original} smart contract`)\n yield `export abstract class ${ctx.app.name.makeSafeTypeIdentifier}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n if (!method.callActions.noOp) continue\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, app.createMethods, 'create', true)\n yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, app.updateMethods, 'update', true)\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, app.deleteMethods, 'delete')\n }\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, app.optInMethods, 'optIn')\n yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, app.closeOutMethods, 'closeOut')\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: AppClientMethodContext[],\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, sanitizer, name } = ctx\n if (methods.some((m) => !m.isBare)) {\n yield* jsDoc(`Gets available ${verb} ABI call param factories`)\n yield `static get ${verb}() {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n\n if (['create', 'update', 'delete'].includes(verb)) {\n yield `_resolveByMethod<TParams extends ${app.name.makeSafeTypeIdentifier}${verb[0].toUpperCase()}${verb.substring(1)}CallParams & {method: string}>(params: TParams) {`\n yield IncIndent\n yield `switch(params.method) {`\n yield IncIndent\n\n for (const method of methods) {\n if (!isAbiMethod(method)) continue\n if (method.baseNameIsUnique) {\n yield `case '${method.name.makeSafeStringTypeLiteral}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(method.signature)}':`\n yield* indent(\n `return ${app.name.makeSafeTypeIdentifier}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(method.uniqueName.original))}(params)`,\n )\n }\n yield DecIndentAndCloseBlock\n\n // Ordinarily we'd pop in the params.method value, but we can't here since it knows at compile time the type of params.method is never\n yield `throw new Error(\\`Unknown ' + verb + ' method\\`)`\n yield DecIndent\n yield '},'\n yield NewLine\n }\n\n for (const method of methods) {\n if (!isAbiMethod(method)) continue\n const onComplete = verb === 'create' ? method.createActions.inputType : undefined\n\n const uniqueName = method.uniqueName.original\n yield* jsDoc({\n description: `${description} using the ${method.signature} ABI method`,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: true,\n sanitizer,\n name: sanitizer.makeSafeMethodIdentifier(uniqueName),\n signature: method.signature,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.typeLiteral ? ` & ${onComplete.typeLiteral}` : ''\n }`,\n contractName: name,\n })\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ sanitizer, name }: GeneratorContext, method: AppClientMethodContext) {\n if (!method.callActions.any || !isAbiMethod(method)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${method.signature} ABI method`,\n abiDescription: method.desc,\n params: {\n params: `Parameters for the call`,\n },\n returns: 'An `AppClientMethodCallParams` object for the call',\n })\n yield* factoryMethod({\n isNested: false,\n sanitizer,\n name: method.uniqueName.makeSafeMethodIdentifier,\n signature: method.signature,\n args: method.args,\n additionalParamTypes: ' & CallOnComplete',\n contractName: name,\n })\n}\n\nfunction* factoryMethod(m: {\n isNested: boolean\n name?: string\n signature: string\n args: MethodArgClientContext[]\n additionalParamTypes?: string\n sanitizer: Sanitizer\n contractName: string\n}) {\n const { isNested, name, signature, args, additionalParamTypes, sanitizer, contractName } = m\n const methodSigSafe = sanitizer.makeSafeStringTypeLiteral(signature)\n yield `${isNested ? '' : 'static '}${name}(params: CallParams<${contractName}Args['obj']['${methodSigSafe}'] | ${contractName}Args['tuple']['${methodSigSafe}']>${additionalParamTypes}): AppClientMethodCallParams${additionalParamTypes} {`\n yield IncIndent\n yield `return {`\n yield IncIndent\n yield '...params,'\n yield `method: '${methodSigSafe}' as const,`\n yield `args: Array.isArray(params.args) ? params.args : [${args\n .map((a, i) => `params.args${sanitizer.getSafeMemberAccessor(a.name?.makeSafePropertyIdentifier ?? `arg${i + 1}`)}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":[],"mappings":";;;AAKM,UAAW,aAAa,CAAC,GAAqB,EAAA;AAClD,IAAA,OAAO,KAAK,CAAC,sFAAsF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAA,eAAA,CAAiB,CAAC;IAC1I,MAAM,CAAA,sBAAA,EAAyB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAA,eAAA,CAAiB;AACnF,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;AACpC,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI;YAAE;QAC9B,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;IACvC;AAEA,IAAA,MAAM,SAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EAAA;AACvC,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG;AAEnB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;QACvB,OAAO,eAAe,CAAC,GAAG,EAAE,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;QACtI,OAAO,eAAe,CAAC,GAAG,EAAE,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EAAE,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,CAAC;AACtI,QAAA,OAAO,eAAe,CAAC,GAAG,EAAE,6CAA6C,GAAG,CAAC,IAAI,CAAA,eAAA,C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EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,CAAC;IAC5F,MAAM,aAAa,GAAG,SAAS,CAAC,yBAAyB,CAAC,SAAS,CAAC;IACpE,MAAM,CAAA,EAAG,QAAQ,GAAG,EAAE,GAAG,SAAS,CAAA,EAAG,IAAI,uBAAuB,YAAY,CAAA,aAAA,EAAgB,aAAa,CAAA,KAAA,EAAQ,YAAY,CAAA,eAAA,EAAkB,aAAa,CAAA,GAAA,EAAM,oBAAoB,CAAA,4BAAA,EAA+B,oBAAoB,CAAA,EAAA,CAAI;AAC7O,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,UAAU;AAChB,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,YAAY;IAClB,MAAM,CAAA,SAAA,EAAY,aAAa,CAAA,WAAA,CAAa;AAC5C,IAAA,MAAM,qDAAqD;SACxD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAA,WAAA,EAAc,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,EAAE,0BAA0B,IAAI,CAAA,GAAA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAA,CAAE;AAClH,SAAA,IAAI,CAAC,IAAI,CAAC,CAAA,EAAA,CAAI;AACjB,IAAA,MAAM,SAAS;AACf,IAAA,MAAM,GAAG;AACT,IAAA,MAAM,SAAS;IACf,MAAM,CAAA,CAAA,EAAI,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAA,CAAE;AACjC;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility-types.js","sources":["../../../src/client/utility-types.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\n\nexport function* utilityTypes(): DocumentParts {\n yield `\n /**\n * A state record containing binary data\n */\n export interface BinaryState {\n /**\n * Gets the state value as a Uint8Array\n */\n asByteArray(): Uint8Array | undefined\n /**\n * Gets the state value as a string\n */\n asString(): string | undefined\n }\n\n class BinaryStateValue implements BinaryState {\n constructor(private value: Uint8Array | undefined) {}\n\n asByteArray(): Uint8Array | undefined {\n return this.value\n }\n\n asString(): string | undefined {\n return this.value !== undefined ? Buffer.from(this.value).toString('utf-8') : undefined\n }\n }\n\n /**\n * Expands types for IntelliSense so they are more human readable\n * See https://stackoverflow.com/a/69288824\n */\n export type Expand<T> = T extends (...args: infer A) => infer R\n ? (...args: Expand<A>) => Expand<R>\n : T extends infer O\n ? { [K in keyof O]: O[K] }\n : never\n `\n}\n"],"names":[],"mappings":";;AAEM,UAAW,YAAY,GAAA;IAC3B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCL;AACH;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility-types.mjs","sources":["../../../src/client/utility-types.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\n\nexport function* utilityTypes(): DocumentParts {\n yield `\n /**\n * A state record containing binary data\n */\n export interface BinaryState {\n /**\n * Gets the state value as a Uint8Array\n */\n asByteArray(): Uint8Array | undefined\n /**\n * Gets the state value as a string\n */\n asString(): string | undefined\n }\n\n class BinaryStateValue implements BinaryState {\n constructor(private value: Uint8Array | undefined) {}\n\n asByteArray(): Uint8Array | undefined {\n return this.value\n }\n\n asString(): string | undefined {\n return this.value !== undefined ? Buffer.from(this.value).toString('utf-8') : undefined\n }\n }\n\n /**\n * Expands types for IntelliSense so they are more human readable\n * See https://stackoverflow.com/a/69288824\n */\n export type Expand<T> = T extends (...args: infer A) => infer R\n ? (...args: Expand<A>) => Expand<R>\n : T extends infer O\n ? { [K in keyof O]: O[K] }\n : never\n `\n}\n"],"names":[],"mappings":"AAEM,UAAW,YAAY,GAAA;IAC3B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCL;AACH;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.js","sources":["../../../src/output/writer.ts"],"sourcesContent":["export const IncIndent = Symbol('Increase Indent')\nexport const DecIndent = Symbol('Decrease Indent')\nexport const DecIndentAndCloseBlock = Symbol('Decrease Indent and write a closing brace')\nexport const NewLineMode = Symbol('New Line Mode')\nexport const RestoreLineMode = Symbol('Restore Line Mode')\nexport const PropertyDelimiter = Symbol('Property Delimiter')\nexport const InlineMode = Symbol('Inline Mode')\nexport const NewLine = Symbol('New Line')\n\nexport type Part =\n | string\n | typeof IncIndent\n | typeof DecIndent\n | typeof NewLineMode\n | typeof DecIndentAndCloseBlock\n | typeof InlineMode\n | typeof NewLine\n | typeof RestoreLineMode\n | typeof PropertyDelimiter\nexport type DocumentParts = Generator<Part, void>\n\nexport type WriteOptions = {\n indent?: string\n disableEslint?: boolean\n header?: string\n}\n\ninterface StringWriter {\n write(value: string): void\n get last(): string\n}\n\nexport function writeDocumentPartsToStream(document: DocumentParts, stream: { write(chunk: string): void }, options: WriteOptions = {}) {\n const writer = {\n _last: '',\n write(val: string) {\n this._last = val\n stream.write(val)\n },\n get last() {\n return this._last\n },\n }\n writeDocumentPartsTo(document, options, writer)\n}\n\nexport function writeDocumentPartsToString(document: DocumentParts, options: WriteOptions = {}) {\n const writer = {\n result: [] as string[],\n _last: '',\n write(val: string) {\n this._last = val\n this.result.push(val)\n },\n get last() {\n return this._last\n },\n toString() {\n return this.result.join('')\n },\n }\n writeDocumentPartsTo(document, options, writer)\n return writer.toString()\n}\n\nexport function* inline(...parts: Array<Part | DocumentParts>) {\n yield InlineMode\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield RestoreLineMode\n}\n\nexport function* indent(...parts: Array<Part | DocumentParts>) {\n yield IncIndent\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield DecIndent\n}\n\nexport function* jsDoc(\n docs: string | string[] | { description: string | string[]; abiDescription?: string; params?: Record<string, string>; returns?: string },\n) {\n yield `/**`\n if (typeof docs === 'string' || Array.isArray(docs)) {\n const description = typeof docs === 'string' ? [docs] : docs\n for (const line of description) {\n yield ` * ${line}`\n }\n } else {\n const description = typeof docs.description === 'string' ? [docs.description] : docs.description\n for (const line of description) {\n yield ` * ${line}`\n }\n if (docs.abiDescription) {\n yield ' *'\n yield ` * ${docs.abiDescription}`\n }\n if (docs.params || docs.returns) {\n yield ' *'\n }\n for (const [paramName, paramDesc] of Object.entries(docs.params ?? {})) {\n yield ` * @param ${paramName} ${paramDesc}`\n }\n if (docs.returns) yield ` * @returns ${docs.returns}`\n }\n yield ' */'\n}\n\nfunction writeDocumentPartsTo(document: DocumentParts, { indent = ' ', ...options }: WriteOptions, writer: StringWriter): void {\n if (options.header) writer.write(`${options.header}\\n`)\n if (options.disableEslint) writer.write('/* eslint-disable */\\n')\n\n const lineModes = [NewLineMode]\n const currentLineMode = () => lineModes.at(-1) ?? NewLineMode\n\n let curIndent = ''\n for (const part of document) {\n switch (part) {\n case IncIndent:\n curIndent += indent\n break\n case DecIndent:\n curIndent = curIndent.slice(0, -indent.length)\n break\n case DecIndentAndCloseBlock:\n curIndent = curIndent.slice(0, -indent.length)\n writer.write(`${curIndent}}\\n`)\n break\n case NewLineMode:\n lineModes.push(NewLineMode)\n if (writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case InlineMode:\n lineModes.push(InlineMode)\n break\n case RestoreLineMode:\n lineModes.pop()\n\n if (currentLineMode() === NewLineMode && writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case PropertyDelimiter:\n if (currentLineMode() === NewLineMode) {\n writer.write('\\n')\n } else {\n writer.write(', ')\n }\n break\n case NewLine:\n writer.write('\\n')\n break\n default:\n // Multi-line\n if (part.includes('\\n') || part.includes('\\r')) {\n if (writer.last.slice(-1)[0] !== '\\n') writer.write('\\n')\n const normalisedLineEndings = part.replaceAll(/\\r\\n/g, '\\n').replaceAll(/\\r/g, '\\n').replace(/^\\n/, '').trimEnd()\n const lines = normalisedLineEndings.split('\\n')\n const baseIndent = lines[0].match(/^\\s+/)?.[0] ?? ''\n for (const line of lines) {\n writer.write(curIndent + line.replace(new RegExp(`^${baseIndent}`, ''), '').trimEnd())\n writer.write('\\n')\n }\n } else {\n if (writer.last.slice(-1)[0] === '\\n') writer.write(curIndent)\n writer.write(part)\n }\n if (currentLineMode() === NewLineMode) writer.write('\\n')\n break\n }\n }\n}\n"],"names":[],"mappings":";;MAAa,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,sBAAsB,GAAG,MAAM,CAAC,2CAA2C;MAC3E,WAAW,GAAG,MAAM,CAAC,eAAe;MACpC,eAAe,GAAG,MAAM,CAAC,mBAAmB;MAC5C,iBAAiB,GAAG,MAAM,CAAC,oBAAoB;MAC/C,UAAU,GAAG,MAAM,CAAC,aAAa;MACjC,OAAO,GAAG,MAAM,CAAC,UAAU;AAyBlC,SAAU,0BAA0B,CAAC,QAAuB,EAAE,MAAsC,EAAE,UAAwB,EAAE,EAAA;AACpI,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACnB,CAAC;AACD,QAAA,IAAI,IAAI,GAAA;YACN,OAAO,IAAI,CAAC,KAAK;QACnB,CAAC;KACF;AACD,IAAA,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;AACjD;SAEgB,0BAA0B,CAAC,QAAuB,EAAE,UAAwB,EAAE,EAAA;AAC5F,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,MAAM,EAAE,EAAc;AACtB,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACvB,CAAC;AACD,QAAA,IAAI,IAAI,GAAA;YACN,OAA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mjs","sources":["../../../src/output/writer.ts"],"sourcesContent":["export const IncIndent = Symbol('Increase Indent')\nexport const DecIndent = Symbol('Decrease Indent')\nexport const DecIndentAndCloseBlock = Symbol('Decrease Indent and write a closing brace')\nexport const NewLineMode = Symbol('New Line Mode')\nexport const RestoreLineMode = Symbol('Restore Line Mode')\nexport const PropertyDelimiter = Symbol('Property Delimiter')\nexport const InlineMode = Symbol('Inline Mode')\nexport const NewLine = Symbol('New Line')\n\nexport type Part =\n | string\n | typeof IncIndent\n | typeof DecIndent\n | typeof NewLineMode\n | typeof DecIndentAndCloseBlock\n | typeof InlineMode\n | typeof NewLine\n | typeof RestoreLineMode\n | typeof PropertyDelimiter\nexport type DocumentParts = Generator<Part, void>\n\nexport type WriteOptions = {\n indent?: string\n disableEslint?: boolean\n header?: string\n}\n\ninterface StringWriter {\n write(value: string): void\n get last(): string\n}\n\nexport function writeDocumentPartsToStream(document: DocumentParts, stream: { write(chunk: string): void }, options: WriteOptions = {}) {\n const writer = {\n _last: '',\n write(val: string) {\n this._last = val\n stream.write(val)\n },\n get last() {\n return this._last\n },\n }\n writeDocumentPartsTo(document, options, writer)\n}\n\nexport function writeDocumentPartsToString(document: DocumentParts, options: WriteOptions = {}) {\n const writer = {\n result: [] as string[],\n _last: '',\n write(val: string) {\n this._last = val\n this.result.push(val)\n },\n get last() {\n return this._last\n },\n toString() {\n return this.result.join('')\n },\n }\n writeDocumentPartsTo(document, options, writer)\n return writer.toString()\n}\n\nexport function* inline(...parts: Array<Part | DocumentParts>) {\n yield InlineMode\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield RestoreLineMode\n}\n\nexport function* indent(...parts: Array<Part | DocumentParts>) {\n yield IncIndent\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield DecIndent\n}\n\nexport function* jsDoc(\n docs: string | string[] | { description: string | string[]; abiDescription?: string; params?: Record<string, string>; returns?: string },\n) {\n yield `/**`\n if (typeof docs === 'string' || Array.isArray(docs)) {\n const description = typeof docs === 'string' ? [docs] : docs\n for (const line of description) {\n yield ` * ${line}`\n }\n } else {\n const description = typeof docs.description === 'string' ? [docs.description] : docs.description\n for (const line of description) {\n yield ` * ${line}`\n }\n if (docs.abiDescription) {\n yield ' *'\n yield ` * ${docs.abiDescription}`\n }\n if (docs.params || docs.returns) {\n yield ' *'\n }\n for (const [paramName, paramDesc] of Object.entries(docs.params ?? {})) {\n yield ` * @param ${paramName} ${paramDesc}`\n }\n if (docs.returns) yield ` * @returns ${docs.returns}`\n }\n yield ' */'\n}\n\nfunction writeDocumentPartsTo(document: DocumentParts, { indent = ' ', ...options }: WriteOptions, writer: StringWriter): void {\n if (options.header) writer.write(`${options.header}\\n`)\n if (options.disableEslint) writer.write('/* eslint-disable */\\n')\n\n const lineModes = [NewLineMode]\n const currentLineMode = () => lineModes.at(-1) ?? NewLineMode\n\n let curIndent = ''\n for (const part of document) {\n switch (part) {\n case IncIndent:\n curIndent += indent\n break\n case DecIndent:\n curIndent = curIndent.slice(0, -indent.length)\n break\n case DecIndentAndCloseBlock:\n curIndent = curIndent.slice(0, -indent.length)\n writer.write(`${curIndent}}\\n`)\n break\n case NewLineMode:\n lineModes.push(NewLineMode)\n if (writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case InlineMode:\n lineModes.push(InlineMode)\n break\n case RestoreLineMode:\n lineModes.pop()\n\n if (currentLineMode() === NewLineMode && writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case PropertyDelimiter:\n if (currentLineMode() === NewLineMode) {\n writer.write('\\n')\n } else {\n writer.write(', ')\n }\n break\n case NewLine:\n writer.write('\\n')\n break\n default:\n // Multi-line\n if (part.includes('\\n') || part.includes('\\r')) {\n if (writer.last.slice(-1)[0] !== '\\n') writer.write('\\n')\n const normalisedLineEndings = part.replaceAll(/\\r\\n/g, '\\n').replaceAll(/\\r/g, '\\n').replace(/^\\n/, '').trimEnd()\n const lines = normalisedLineEndings.split('\\n')\n const baseIndent = lines[0].match(/^\\s+/)?.[0] ?? ''\n for (const line of lines) {\n writer.write(curIndent + line.replace(new RegExp(`^${baseIndent}`, ''), '').trimEnd())\n writer.write('\\n')\n }\n } else {\n if (writer.last.slice(-1)[0] === '\\n') writer.write(curIndent)\n writer.write(part)\n }\n if (currentLineMode() === NewLineMode) writer.write('\\n')\n break\n }\n }\n}\n"],"names":[],"mappings":"MAAa,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,sBAAsB,GAAG,MAAM,CAAC,2CAA2C;MAC3E,WAAW,GAAG,MAAM,CAAC,eAAe;MACpC,eAAe,GAAG,MAAM,CAAC,mBAAmB;MAC5C,iBAAiB,GAAG,MAAM,CAAC,oBAAoB;MAC/C,UAAU,GAAG,MAAM,CAAC,aAAa;MACjC,OAAO,GAAG,MAAM,CAAC,UAAU;AAyBlC,SAAU,0BAA0B,CAAC,QAAuB,EAAE,MAAsC,EAAE,UAAwB,EAAE,EAAA;AACpI,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACnB,CAAC;AACD,QAAA,IAAI,IAAI,GAAA;YACN,OAAO,IAAI,CAAC,KAAK;QACnB,CAAC;KACF;AACD,IAAA,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;AACjD;SAEgB,0BAA0B,CAAC,QAAuB,EAAE,UAAwB,EAAE,EAAA;AAC5F,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,MAAM,EAAE,EAAc;AACtB,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;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,CAAC,KAAK,CAAC,IAAI,CAAC;gBACzD;;IAEN;AACF;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sources":["../../../src/schema/load.ts"],"sourcesContent":["import { Schema, Validator } from 'jsonschema'\nimport { boom } from '../util/boom'\nimport arc32Schema from './application.schema.json' with { type: 'json' }\nimport arc56Schema from './arc56.schema.json' with { type: 'json' }\nimport contractSchema from './contract.schema.json' with { type: 'json' }\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/abi'\nimport { AppSpec, arc32ToArc56 } from '@algorandfoundation/algokit-utils/types/app-spec'\n\nexport async function loadApplicationJson(appJsonPath: string): Promise<Arc56Contract> {\n const fs = await import('fs')\n if (!fs.existsSync(appJsonPath)) boom(`Could not find application.json file at ${appJsonPath}`)\n\n let jsonText = fs.readFileSync(appJsonPath, 'utf-8')\n let file = JSON.parse(jsonText)\n // Temporary to get backwards compatibility with TEALScript draft ARC-56\n if (!('contract' in file) /* ARC-56 */) {\n jsonText = jsonText.replace(/ype\":\\s*\"bytes\"/g, 'ype\":\"AVMBytes\"').replace(/import\\(.+?\\)\\./g, '')\n file = JSON.parse(jsonText)\n }\n\n return validateApplicationJson(file, appJsonPath)\n}\n\nexport function validateApplicationJson(json: unknown, appJsonPath: string): Arc56Contract {\n if (typeof json !== 'object') boom(`Could not parse ${appJsonPath} as JSON object`)\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n if ('contract' in (json as any)) {\n // ARC-32\n const arc32Validator = new Validator()\n arc32Validator.addSchema(contractSchema, '/contract.schema.json')\n const arc32Result = arc32Validator.validate(json, arc32Schema as unknown as Schema)\n if (!arc32Result.valid) boom(`Could not parse ${appJsonPath} as ARC-32.\\n${arc32Result}`)\n return arc32ToArc56(json as AppSpec)\n }\n // ARC-56\n const arc56Validator = new Validator()\n const arc56Result = arc56Validator.validate(json, arc56Schema as unknown as Schema)\n if (!arc56Result.valid) boom(`Could not parse ${appJsonPath} as ARC-56.\\n${arc56Result}`)\n return json as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AmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,QAAA,OAAOI,oBAAY,CAAC,IAAe,CAAC;IACtC;;AAEA,IAAA,MAAM,cAAc,GAAG,IAAIH,oBAAS,EAAE;IACtC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAEI,oBAAgC,CAAC;IACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,QAAAL,SAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,IAAA,OAAO,IAAqB;AAC9B;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.mjs","sources":["../../../src/schema/load.ts"],"sourcesContent":["import { Schema, Validator } from 'jsonschema'\nimport { boom } from '../util/boom'\nimport arc32Schema from './application.schema.json' with { type: 'json' }\nimport arc56Schema from './arc56.schema.json' with { type: 'json' }\nimport contractSchema from './contract.schema.json' with { type: 'json' }\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/abi'\nimport { AppSpec, arc32ToArc56 } from '@algorandfoundation/algokit-utils/types/app-spec'\n\nexport async function loadApplicationJson(appJsonPath: string): Promise<Arc56Contract> {\n const fs = await import('fs')\n if (!fs.existsSync(appJsonPath)) boom(`Could not find application.json file at ${appJsonPath}`)\n\n let jsonText = fs.readFileSync(appJsonPath, 'utf-8')\n let file = JSON.parse(jsonText)\n // Temporary to get backwards compatibility with TEALScript draft ARC-56\n if (!('contract' in file) /* ARC-56 */) {\n jsonText = jsonText.replace(/ype\":\\s*\"bytes\"/g, 'ype\":\"AVMBytes\"').replace(/import\\(.+?\\)\\./g, '')\n file = JSON.parse(jsonText)\n }\n\n return validateApplicationJson(file, appJsonPath)\n}\n\nexport function validateApplicationJson(json: unknown, appJsonPath: string): Arc56Contract {\n if (typeof json !== 'object') boom(`Could not parse ${appJsonPath} as JSON object`)\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n if ('contract' in (json as any)) {\n // ARC-32\n const arc32Validator = new Validator()\n arc32Validator.addSchema(contractSchema, '/contract.schema.json')\n const arc32Result = arc32Validator.validate(json, arc32Schema as unknown as Schema)\n if (!arc32Result.valid) boom(`Could not parse ${appJsonPath} as ARC-32.\\n${arc32Result}`)\n return arc32ToArc56(json as AppSpec)\n }\n // ARC-56\n const arc56Validator = new Validator()\n const arc56Result = arc56Validator.validate(json, arc56Schema as unknown as Schema)\n if (!arc56Result.valid) boom(`Could not parse ${appJsonPath} as ARC-56.\\n${arc56Result}`)\n return json as Arc56Contract\n}\n"],"names":[],"mappings":";;;;;;;AAQO,eAAe,mBAAmB,CAAC,WAAmB,EAAA;AAC3D,IAAA,MAAM,EAAE,GAAG,MAAM,OAAO,IAAI,CAAC;AAC7B,IAAA,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;AAAE,QAAA,IAAI,CAAC,CAAA,wCAAA,EAA2C,WAAW,CAAA,CAAE,CAAC;IAE/F,IAAI,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC;IACpD,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;IAE/B,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,eAAe;AACtC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AAClG,QAAA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B;AAEA,IAAA,OAAO,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC;AACnD;AAEM,SAAU,uBAAuB,CAAC,IAAa,EAAE,WAAmB,EAAA;IACxE,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,IAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,CAAA,eAAA,CAAiB,CAAC;;AAGnF,IAAA,IAAI,UAAU,IAAK,IAAY,EAAE;;AAE/B,QAAA,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE;AACtC,QAAA,cAAc,CAAC,SAAS,CAAC,cAAc,EAAE,uBAAuB,CAAC;QACjE,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAgC,CAAC;QACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,YAAA,IAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,QAAA,OAAO,YAAY,CAAC,IAAe,CAAC;IACtC;;AAEA,IAAA,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE;IACtC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAgC,CAAC;IACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,QAAA,IAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,IAAA,OAAO,IAAqB;AAC9B;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boom.js","sources":["../../../src/util/boom.ts"],"sourcesContent":["export const boom = (reason: string): never => {\n throw new Error(reason)\n}\n"],"names":[],"mappings":";;AAAO,MAAM,IAAI,GAAG,CAAC,MAAc,KAAW;AAC5C,IAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;AACzB;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boom.mjs","sources":["../../../src/util/boom.ts"],"sourcesContent":["export const boom = (reason: string): never => {\n throw new Error(reason)\n}\n"],"names":[],"mappings":"AAAO,MAAM,IAAI,GAAG,CAAC,MAAc,KAAW;AAC5C,IAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;AACzB;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-console.js","sources":["../../../src/util/color-console.ts"],"sourcesContent":["import chalk from 'chalk'\n\ntype ColorFn = (text: string) => string\n\nconst createColorFormatter =\n (textColor: ColorFn, argColor: ColorFn, consoleFn: 'log' | 'error' | 'info' | 'warn') =>\n (textParts: TemplateStringsArray, ...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console[consoleFn](\n textParts\n .flatMap((t, i) => (args.length > i ? [textColor(t), argColor(`${args[i]}`)] : textColor(t)))\n .reduce((acc, cur) => acc + cur, ''),\n )\n }\n\nexport const colorConsole = {\n info: createColorFormatter(chalk.cyan, chalk.blue, 'info'),\n warn: createColorFormatter(chalk.yellow, chalk.yellow.bold, 'warn'),\n success: createColorFormatter(chalk.green, chalk.green.bold, 'info'),\n error: createColorFormatter(chalk.red, chalk.red.bold, 'error'),\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,oBAAoB,GACxB,CAAC,SAAkB,EAAE,QAAiB,EAAE,SAA4C,KACpF,CAAC,SAA+B,EAAE,GAAG,IAAe,KAAU;;AAE5D,IAAA,OAAO,CAAC,SAAS,CAAC,CAChB;AACG,SAAA,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3F,SAAA,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CACvC;AACH,CAAC;AAEI,MAAM,YAAY,GAAG;AAC1B,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AAC1D,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;AACnE,IAAA,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AACpE,IAAA,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-console.mjs","sources":["../../../src/util/color-console.ts"],"sourcesContent":["import chalk from 'chalk'\n\ntype ColorFn = (text: string) => string\n\nconst createColorFormatter =\n (textColor: ColorFn, argColor: ColorFn, consoleFn: 'log' | 'error' | 'info' | 'warn') =>\n (textParts: TemplateStringsArray, ...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console[consoleFn](\n textParts\n .flatMap((t, i) => (args.length > i ? [textColor(t), argColor(`${args[i]}`)] : textColor(t)))\n .reduce((acc, cur) => acc + cur, ''),\n )\n }\n\nexport const colorConsole = {\n info: createColorFormatter(chalk.cyan, chalk.blue, 'info'),\n warn: createColorFormatter(chalk.yellow, chalk.yellow.bold, 'warn'),\n success: createColorFormatter(chalk.green, chalk.green.bold, 'info'),\n error: createColorFormatter(chalk.red, chalk.red.bold, 'error'),\n}\n"],"names":[],"mappings":";;AAIA,MAAM,oBAAoB,GACxB,CAAC,SAAkB,EAAE,QAAiB,EAAE,SAA4C,KACpF,CAAC,SAA+B,EAAE,GAAG,IAAe,KAAU;;AAE5D,IAAA,OAAO,CAAC,SAAS,CAAC,CAChB;AACG,SAAA,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3F,SAAA,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CACvC;AACH,CAAC;AAEI,MAAM,YAAY,GAAG;AAC1B,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AAC1D,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;AACnE,IAAA,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AACpE,IAAA,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitization.js","sources":["../../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\nimport { GeneratorOptions } from '../client/generator-context'\n\nconst replaceInvalidWithUnderscore = (value: string) => value.replace(/[^a-z0-9_$]+/gi, '_')\n\nconst escapeQuotes = (value: string) => value.replace(/['\"]/g, (val) => `\\\\${val}`)\n\nconst removeEnclosingQuotes = (value: string) => value.replace(/^\"|\"$/g, '')\n\nexport interface Sanitizer {\n makeSafeTypeIdentifier(value: string): string\n makeSafeMethodIdentifier(value: string): string\n makeSafeVariableIdentifier(value: string): string\n makeSafePropertyIdentifier(value: string): string\n makeSafeStringTypeLiteral(value: string): string\n getSafeMemberAccessor(value: string): string\n isSafeVariableIdentifier(value: string): boolean\n}\n\nconst defaultSanitiser: Sanitizer = {\n makeSafePropertyIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeTypeIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return pascalCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeMethodIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n isSafeVariableIdentifier(value: string) {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeVariableIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${this.makeSafeStringTypeLiteral(value)}']`\n },\n}\n\nconst preservingSanitiser: Sanitizer = {\n isSafeVariableIdentifier(value: string): boolean {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeMethodIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafePropertyIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafeTypeIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeVariableIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`\n },\n}\n\nexport const getSanitizer = (options: GeneratorOptions) => (options.preserveNames ? preservingSanitiser : defaultSanitiser)\n"],"names":["camelCase","pascalCase"],"mappings":";;;;AAGA,MAAM,4BAA4B,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAE5F,MAAM,YAAY,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,CAAC;AAEnF,MAAM,qBAAqB,GAA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AyB,MAAM,OAAO,CAAC,aAAa,GAAG,mBAAmB,GAAG,gBAAgB;;;;"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitization.mjs","sources":["../../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\nimport { GeneratorOptions } from '../client/generator-context'\n\nconst replaceInvalidWithUnderscore = (value: string) => value.replace(/[^a-z0-9_$]+/gi, '_')\n\nconst escapeQuotes = (value: string) => value.replace(/['\"]/g, (val) => `\\\\${val}`)\n\nconst removeEnclosingQuotes = (value: string) => value.replace(/^\"|\"$/g, '')\n\nexport interface Sanitizer {\n makeSafeTypeIdentifier(value: string): string\n makeSafeMethodIdentifier(value: string): string\n makeSafeVariableIdentifier(value: string): string\n makeSafePropertyIdentifier(value: string): string\n makeSafeStringTypeLiteral(value: string): string\n getSafeMemberAccessor(value: string): string\n isSafeVariableIdentifier(value: string): boolean\n}\n\nconst defaultSanitiser: Sanitizer = {\n makeSafePropertyIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeTypeIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return pascalCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeMethodIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n isSafeVariableIdentifier(value: string) {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeVariableIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${this.makeSafeStringTypeLiteral(value)}']`\n },\n}\n\nconst preservingSanitiser: Sanitizer = {\n isSafeVariableIdentifier(value: string): boolean {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeMethodIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafePropertyIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafeTypeIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeVariableIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`\n },\n}\n\nexport const getSanitizer = (options: GeneratorOptions) => (options.preserveNames ? preservingSanitiser : defaultSanitiser)\n"],"names":[],"mappings":";;AAGA,MAAM,4BAA4B,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAE5F,MAAM,YAAY,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,CAAC;AAEnF,MAAM,qBAAqB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;AAY5E,MAAM,gBAAgB,GAAc;AAClC,IAAA,0BAA0B,CAAC,KAAa,EAAA;QACtC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE;QACtE,OAAO,SAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChE,CAAC;AACD,IAAA,sBAAsB,CAAC,KAAa,EAAA;QAClC,MAAM,OAAO,GAAG,KAAK,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AC,wBAAwB,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAA,CAAA,CAAG;IACpG,CAAC;AACD,IAAA,0BAA0B,CAAC,KAAa,EAAA;QACtC,OAAO,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAA,CAAA,CAAG;IACpG,CAAC;AACD,IAAA,sBAAsB,CAAC,KAAa,EAAA;AAClC,QAAA,OAAO,4BAA4B,CAAC,KAAK,CAAC;IAC5C,CAAC;AACD,IAAA,0BAA0B,CAAC,KAAa,EAAA;AACtC,QAAA,OAAO,4BAA4B,CAAC,KAAK,CAAC;IAC5C,CAAC;AACD,IAAA,yBAAyB,CAAC,KAAa,EAAA;AACrC,QAAA,OAAO,YAAY,CAAC,KAAK,CAAC;IAC5B,CAAC;AACD,IAAA,qBAAqB,CAAC,KAAa,EAAA;QACjC,OAAO,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,GAAG,CAAA,EAAA,EAAK,qBAAqB,CAAC,KAAK,CAAC,CAAA,EAAA,CAAI;IACnG,CAAC;CACF;MAEY,YAAY,GAAG,CAAC,OAAyB,MAAM,OAAO,CAAC,aAAa,GAAG,mBAAmB,GAAG,gBAAgB;;;;"}
package/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import { Command, Option } from 'commander'\nimport { loadApplicationJson } from './schema/load'\nimport * as path from 'path'\nimport { generate } from './client/generate'\nimport { writeDocumentPartsToStream } from './output/writer'\nimport { colorConsole } from './util/color-console'\nimport { GenerateMode, generateModes, GeneratorOptions } from './client/generator-context'\n\nexport function cli(workingDirectory: string, args: string[]) {\n // Pre 13 commander allowed `-pn` however the latest version doesn't. Rewrite it to `--pn` for backwards compatibility.\n const processedArgs = args.map((arg) => (arg === '-pn' ? '--pn' : arg))\n const program = new Command()\n program\n .command('generate')\n .description('Generates a TypeScript client for the given application.json file')\n .requiredOption('-a --application <path>', 'Specifies the application.json file')\n .requiredOption('-o --output <path>', 'Specifies the output file path')\n .option('--pn --preserve-names', 'Preserve names from application.json spec instead of sanitizing them')\n .addOption(\n new Option(\n '-m --mode <mode>',\n \"Generate client in specified mode. The 'full' mode includes all features, 'minimal' generates a smaller client without deployment features.\",\n )\n .choices(generateModes)\n .default('full'),\n )\n .allowExcessArguments(true) // Maintains backwards compatibility with pre 13 commanded\n .action(\n async ({\n application,\n output,\n preserveNames,\n mode,\n }: {\n application: string\n output: string\n preserveNames?: boolean\n mode?: GenerateMode\n }): Promise<void> => {\n await generateClientCommand({\n application,\n output,\n preserveNames: Boolean(preserveNames),\n mode: (mode ?? 'full') as GenerateMode,\n workingDirectory,\n })\n colorConsole.success`Operation completed successfully`\n },\n )\n .configureOutput({\n writeErr(str: string) {\n colorConsole.error`${str}`\n },\n })\n try {\n program.parse(processedArgs)\n } catch (err) {\n if (err instanceof Error) {\n colorConsole.error`Unhandled error: \\n\\n${err.stack}`\n } else {\n colorConsole.error`Unhandled error: \\n\\n${err}`\n }\n process.exit(-1)\n }\n}\n\nexport async function generateClientCommand({\n application,\n output,\n preserveNames,\n mode,\n workingDirectory,\n}: {\n application: string\n output: string\n workingDirectory: string\n} & GeneratorOptions): Promise<void> {\n const fs = await import('fs')\n\n const resolvedAppJsonPath = path.resolve(workingDirectory, application)\n const resolvedOutPath = path.resolve(workingDirectory, output)\n const resolvedOutDir = path.dirname(resolvedOutPath)\n colorConsole.info`Reading application.json file from path ${resolvedAppJsonPath}`\n const spec = await loadApplicationJson(resolvedAppJsonPath)\n colorConsole.info`Generating TS client for ${spec.name}`\n const parts = generate(spec, { preserveNames, mode })\n if (!fs.existsSync(resolvedOutDir)) {\n colorConsole.warn`Output directory ${resolvedOutDir} does not exist and will be created.`\n fs.mkdirSync(resolvedOutDir, { recursive: true })\n }\n colorConsole.info`Writing TS client to ${resolvedOutPath}`\n const file = await createAwaitableWriteStream(resolvedOutPath)\n writeDocumentPartsToStream(parts, file)\n await file.finish()\n}\n\nasync function createAwaitableWriteStream(path: string) {\n const fs = await import('fs')\n const stream = fs.createWriteStream(path, {\n flags: 'w',\n })\n const finish = new Promise<void>((resolve, reject) => {\n stream.on('error', (err) => {\n reject(err)\n })\n stream.on('finish', () => {\n resolve()\n })\n })\n return {\n write(chunk: string): void {\n stream.write(chunk)\n },\n finish() {\n stream.end()\n return finish\n },\n }\n}\n"],"names":["Command","Option","generateModes","colorConsole","path","loadApplicationJson","generate","writeDocumentPartsToStream"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQM,SAAU,GAAG,CAAC,gBAAwB,EAAE,IAAc,EAAA;;IAE1D,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,KAAK,GAAG,MAAM,GAAG,GAAG,CAAC,CAAC;AACvE,IAAA,MAAM,OAAO,GAAG,IAAIA,iBAAO,EAAE;IAC7B;SACG,OAAO,CAAC,UAAU;SAClB,WAAW,CAAC,mEAAmE;AAC/E,SAAA,cAAc,CAAC,yBAAyB,EAAE,qCAAqC;AAC/E,SAAA,cAAc,CAAC,oBAAoB,EAAE,gCAAgC;AACrE,SAAA,MAAM,CAAC,uBAAuB,EAAE,sEAAsE;AACtG,SAAA,SAAS,CACR,IAAIC,gBAAM,CACR,kBAAkB,EAClB,6IAA6I;SAE5I,OAAO,CAACC,8BAAa;SACrB,OAAO,CAAC,MAAM,CAAC;AAEnB,SAAA,oBAAoB,CAAC,IAAI,CAAC;AAC1B,SAAA,MAAM,CACL,OAAO,EACL,WAAW,EACX,MAAM,EACN,aAAa,EACb,IAAI,GAML,KAAmB;AAClB,QAAA,MAAM,qBAAqB,CAAC;YAC1B,WAAW;YACX,MAAM;AACN,YAAA,aAAa,EAAE,OAAO,CAAC,aAAa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