@algorandfoundation/algokit-client-generator 2.6.0-beta.1 → 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.
Files changed (128) hide show
  1. package/bin/cli.mjs +4 -0
  2. package/cli.cjs +75 -0
  3. package/cli.d.ts +0 -1
  4. package/cli.mjs +54 -0
  5. package/client/app-types.cjs +152 -0
  6. package/client/app-types.d.ts +0 -1
  7. package/client/app-types.mjs +131 -0
  8. package/client/call-client.cjs +332 -0
  9. package/client/call-client.d.ts +0 -1
  10. package/client/{call-client.js → call-client.mjs} +107 -135
  11. package/client/call-composer-types.cjs +141 -0
  12. package/client/call-composer-types.d.ts +0 -1
  13. package/client/{call-composer-types.js → call-composer-types.mjs} +33 -58
  14. package/client/call-composer.cjs +145 -0
  15. package/client/call-composer.d.ts +0 -1
  16. package/client/call-composer.mjs +124 -0
  17. package/client/call-factory.cjs +138 -0
  18. package/client/call-factory.d.ts +0 -1
  19. package/client/{call-factory.js → call-factory.mjs} +31 -56
  20. package/client/deploy-types.cjs +94 -0
  21. package/client/deploy-types.d.ts +0 -1
  22. package/client/deploy-types.mjs +91 -0
  23. package/client/generate.cjs +37 -0
  24. package/client/generate.d.ts +0 -1
  25. package/client/generate.mjs +35 -0
  26. package/client/generator-context.cjs +37 -0
  27. package/client/generator-context.d.ts +0 -1
  28. package/client/generator-context.mjs +16 -0
  29. package/client/helpers/{get-call-config-summary.js → get-call-config-summary.cjs} +7 -25
  30. package/client/helpers/get-call-config-summary.d.ts +1 -2
  31. package/client/helpers/get-call-config-summary.mjs +54 -0
  32. package/client/helpers/{get-equivalent-type.js → get-equivalent-type.cjs} +20 -20
  33. package/client/helpers/get-equivalent-type.d.ts +0 -1
  34. package/client/helpers/get-equivalent-type.mjs +56 -0
  35. package/client/{imports.js → imports.cjs} +3 -4
  36. package/client/imports.d.ts +0 -1
  37. package/client/imports.mjs +27 -0
  38. package/client/{utility-types.js → utility-types.cjs} +26 -25
  39. package/client/utility-types.d.ts +0 -1
  40. package/client/utility-types.mjs +47 -0
  41. package/dev.d.ts +0 -1
  42. package/index.cjs +13 -0
  43. package/index.d.ts +0 -1
  44. package/index.mjs +3 -0
  45. package/output/{writer.js → writer.cjs} +44 -38
  46. package/output/writer.d.ts +0 -1
  47. package/output/writer.mjs +139 -0
  48. package/package.json +7 -4
  49. package/schema/application.schema.json.cjs +374 -0
  50. package/schema/application.schema.json.mjs +363 -0
  51. package/schema/contract.schema.json.cjs +159 -0
  52. package/schema/contract.schema.json.mjs +148 -0
  53. package/schema/load.cjs +25 -0
  54. package/schema/load.d.ts +0 -1
  55. package/schema/load.mjs +22 -0
  56. package/tests/approval-tests.spec.d.ts +0 -1
  57. package/tests/util.d.ts +1 -0
  58. package/util/boom.cjs +7 -0
  59. package/util/boom.d.ts +0 -1
  60. package/util/boom.mjs +5 -0
  61. package/util/color-console.cjs +18 -0
  62. package/util/color-console.d.ts +0 -1
  63. package/util/color-console.mjs +16 -0
  64. package/util/not-falsy.d.ts +0 -1
  65. package/util/sanitization.cjs +17 -0
  66. package/util/sanitization.d.ts +0 -1
  67. package/util/sanitization.mjs +11 -0
  68. package/bin/cli.js +0 -4
  69. package/cli.d.ts.map +0 -1
  70. package/cli.js +0 -79
  71. package/cli.js.map +0 -1
  72. package/client/app-types.d.ts.map +0 -1
  73. package/client/app-types.js +0 -161
  74. package/client/app-types.js.map +0 -1
  75. package/client/call-client.d.ts.map +0 -1
  76. package/client/call-client.js.map +0 -1
  77. package/client/call-composer-types.d.ts.map +0 -1
  78. package/client/call-composer-types.js.map +0 -1
  79. package/client/call-composer.d.ts.map +0 -1
  80. package/client/call-composer.js +0 -151
  81. package/client/call-composer.js.map +0 -1
  82. package/client/call-factory.d.ts.map +0 -1
  83. package/client/call-factory.js.map +0 -1
  84. package/client/deploy-types.d.ts.map +0 -1
  85. package/client/deploy-types.js +0 -95
  86. package/client/deploy-types.js.map +0 -1
  87. package/client/generate.d.ts.map +0 -1
  88. package/client/generate.js +0 -37
  89. package/client/generate.js.map +0 -1
  90. package/client/generator-context.d.ts.map +0 -1
  91. package/client/generator-context.js +0 -41
  92. package/client/generator-context.js.map +0 -1
  93. package/client/helpers/get-call-config-summary.d.ts.map +0 -1
  94. package/client/helpers/get-call-config-summary.js.map +0 -1
  95. package/client/helpers/get-equivalent-type.d.ts.map +0 -1
  96. package/client/helpers/get-equivalent-type.js.map +0 -1
  97. package/client/imports.d.ts.map +0 -1
  98. package/client/imports.js.map +0 -1
  99. package/client/utility-types.d.ts.map +0 -1
  100. package/client/utility-types.js.map +0 -1
  101. package/dev.d.ts.map +0 -1
  102. package/dev.js +0 -5
  103. package/dev.js.map +0 -1
  104. package/index.d.ts.map +0 -1
  105. package/index.js +0 -12
  106. package/index.js.map +0 -1
  107. package/output/writer.d.ts.map +0 -1
  108. package/output/writer.js.map +0 -1
  109. package/schema/application.schema.json +0 -354
  110. package/schema/contract.schema.json +0 -139
  111. package/schema/load.d.ts.map +0 -1
  112. package/schema/load.js +0 -51
  113. package/schema/load.js.map +0 -1
  114. package/tests/approval-tests.spec.d.ts.map +0 -1
  115. package/tests/approval-tests.spec.js +0 -24
  116. package/tests/approval-tests.spec.js.map +0 -1
  117. package/util/boom.d.ts.map +0 -1
  118. package/util/boom.js +0 -8
  119. package/util/boom.js.map +0 -1
  120. package/util/color-console.d.ts.map +0 -1
  121. package/util/color-console.js +0 -20
  122. package/util/color-console.js.map +0 -1
  123. package/util/not-falsy.d.ts.map +0 -1
  124. package/util/not-falsy.js +0 -6
  125. package/util/not-falsy.js.map +0 -1
  126. package/util/sanitization.d.ts.map +0 -1
  127. package/util/sanitization.js +0 -17
  128. package/util/sanitization.js.map +0 -1
@@ -0,0 +1,139 @@
1
+ const IncIndent = Symbol('Increase Indent');
2
+ const DecIndent = Symbol('Decrease Indent');
3
+ const DecIndentAndCloseBlock = Symbol('Decrease Indent and write a closing brace');
4
+ const NewLineMode = Symbol('New Line Mode');
5
+ const RestoreLineMode = Symbol('Restore Line Mode');
6
+ const PropertyDelimiter = Symbol('Property Delimiter');
7
+ const InlineMode = Symbol('Inline Mode');
8
+ const NewLine = Symbol('New Line');
9
+ function writeDocumentPartsToStream(document, stream, options = {}) {
10
+ const writer = {
11
+ _last: '',
12
+ write(val) {
13
+ this._last = val;
14
+ stream.write(val);
15
+ },
16
+ get last() {
17
+ return this._last;
18
+ },
19
+ };
20
+ writeDocumentPartsTo(document, options, writer);
21
+ }
22
+ function writeDocumentPartsToString(document, options = {}) {
23
+ const writer = {
24
+ result: [],
25
+ _last: '',
26
+ write(val) {
27
+ this._last = val;
28
+ this.result.push(val);
29
+ },
30
+ get last() {
31
+ return this._last;
32
+ },
33
+ toString() {
34
+ return this.result.join('');
35
+ },
36
+ };
37
+ writeDocumentPartsTo(document, options, writer);
38
+ return writer.toString();
39
+ }
40
+ function* inline(...parts) {
41
+ yield InlineMode;
42
+ for (const part of parts) {
43
+ if (typeof part === 'string' || typeof part === 'symbol')
44
+ yield part;
45
+ else
46
+ yield* part;
47
+ }
48
+ yield RestoreLineMode;
49
+ }
50
+ function* indent(...parts) {
51
+ yield IncIndent;
52
+ for (const part of parts) {
53
+ if (typeof part === 'string' || typeof part === 'symbol')
54
+ yield part;
55
+ else
56
+ yield* part;
57
+ }
58
+ yield DecIndent;
59
+ }
60
+ function* jsDoc(docs) {
61
+ yield `/**`;
62
+ if (typeof docs === 'string') {
63
+ yield ` * ${docs}`;
64
+ }
65
+ else {
66
+ yield ` * ${docs.description}`;
67
+ if (docs.abiDescription) {
68
+ yield ' *';
69
+ yield ` * ${docs.abiDescription}`;
70
+ }
71
+ if (docs.params || docs.returns) {
72
+ yield ' *';
73
+ }
74
+ for (const [paramName, paramDesc] of Object.entries(docs.params ?? {})) {
75
+ yield ` * @param ${paramName} ${paramDesc}`;
76
+ }
77
+ if (docs.returns)
78
+ yield ` * @returns ${docs.returns}`;
79
+ }
80
+ yield ' */';
81
+ }
82
+ function writeDocumentPartsTo(document, { indent = ' ', ...options }, writer) {
83
+ if (options.header)
84
+ writer.write(`${options.header}\n`);
85
+ if (options.disableEslint)
86
+ writer.write('/* eslint-disable */\n');
87
+ const lineModes = [NewLineMode];
88
+ const currentLineMode = () => lineModes.at(-1) ?? NewLineMode;
89
+ let curIndent = '';
90
+ for (const part of document) {
91
+ switch (part) {
92
+ case IncIndent:
93
+ curIndent += indent;
94
+ break;
95
+ case DecIndent:
96
+ curIndent = curIndent.slice(0, -indent.length);
97
+ break;
98
+ case DecIndentAndCloseBlock:
99
+ curIndent = curIndent.slice(0, -indent.length);
100
+ writer.write(`${curIndent}}\n`);
101
+ break;
102
+ case NewLineMode:
103
+ lineModes.push(NewLineMode);
104
+ if (writer.last.slice(-1)[0] !== '\n') {
105
+ writer.write('\n');
106
+ }
107
+ break;
108
+ case InlineMode:
109
+ lineModes.push(InlineMode);
110
+ break;
111
+ case RestoreLineMode:
112
+ lineModes.pop();
113
+ if (currentLineMode() === NewLineMode && writer.last.slice(-1)[0] !== '\n') {
114
+ writer.write('\n');
115
+ }
116
+ break;
117
+ case PropertyDelimiter:
118
+ if (currentLineMode() === NewLineMode) {
119
+ writer.write('\n');
120
+ }
121
+ else {
122
+ writer.write(', ');
123
+ }
124
+ break;
125
+ case NewLine:
126
+ writer.write('\n');
127
+ break;
128
+ default:
129
+ if (writer.last.slice(-1)[0] === '\n')
130
+ writer.write(curIndent);
131
+ writer.write(part);
132
+ if (currentLineMode() === NewLineMode)
133
+ writer.write('\n');
134
+ break;
135
+ }
136
+ }
137
+ }
138
+
139
+ export { DecIndent, DecIndentAndCloseBlock, IncIndent, InlineMode, NewLine, NewLineMode, PropertyDelimiter, RestoreLineMode, indent, inline, jsDoc, writeDocumentPartsToStream, writeDocumentPartsToString };
package/package.json CHANGED
@@ -2,12 +2,15 @@
2
2
  "main": "index.js",
3
3
  "types": "index.d.ts",
4
4
  "name": "@algorandfoundation/algokit-client-generator",
5
- "version": "2.6.0-beta.1",
5
+ "version": "2.6.1-beta.1",
6
6
  "description": "Generates a TypeScript client for interacting with, and deploying ARC-0032 smart contracts on the Algorand Blockchain.",
7
7
  "private": false,
8
+ "engines": {
9
+ "node": ">=19.0"
10
+ },
8
11
  "bin": {
9
- "@algorandfoundation/algokit-client-generator": "bin/cli.js",
10
- "algokitgen": "bin/cli.js"
12
+ "@algorandfoundation/algokit-client-generator": "bin/cli.mjs",
13
+ "algokitgen": "bin/cli.mjs"
11
14
  },
12
15
  "author": "Algorand Foundation",
13
16
  "license": "MIT",
@@ -19,7 +22,7 @@
19
22
  "algosdk": "^2.7.0",
20
23
  "chalk": "^4.1.2",
21
24
  "change-case": "^4.1.2",
22
- "commander": "^11.0.0",
25
+ "commander": "^11.1.0",
23
26
  "jsonschema": "^1.4.1"
24
27
  },
25
28
  "publishConfig": {
@@ -0,0 +1,374 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var $schema = "http://json-schema.org/draft-07/schema";
6
+ var title = "AlgoAppSpec";
7
+ var type = "object";
8
+ var required = [
9
+ "contract",
10
+ "schema",
11
+ "source",
12
+ "state"
13
+ ];
14
+ var additionalProperties = true;
15
+ var properties = {
16
+ hints: {
17
+ type: "object",
18
+ additionalProperties: {
19
+ $ref: "#/definitions/Hint"
20
+ }
21
+ },
22
+ source: {
23
+ $ref: "#/definitions/AppSources"
24
+ },
25
+ contract: {
26
+ $ref: "contract.schema.json"
27
+ },
28
+ schema: {
29
+ $ref: "#/definitions/SchemaSpec"
30
+ },
31
+ state: {
32
+ $ref: "#/definitions/StateSchemaSpec"
33
+ },
34
+ bare_call_config: {
35
+ $ref: "#/definitions/CallConfig"
36
+ }
37
+ };
38
+ var definitions = {
39
+ AVMType: {
40
+ description: "AVM data type",
41
+ "enum": [
42
+ "uint64",
43
+ "bytes"
44
+ ]
45
+ },
46
+ DeclaredSchemaValueSpec: {
47
+ type: "object",
48
+ required: [
49
+ "type",
50
+ "key"
51
+ ],
52
+ additionalProperties: true,
53
+ properties: {
54
+ type: {
55
+ description: "The type of the value",
56
+ $ref: "#/definitions/AVMType"
57
+ },
58
+ key: {
59
+ description: "The name of the key",
60
+ type: "string"
61
+ },
62
+ descr: {
63
+ description: "A description of the variable",
64
+ type: "string"
65
+ },
66
+ "static": {
67
+ description: "Whether the value is set statically (at create time only) or dynamically",
68
+ type: "boolean"
69
+ }
70
+ }
71
+ },
72
+ ReservedSchemaValueSpec: {
73
+ type: "object",
74
+ required: [
75
+ "type"
76
+ ],
77
+ properties: {
78
+ type: {
79
+ description: "The type of the value",
80
+ $ref: "#/definitions/AVMType"
81
+ },
82
+ descr: {
83
+ description: "A description of the variable",
84
+ type: "string"
85
+ },
86
+ max_keys: {
87
+ description: "The maximum number of slots to reserve",
88
+ type: "integer"
89
+ }
90
+ }
91
+ },
92
+ StateSchemaSpec: {
93
+ type: "object",
94
+ additionalProperties: true,
95
+ required: [
96
+ "global",
97
+ "local"
98
+ ],
99
+ properties: {
100
+ global: {
101
+ $ref: "#/definitions/StateSchema"
102
+ },
103
+ local: {
104
+ $ref: "#/definitions/StateSchema"
105
+ }
106
+ }
107
+ },
108
+ StateSchema: {
109
+ type: "object",
110
+ additionalProperties: true,
111
+ required: [
112
+ "num_byte_slices",
113
+ "num_uints"
114
+ ],
115
+ properties: {
116
+ num_uints: {
117
+ type: "integer"
118
+ },
119
+ num_byte_slices: {
120
+ type: "integer"
121
+ }
122
+ }
123
+ },
124
+ SchemaSpec: {
125
+ description: "The schema for global and local storage",
126
+ type: "object",
127
+ additionalProperties: true,
128
+ properties: {
129
+ global: {
130
+ $ref: "#/definitions/Schema"
131
+ },
132
+ local: {
133
+ $ref: "#/definitions/Schema"
134
+ }
135
+ }
136
+ },
137
+ Schema: {
138
+ type: "object",
139
+ additionalProperties: true,
140
+ properties: {
141
+ declared: {
142
+ type: "object",
143
+ additionalProperties: {
144
+ $ref: "#/definitions/DeclaredSchemaValueSpec"
145
+ }
146
+ },
147
+ reserved: {
148
+ type: "object",
149
+ additionalProperties: {
150
+ $ref: "#/definitions/ReservedSchemaValueSpec"
151
+ }
152
+ }
153
+ }
154
+ },
155
+ AppSources: {
156
+ type: "object",
157
+ additionalProperties: true,
158
+ properties: {
159
+ approval: {
160
+ type: "string"
161
+ },
162
+ clear: {
163
+ type: "string"
164
+ }
165
+ }
166
+ },
167
+ Hint: {
168
+ type: "object",
169
+ additionalProperties: true,
170
+ properties: {
171
+ read_only: {
172
+ type: "boolean"
173
+ },
174
+ structs: {
175
+ type: "object",
176
+ properties: {
177
+ output: {
178
+ $ref: "#/definitions/Struct"
179
+ }
180
+ },
181
+ additionalProperties: {
182
+ $ref: "#/definitions/Struct"
183
+ }
184
+ },
185
+ default_arguments: {
186
+ additionalProperties: {
187
+ $ref: "#/definitions/DefaultArgument"
188
+ }
189
+ },
190
+ call_config: {
191
+ $ref: "#/definitions/CallConfig"
192
+ }
193
+ }
194
+ },
195
+ CallConfig: {
196
+ type: "object",
197
+ additionalProperties: false,
198
+ properties: {
199
+ no_op: {
200
+ $ref: "#/definitions/CallConfigValue"
201
+ },
202
+ opt_in: {
203
+ $ref: "#/definitions/CallConfigValue"
204
+ },
205
+ close_out: {
206
+ $ref: "#/definitions/CallConfigValue"
207
+ },
208
+ update_application: {
209
+ $ref: "#/definitions/CallConfigValue"
210
+ },
211
+ delete_application: {
212
+ $ref: "#/definitions/CallConfigValue"
213
+ }
214
+ }
215
+ },
216
+ CallConfigValue: {
217
+ "enum": [
218
+ "NEVER",
219
+ "CALL",
220
+ "CREATE",
221
+ "ALL"
222
+ ]
223
+ },
224
+ Struct: {
225
+ type: "object",
226
+ additionalProperties: true,
227
+ required: [
228
+ "name",
229
+ "elements"
230
+ ],
231
+ properties: {
232
+ name: {
233
+ type: "string"
234
+ },
235
+ elements: {
236
+ type: "array",
237
+ items: {
238
+ $ref: "#/definitions/StructElement"
239
+ }
240
+ }
241
+ }
242
+ },
243
+ FieldName: {
244
+ type: "string"
245
+ },
246
+ ABIType: {
247
+ type: "string"
248
+ },
249
+ StructElement: {
250
+ type: "array",
251
+ minItems: 2,
252
+ items: [
253
+ {
254
+ $ref: "#/definitions/FieldName"
255
+ },
256
+ {
257
+ $ref: "#/definitions/ABIType"
258
+ }
259
+ ]
260
+ },
261
+ DefaultArgument: {
262
+ description: "Defines a strategy for obtaining a default value for a given ABI arg.",
263
+ oneOf: [
264
+ {
265
+ type: "object",
266
+ required: [
267
+ "source",
268
+ "data"
269
+ ],
270
+ additionalProperties: true,
271
+ properties: {
272
+ source: {
273
+ description: "The default value should be fetched by invoking an ABI method",
274
+ "enum": [
275
+ "abi-method"
276
+ ]
277
+ },
278
+ data: {
279
+ description: "The contract of the ABI method to invoke.",
280
+ $ref: "contract.schema.json#/definitions/ContractMethod"
281
+ }
282
+ }
283
+ },
284
+ {
285
+ type: "object",
286
+ required: [
287
+ "source",
288
+ "data"
289
+ ],
290
+ additionalProperties: true,
291
+ properties: {
292
+ source: {
293
+ description: "The default value should be fetched from global state",
294
+ "enum": [
295
+ "global-state"
296
+ ]
297
+ },
298
+ data: {
299
+ description: "The key of the state variable",
300
+ type: "string"
301
+ }
302
+ }
303
+ },
304
+ {
305
+ type: "object",
306
+ required: [
307
+ "source",
308
+ "data"
309
+ ],
310
+ additionalProperties: true,
311
+ properties: {
312
+ source: {
313
+ description: "The default value should be fetched from the local state of the sender user",
314
+ "enum": [
315
+ "local-state"
316
+ ]
317
+ },
318
+ data: {
319
+ description: "The key of the state variable",
320
+ type: "string"
321
+ }
322
+ }
323
+ },
324
+ {
325
+ type: "object",
326
+ required: [
327
+ "source",
328
+ "data"
329
+ ],
330
+ additionalProperties: true,
331
+ properties: {
332
+ source: {
333
+ description: "The default value is a constant.",
334
+ "enum": [
335
+ "constant"
336
+ ]
337
+ },
338
+ data: {
339
+ description: "The static default value to use.",
340
+ anyOf: [
341
+ {
342
+ type: "string"
343
+ },
344
+ {
345
+ type: "number"
346
+ },
347
+ {
348
+ type: "integer"
349
+ }
350
+ ]
351
+ }
352
+ }
353
+ }
354
+ ]
355
+ }
356
+ };
357
+ var appJsonSchema = {
358
+ $schema: $schema,
359
+ title: title,
360
+ type: type,
361
+ required: required,
362
+ additionalProperties: additionalProperties,
363
+ properties: properties,
364
+ definitions: definitions
365
+ };
366
+
367
+ exports.$schema = $schema;
368
+ exports.additionalProperties = additionalProperties;
369
+ exports.default = appJsonSchema;
370
+ exports.definitions = definitions;
371
+ exports.properties = properties;
372
+ exports.required = required;
373
+ exports.title = title;
374
+ exports.type = type;