@algorandfoundation/algokit-client-generator 6.0.0-beta.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -4
- package/cli.d.ts +3 -3
- package/cli.js +12 -4
- package/cli.js.map +1 -1
- package/cli.mjs +13 -5
- package/cli.mjs.map +1 -1
- package/client/app-client.js +4 -2
- package/client/app-client.js.map +1 -1
- package/client/app-client.mjs +4 -2
- package/client/app-client.mjs.map +1 -1
- package/client/call-composer-types.js +7 -5
- package/client/call-composer-types.js.map +1 -1
- package/client/call-composer-types.mjs +7 -5
- package/client/call-composer-types.mjs.map +1 -1
- package/client/call-composer.js +4 -2
- package/client/call-composer.js.map +1 -1
- package/client/call-composer.mjs +4 -2
- package/client/call-composer.mjs.map +1 -1
- package/client/generate.d.ts +1 -1
- package/client/generate.js +59 -8
- package/client/generate.js.map +1 -1
- package/client/generate.mjs +59 -8
- package/client/generate.mjs.map +1 -1
- package/client/generator-context.d.ts +10 -7
- package/client/generator-context.js +7 -0
- package/client/generator-context.js.map +1 -1
- package/client/generator-context.mjs +7 -1
- package/client/generator-context.mjs.map +1 -1
- package/client/imports.d.ts +2 -1
- package/client/imports.js +2 -3
- package/client/imports.js.map +1 -1
- package/client/imports.mjs +2 -3
- package/client/imports.mjs.map +1 -1
- package/client/params-factory.js +5 -3
- package/client/params-factory.js.map +1 -1
- package/client/params-factory.mjs +5 -3
- package/client/params-factory.mjs.map +1 -1
- package/package.json +2 -8
- package/util/sanitization.d.ts +2 -3
- package/util/sanitization.js +1 -1
- package/util/sanitization.js.map +1 -1
- package/util/sanitization.mjs +1 -1
- package/util/sanitization.mjs.map +1 -1
- package/tests/approval-tests.spec.d.ts +0 -1
package/client/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nexport function* generate(app: Arc56Contract, options: GeneratorOptions = { preserveNames: false }
|
|
1
|
+
{"version":3,"file":"generate.js","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, ProgramSourceInfo, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nfunction shrinkAppSpec(app: Arc56Contract, options: GeneratorOptions): Arc56Contract {\n const strippedAppSpec = structuredClone(app)\n\n // Only keep the source info if it is needed for error mapping\n const shrinkSourceInfo = (sourceInfo: ProgramSourceInfo['sourceInfo']) => {\n return sourceInfo\n .filter((entry) => entry.errorMessage)\n .map((entry) => ({\n pc: entry.pc,\n errorMessage: entry.errorMessage,\n // Keep minimal context for error mapping if available\n ...(entry.teal !== undefined && { teal: entry.teal }),\n }))\n }\n\n // Keep only source info entries that can be used for approval and clear program error mapping\n if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo)\n }\n\n if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo)\n }\n\n if (strippedAppSpec.compilerInfo) {\n delete strippedAppSpec.compilerInfo\n }\n\n // These are used for deploying but not for calling deployed apps\n if (options.mode === 'minimal') {\n if (strippedAppSpec.source) {\n delete strippedAppSpec.source\n }\n if (strippedAppSpec.byteCode) {\n delete strippedAppSpec.byteCode\n }\n if (strippedAppSpec.templateVariables) {\n delete strippedAppSpec.templateVariables\n }\n if (strippedAppSpec.scratchVariables) {\n delete strippedAppSpec.scratchVariables\n }\n }\n return strippedAppSpec\n}\n\nexport function* generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts {\n const resolvedOptions: GeneratorOptions = {\n // Set defaults\n preserveNames: false,\n mode: 'full',\n ...options,\n }\n const reduceAppSpec = shrinkAppSpec(app, resolvedOptions)\n\n const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports(ctx)\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n reduceAppSpec.structs = Object.fromEntries(\n Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]),\n )\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n\n if (ctx.mode === 'full') {\n yield* deployTypes(ctx)\n }\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory in full mode\n if (ctx.mode === 'full') {\n yield* appFactory(ctx)\n }\n // Write a client\n yield* appClient(ctx)\n\n yield* callComposerType(ctx)\n}\n"],"names":["createGeneratorContext","imports","inline","NewLine","utilityTypes","appTypes","deployTypes","paramsFactory","appFactory","appClient","callComposerType"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,cAAc,CAAC,CAAgB,EAAE,SAAoB,EAAA;AAC5D,IAAA,OAAO,CAAC,CAAC,GAAG,CACV,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MACZ;AACC,QAAA,IAAI,EAAE,SAAS,CAAC,0BAA0B,CAAC,IAAI,CAAC;AAChD,QAAA,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC;AACxE,KAAA,CAAuB,CAC3B;AACH;AAEA,SAAS,aAAa,CAAC,GAAkB,EAAE,OAAyB,EAAA;AAClE,IAAA,MAAM,eAAe,GAAG,eAAe,CAAC,GAAG,CAAC;;AAG5C,IAAA,MAAM,gBAAgB,GAAG,CAAC,UAA2C,KAAI;AACvE,QAAA,OAAO;aACJ,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,YAAY;AACpC,aAAA,GAAG,CAAC,CAAC,KAAK,MAAM;YACf,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,YAAY,EAAE,KAAK,CAAC,YAAY;;AAEhC,YAAA,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,EA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;"}
|
package/client/generate.mjs
CHANGED
|
@@ -15,30 +15,81 @@ function convertStructs(s, sanitizer) {
|
|
|
15
15
|
type: typeof type === 'string' ? type : convertStructs(type, sanitizer),
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const
|
|
18
|
+
function shrinkAppSpec(app, options) {
|
|
19
|
+
const strippedAppSpec = structuredClone(app);
|
|
20
|
+
// Only keep the source info if it is needed for error mapping
|
|
21
|
+
const shrinkSourceInfo = (sourceInfo) => {
|
|
22
|
+
return sourceInfo
|
|
23
|
+
.filter((entry) => entry.errorMessage)
|
|
24
|
+
.map((entry) => ({
|
|
25
|
+
pc: entry.pc,
|
|
26
|
+
errorMessage: entry.errorMessage,
|
|
27
|
+
// Keep minimal context for error mapping if available
|
|
28
|
+
...(entry.teal !== undefined && { teal: entry.teal }),
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
// Keep only source info entries that can be used for approval and clear program error mapping
|
|
32
|
+
if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {
|
|
33
|
+
strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo);
|
|
34
|
+
}
|
|
35
|
+
if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {
|
|
36
|
+
strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo);
|
|
37
|
+
}
|
|
38
|
+
if (strippedAppSpec.compilerInfo) {
|
|
39
|
+
delete strippedAppSpec.compilerInfo;
|
|
40
|
+
}
|
|
41
|
+
// These are used for deploying but not for calling deployed apps
|
|
42
|
+
if (options.mode === 'minimal') {
|
|
43
|
+
if (strippedAppSpec.source) {
|
|
44
|
+
delete strippedAppSpec.source;
|
|
45
|
+
}
|
|
46
|
+
if (strippedAppSpec.byteCode) {
|
|
47
|
+
delete strippedAppSpec.byteCode;
|
|
48
|
+
}
|
|
49
|
+
if (strippedAppSpec.templateVariables) {
|
|
50
|
+
delete strippedAppSpec.templateVariables;
|
|
51
|
+
}
|
|
52
|
+
if (strippedAppSpec.scratchVariables) {
|
|
53
|
+
delete strippedAppSpec.scratchVariables;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return strippedAppSpec;
|
|
57
|
+
}
|
|
58
|
+
function* generate(app, options) {
|
|
59
|
+
const resolvedOptions = {
|
|
60
|
+
// Set defaults
|
|
61
|
+
preserveNames: false,
|
|
62
|
+
mode: 'full',
|
|
63
|
+
...options,
|
|
64
|
+
};
|
|
65
|
+
const reduceAppSpec = shrinkAppSpec(app, resolvedOptions);
|
|
66
|
+
const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions);
|
|
20
67
|
yield `/* eslint-disable */`;
|
|
21
68
|
yield `/**`;
|
|
22
69
|
yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`;
|
|
23
70
|
yield ` * DO NOT MODIFY IT BY HAND.`;
|
|
24
71
|
yield ` * requires: @algorandfoundation/algokit-utils: ^7`;
|
|
25
72
|
yield ` */`;
|
|
26
|
-
yield* imports();
|
|
73
|
+
yield* imports(ctx);
|
|
27
74
|
// Change the structs definition to sanitize property names according to the defined rules
|
|
28
75
|
// for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp
|
|
29
|
-
|
|
30
|
-
yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(
|
|
76
|
+
reduceAppSpec.structs = Object.fromEntries(Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]));
|
|
77
|
+
yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract');
|
|
31
78
|
yield NewLine;
|
|
32
79
|
yield* utilityTypes();
|
|
33
80
|
yield NewLine;
|
|
34
81
|
yield* appTypes(ctx);
|
|
35
|
-
|
|
82
|
+
if (ctx.mode === 'full') {
|
|
83
|
+
yield* deployTypes(ctx);
|
|
84
|
+
}
|
|
36
85
|
yield NewLine;
|
|
37
86
|
// Write a call factory
|
|
38
87
|
yield* paramsFactory(ctx);
|
|
39
88
|
yield NewLine;
|
|
40
|
-
// Write a factory
|
|
41
|
-
|
|
89
|
+
// Write a factory in full mode
|
|
90
|
+
if (ctx.mode === 'full') {
|
|
91
|
+
yield* appFactory(ctx);
|
|
92
|
+
}
|
|
42
93
|
// Write a client
|
|
43
94
|
yield* appClient(ctx);
|
|
44
95
|
yield* callComposerType(ctx);
|
package/client/generate.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.mjs","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nexport function* generate(app: Arc56Contract, options: GeneratorOptions = { preserveNames: false }
|
|
1
|
+
{"version":3,"file":"generate.mjs","sources":["../../src/client/generate.ts"],"sourcesContent":["import { DocumentParts, inline, NewLine } from '../output/writer'\nimport { paramsFactory } from './params-factory'\nimport { appClient } from './app-client'\nimport { deployTypes } from './deploy-types'\nimport { utilityTypes } from './utility-types'\nimport { imports } from './imports'\nimport { createGeneratorContext, GeneratorOptions } from './generator-context'\nimport { appTypes } from './app-types'\nimport { callComposerType } from './call-composer-types'\nimport { Arc56Contract, ProgramSourceInfo, StructField } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { appFactory } from './app-factory'\nimport { Sanitizer } from '../util/sanitization'\n\nfunction convertStructs(s: StructField[], sanitizer: Sanitizer): StructField[] {\n return s.map(\n ({ name, type }) =>\n ({\n name: sanitizer.makeSafePropertyIdentifier(name),\n type: typeof type === 'string' ? type : convertStructs(type, sanitizer),\n }) satisfies StructField,\n )\n}\n\nfunction shrinkAppSpec(app: Arc56Contract, options: GeneratorOptions): Arc56Contract {\n const strippedAppSpec = structuredClone(app)\n\n // Only keep the source info if it is needed for error mapping\n const shrinkSourceInfo = (sourceInfo: ProgramSourceInfo['sourceInfo']) => {\n return sourceInfo\n .filter((entry) => entry.errorMessage)\n .map((entry) => ({\n pc: entry.pc,\n errorMessage: entry.errorMessage,\n // Keep minimal context for error mapping if available\n ...(entry.teal !== undefined && { teal: entry.teal }),\n }))\n }\n\n // Keep only source info entries that can be used for approval and clear program error mapping\n if (strippedAppSpec.sourceInfo?.approval?.sourceInfo && strippedAppSpec.sourceInfo.approval.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.approval.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.approval.sourceInfo)\n }\n\n if (strippedAppSpec.sourceInfo?.clear?.sourceInfo && strippedAppSpec.sourceInfo.clear.sourceInfo.length > 0) {\n strippedAppSpec.sourceInfo.clear.sourceInfo = shrinkSourceInfo(strippedAppSpec.sourceInfo.clear.sourceInfo)\n }\n\n if (strippedAppSpec.compilerInfo) {\n delete strippedAppSpec.compilerInfo\n }\n\n // These are used for deploying but not for calling deployed apps\n if (options.mode === 'minimal') {\n if (strippedAppSpec.source) {\n delete strippedAppSpec.source\n }\n if (strippedAppSpec.byteCode) {\n delete strippedAppSpec.byteCode\n }\n if (strippedAppSpec.templateVariables) {\n delete strippedAppSpec.templateVariables\n }\n if (strippedAppSpec.scratchVariables) {\n delete strippedAppSpec.scratchVariables\n }\n }\n return strippedAppSpec\n}\n\nexport function* generate(app: Arc56Contract, options?: Partial<GeneratorOptions>): DocumentParts {\n const resolvedOptions: GeneratorOptions = {\n // Set defaults\n preserveNames: false,\n mode: 'full',\n ...options,\n }\n const reduceAppSpec = shrinkAppSpec(app, resolvedOptions)\n\n const ctx = createGeneratorContext(reduceAppSpec, resolvedOptions)\n yield `/* eslint-disable */`\n yield `/**`\n yield ` * This file was automatically generated by @algorandfoundation/algokit-client-generator.`\n yield ` * DO NOT MODIFY IT BY HAND.`\n yield ` * requires: @algorandfoundation/algokit-utils: ^7`\n yield ` */`\n\n yield* imports(ctx)\n // Change the structs definition to sanitize property names according to the defined rules\n // for instance, this may (unless you passed in --preserve-names) convert properties like my_prop to myProp\n reduceAppSpec.structs = Object.fromEntries(\n Object.keys(reduceAppSpec.structs).map((key) => [key, convertStructs(reduceAppSpec.structs[key], ctx.sanitizer)]),\n )\n yield* inline('export const APP_SPEC: Arc56Contract = ', JSON.stringify(reduceAppSpec), ' as unknown as Arc56Contract')\n yield NewLine\n\n yield* utilityTypes()\n yield NewLine\n yield* appTypes(ctx)\n\n if (ctx.mode === 'full') {\n yield* deployTypes(ctx)\n }\n yield NewLine\n\n // Write a call factory\n yield* paramsFactory(ctx)\n yield NewLine\n // Write a factory in full mode\n if (ctx.mode === 'full') {\n yield* appFactory(ctx)\n }\n // Write a client\n yield* appClient(ctx)\n\n yield* callComposerType(ctx)\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAaA,SAAS,cAAc,CAAC,CAAgB,EAAE,SAAoB,EAAA;AAC5D,IAAA,OAAO,CAAC,CAAC,GAAG,CACV,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MACZ;AACC,QAAA,IAAI,EAAE,SAAS,CAAC,0BAA0B,CAAC,IAAI,CAAC;AAChD,QAAA,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG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AA,MAAM,OAAO;AACb,IAAA,OAAO,QAAQ,CAAC,GAAG,CAAC;AAEpB,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,WAAW,CAAC,GAAG,CAAC;;AAEzB,IAAA,MAAM,OAAO;;AAGb,IAAA,OAAO,aAAa,CAAC,GAAG,CAAC;AACzB,IAAA,MAAM,OAAO;;AAEb,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;AACvB,QAAA,OAAO,UAAU,CAAC,GAAG,CAAC;;;AAGxB,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;AAErB,IAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC;AAC9B;;;;"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { CallConfigSummary } from './helpers/get-call-config-summary';
|
|
2
2
|
import { Sanitizer } from '../util/sanitization';
|
|
3
3
|
import { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56';
|
|
4
|
+
declare const GenerateMode: {
|
|
5
|
+
readonly FULL: "full";
|
|
6
|
+
readonly MINIMAL: "minimal";
|
|
7
|
+
};
|
|
8
|
+
export type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode];
|
|
9
|
+
export declare const generateModes: ("full" | "minimal")[];
|
|
4
10
|
export type GeneratorContext = {
|
|
5
11
|
app: Arc56Contract;
|
|
6
12
|
name: string;
|
|
7
13
|
callConfig: CallConfigSummary;
|
|
8
14
|
methodSignatureToUniqueName: Record<string, string>;
|
|
9
15
|
sanitizer: Sanitizer;
|
|
16
|
+
mode: GenerateMode;
|
|
10
17
|
};
|
|
11
18
|
export type GeneratorOptions = {
|
|
12
19
|
preserveNames: boolean;
|
|
20
|
+
mode: GenerateMode;
|
|
13
21
|
};
|
|
14
|
-
export declare const createGeneratorContext: (app: Arc56Contract, options: GeneratorOptions) =>
|
|
15
|
-
|
|
16
|
-
app: Arc56Contract;
|
|
17
|
-
name: string;
|
|
18
|
-
callConfig: CallConfigSummary;
|
|
19
|
-
methodSignatureToUniqueName: Record<string, string>;
|
|
20
|
-
};
|
|
22
|
+
export declare const createGeneratorContext: (app: Arc56Contract, options: GeneratorOptions) => GeneratorContext;
|
|
23
|
+
export {};
|
|
@@ -4,6 +4,11 @@ var getCallConfigSummary = require('./helpers/get-call-config-summary.js');
|
|
|
4
4
|
var sanitization = require('../util/sanitization.js');
|
|
5
5
|
var algosdk = require('algosdk');
|
|
6
6
|
|
|
7
|
+
const GenerateMode = {
|
|
8
|
+
FULL: 'full',
|
|
9
|
+
MINIMAL: 'minimal',
|
|
10
|
+
};
|
|
11
|
+
const generateModes = Object.values(GenerateMode);
|
|
7
12
|
const createGeneratorContext = (app, options) => {
|
|
8
13
|
const sanitizer = sanitization.getSanitizer(options);
|
|
9
14
|
return {
|
|
@@ -16,8 +21,10 @@ const createGeneratorContext = (app, options) => {
|
|
|
16
21
|
acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
|
|
17
22
|
return acc;
|
|
18
23
|
}, {}),
|
|
24
|
+
mode: options.mode,
|
|
19
25
|
};
|
|
20
26
|
};
|
|
21
27
|
|
|
22
28
|
exports.createGeneratorContext = createGeneratorContext;
|
|
29
|
+
exports.generateModes = generateModes;
|
|
23
30
|
//# sourceMappingURL=generator-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator-context.js","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions) => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n }\n}\n"],"names":["getSanitizer","getCallConfigSummary","ABIMethod"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"generator-context.js","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nconst GenerateMode = {\n FULL: 'full',\n MINIMAL: 'minimal',\n} as const\nexport type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode]\nexport const generateModes = Object.values(GenerateMode)\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n mode: GenerateMode\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n mode: GenerateMode\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions): GeneratorContext => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n mode: options.mode,\n }\n}\n"],"names":["getSanitizer","getCallConfigSummary","ABIMethod"],"mappings":";;;;;;AAKA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEG,MAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAgB1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAGA,yBAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAEC,yCAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAIC,iBAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;SACX,EACD,EAA4B,CAC7B;QACD,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;;"}
|
|
@@ -2,6 +2,11 @@ import { getCallConfigSummary } from './helpers/get-call-config-summary.mjs';
|
|
|
2
2
|
import { getSanitizer } from '../util/sanitization.mjs';
|
|
3
3
|
import { ABIMethod } from 'algosdk';
|
|
4
4
|
|
|
5
|
+
const GenerateMode = {
|
|
6
|
+
FULL: 'full',
|
|
7
|
+
MINIMAL: 'minimal',
|
|
8
|
+
};
|
|
9
|
+
const generateModes = Object.values(GenerateMode);
|
|
5
10
|
const createGeneratorContext = (app, options) => {
|
|
6
11
|
const sanitizer = getSanitizer(options);
|
|
7
12
|
return {
|
|
@@ -14,8 +19,9 @@ const createGeneratorContext = (app, options) => {
|
|
|
14
19
|
acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name;
|
|
15
20
|
return acc;
|
|
16
21
|
}, {}),
|
|
22
|
+
mode: options.mode,
|
|
17
23
|
};
|
|
18
24
|
};
|
|
19
25
|
|
|
20
|
-
export { createGeneratorContext };
|
|
26
|
+
export { createGeneratorContext, generateModes };
|
|
21
27
|
//# sourceMappingURL=generator-context.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator-context.mjs","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions) => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n }\n}\n"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"generator-context.mjs","sources":["../../src/client/generator-context.ts"],"sourcesContent":["import { CallConfigSummary, getCallConfigSummary } from './helpers/get-call-config-summary'\nimport { getSanitizer, Sanitizer } from '../util/sanitization'\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nconst GenerateMode = {\n FULL: 'full',\n MINIMAL: 'minimal',\n} as const\nexport type GenerateMode = (typeof GenerateMode)[keyof typeof GenerateMode]\nexport const generateModes = Object.values(GenerateMode)\n\nexport type GeneratorContext = {\n app: Arc56Contract\n name: string\n callConfig: CallConfigSummary\n methodSignatureToUniqueName: Record<string, string>\n sanitizer: Sanitizer\n mode: GenerateMode\n}\n\nexport type GeneratorOptions = {\n preserveNames: boolean\n mode: GenerateMode\n}\n\nexport const createGeneratorContext = (app: Arc56Contract, options: GeneratorOptions): GeneratorContext => {\n const sanitizer = getSanitizer(options)\n return {\n sanitizer,\n app,\n name: sanitizer.makeSafeTypeIdentifier(app.name),\n callConfig: getCallConfigSummary(app),\n methodSignatureToUniqueName: app.methods.reduce(\n (acc, cur) => {\n const signature = new ABIMethod(cur).getSignature()\n acc[signature] = app.methods.some((m) => m.name === cur.name && m !== cur) ? signature : cur.name\n return acc\n },\n {} as Record<string, string>,\n ),\n mode: options.mode,\n }\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,SAAS;CACV;AAEG,MAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY;MAgB1C,sBAAsB,GAAG,CAAC,GAAkB,EAAE,OAAyB,KAAsB;AACxG,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;IACvC,OAAO;QACL,SAAS;QACT,GAAG;QACH,IAAI,EAAE,SAAS,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,UAAU,EAAE,oBAAoB,CAAC,GAAG,CAAC;AACrC,QAAA,2BAA2B,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,GAAG,KAAI;YACX,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE;AACnD,YAAA,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,GAAG,GAAG,CAAC,IAAI;AACjG,YAAA,OAAO,GAAG;SACX,EACD,EAA4B,CAC7B;QACD,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB;AACH;;;;"}
|
package/client/imports.d.ts
CHANGED
package/client/imports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function* imports() {
|
|
3
|
+
function* imports(ctx) {
|
|
4
4
|
yield `
|
|
5
5
|
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
|
|
6
6
|
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
|
|
@@ -16,11 +16,10 @@ function* imports() {
|
|
|
16
16
|
ResolveAppClientByNetwork,
|
|
17
17
|
CloneAppClientParams,
|
|
18
18
|
} from '@algorandfoundation/algokit-utils/types/app-client'
|
|
19
|
-
import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
|
|
19
|
+
${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}
|
|
20
20
|
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
|
|
21
21
|
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
|
|
22
22
|
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
|
|
23
|
-
import SimulateResponse = modelsv2.SimulateResponse
|
|
24
23
|
`;
|
|
25
24
|
}
|
|
26
25
|
|
package/client/imports.js.map
CHANGED
|
@@ -1 +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 `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n
|
|
1
|
+
{"version":3,"file":"imports.js","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nexport function* imports(ctx: GeneratorContext): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n `\n}\n"],"names":[],"mappings":";;AAGe,UAAE,OAAO,CAAC,GAAqB,EAAA;IAC5C,MAAM;;;;;;;;;;;;;;;MAeF,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,CAAsO,oOAAA,CAAA,GAAG,EAAE;;;;GAIpQ;AACH;;;;"}
|
package/client/imports.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function* imports() {
|
|
1
|
+
function* imports(ctx) {
|
|
2
2
|
yield `
|
|
3
3
|
import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'
|
|
4
4
|
import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'
|
|
@@ -14,11 +14,10 @@ function* imports() {
|
|
|
14
14
|
ResolveAppClientByNetwork,
|
|
15
15
|
CloneAppClientParams,
|
|
16
16
|
} from '@algorandfoundation/algokit-utils/types/app-client'
|
|
17
|
-
import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'
|
|
17
|
+
${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}
|
|
18
18
|
import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'
|
|
19
19
|
import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'
|
|
20
20
|
import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'
|
|
21
|
-
import SimulateResponse = modelsv2.SimulateResponse
|
|
22
21
|
`;
|
|
23
22
|
}
|
|
24
23
|
|
package/client/imports.mjs.map
CHANGED
|
@@ -1 +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 `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n
|
|
1
|
+
{"version":3,"file":"imports.mjs","sources":["../../src/client/imports.ts"],"sourcesContent":["import { DocumentParts } from '../output/writer'\nimport { GeneratorContext } from './generator-context'\n\nexport function* imports(ctx: GeneratorContext): DocumentParts {\n yield `\n import { type AlgorandClient } from '@algorandfoundation/algokit-utils/types/algorand-client'\n import { ABIReturn, AppReturn, SendAppTransactionResult } from '@algorandfoundation/algokit-utils/types/app'\n import { Arc56Contract, getArc56ReturnValue, getABIStructFromABITuple } from '@algorandfoundation/algokit-utils/types/app-arc56'\n import {\n AppClient as _AppClient,\n AppClientMethodCallParams,\n AppClientParams,\n AppClientBareCallParams,\n CallOnComplete,\n AppClientCompilationParams,\n ResolveAppClientByCreatorAndName,\n ResolveAppClientByNetwork,\n CloneAppClientParams,\n } from '@algorandfoundation/algokit-utils/types/app-client'\n ${ctx.mode === 'full' ? `import { AppFactory as _AppFactory, AppFactoryAppClientParams, AppFactoryResolveAppClientByCreatorAndNameParams, AppFactoryDeployParams, AppFactoryParams, CreateSchema } from '@algorandfoundation/algokit-utils/types/app-factory'` : ''}\n import { TransactionComposer, AppCallMethodCall, AppMethodCallTransactionArgument, SimulateOptions, RawSimulateOptions, SkipSignaturesSimulateOptions } from '@algorandfoundation/algokit-utils/types/composer'\n import { SendParams, SendSingleTransactionResult, SendAtomicTransactionComposerResults } from '@algorandfoundation/algokit-utils/types/transaction'\n import { Address, encodeAddress, modelsv2, OnApplicationComplete, Transaction, TransactionSigner } from 'algosdk'\n `\n}\n"],"names":[],"mappings":"AAGe,UAAE,OAAO,CAAC,GAAqB,EAAA;IAC5C,MAAM;;;;;;;;;;;;;;;MAeF,GAAG,CAAC,IAAI,KAAK,MAAM,GAAG,CAAsO,oOAAA,CAAA,GAAG,EAAE;;;;GAIpQ;AACH;;;;"}
|
package/client/params-factory.js
CHANGED
|
@@ -18,9 +18,11 @@ function* paramsFactory(ctx) {
|
|
|
18
18
|
}
|
|
19
19
|
function* opMethods(ctx) {
|
|
20
20
|
const { app, callConfig } = ctx;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (ctx.mode === 'full') {
|
|
22
|
+
yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
|
|
23
|
+
yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, callConfig.updateMethods, 'update', true);
|
|
24
|
+
yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
|
|
25
|
+
}
|
|
24
26
|
yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
|
|
25
27
|
yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
|
|
26
28
|
}
|
|
@@ -1 +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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\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 ${ctx.name}${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 methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} 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: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} 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: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\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: Array<{ name?: string }>\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(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":["jsDoc","IncIndent","DecIndent","BARE_CALL","indent","DecIndentAndCloseBlock","NewLine","getCreateOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAQe,UAAE,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAOA,YAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC;AAC7H,IAAA,MAAM,CAAyB,sBAAA,EAAA,GAAG,CAAC,IAAI,iBAAiB;AACxD,IAAA,MAAMC,gBAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACpC,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;;AAGvC,IAAA,MAAMC,gBAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EA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AAA,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA,GAAA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,EAAE;AAC5H,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;;;;"}
|
|
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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n }\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\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 ${ctx.name}${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 methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} 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: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} 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: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\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: Array<{ name?: string }>\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(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":["jsDoc","IncIndent","DecIndent","BARE_CALL","indent","DecIndentAndCloseBlock","NewLine","getCreateOnCompleteOptions","ABIMethod"],"mappings":";;;;;;;AAQe,UAAE,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAOA,YAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC;AAC7H,IAAA,MAAM,CAAyB,sBAAA,EAAA,GAAG,CAAC,IAAI,iBAAiB;AACxD,IAAA,MAAMC,gBAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACpC,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;;AAGvC,IAAA,MAAMC,gBAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EAAA;AACvC,IAAA,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG;AAE/B,IAAA,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;QACvB,OAAO,eAAe,CACpB,GAAG,EACH,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EACtE,UAAU,CAAC,aAAa,EACxB,QAAQ,EACR,IAAI,CACL;QACD,OAAO,eAAe,CACpB,GAAG,EACH,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EACtE,UAAU,CAAC,aAAa,EACxB,QAAQ,EACR,IAAI,CACL;AACD,QAAA,OAAO,eAAe,CAAC,GAAG,EAAE,6CAA6C,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CA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18
|
const { app, callConfig } = ctx;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (ctx.mode === 'full') {
|
|
20
|
+
yield* operationMethod(ctx, `Constructs create ABI call params for the ${app.name} smart contract`, callConfig.createMethods, 'create', true);
|
|
21
|
+
yield* operationMethod(ctx, `Constructs update ABI call params for the ${app.name} smart contract`, callConfig.updateMethods, 'update', true);
|
|
22
|
+
yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete');
|
|
23
|
+
}
|
|
22
24
|
yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn');
|
|
23
25
|
yield* operationMethod(ctx, `Constructs close out ABI call params for the ${app.name} smart contract`, callConfig.closeOutMethods, 'closeOut');
|
|
24
26
|
}
|
|
@@ -1 +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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\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 ${ctx.name}${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 methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} 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: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} 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: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\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: Array<{ name?: string }>\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(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":[],"mappings":";;;;;AAQe,UAAE,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAO,KAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC;AAC7H,IAAA,MAAM,CAAyB,sBAAA,EAAA,GAAG,CAAC,IAAI,iBAAiB;AACxD,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;QACpC,OAAO,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC;;AAGvC,IAAA,MAAM,SAAS;AAEf,IAAA,MAAM,GAAG;AACX;AAEA,UAAU,SAAS,CAAC,GAAqB,EAAA;AACvC,IAAA,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,GAAG;IAE/B,OAAO,eAAe,CACpB,GAAG,EACH,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EACtE,UAAU,CAAC,aAAa,EACxB,QAAQ,EACR,IAAI,CACL;IACD,OAAO,eAAe,CACpB,GAAG,EACH,CAAA,0CAAA,EAA6C,GAAG,CAAC,IAAI,iBAAiB,EACtE,UAAU,CAAC,aAAa,EACxB,QAAQ,EACR,IAAI,CACL;AACD,IAAA,OAAO,eAAe,CAAC,GAAG,EAAE,6CAA6C,GAAG,CAAC,IAAI,CAAA,eAAA,CAAiB,EAAE,UAAU,CAAC,aAAa,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AAY,EAAE,IAAI;AACnB,KAAA,CAAC;AACJ;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,CAAG,EAAA,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;AACxD,SAAA,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAc,WAAA,EAAA,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA,GAAA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,EAAE;AAC5H,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;;;;"}
|
|
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 { BARE_CALL, MethodList } from './helpers/get-call-config-summary'\nimport { getCreateOnCompleteOptions } from './deploy-types'\nimport { Sanitizer } from '../util/sanitization'\nimport { Method } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { ABIMethod } from 'algosdk'\n\nexport function* paramsFactory(ctx: GeneratorContext): DocumentParts {\n yield* jsDoc(`Exposes methods for constructing \\`AppClient\\` params objects for ABI calls to the ${ctx.name} smart contract`)\n yield `export abstract class ${ctx.name}ParamsFactory {`\n yield IncIndent\n\n yield* opMethods(ctx)\n\n for (const method of ctx.app.methods) {\n yield* callFactoryMethod(ctx, method)\n }\n\n yield DecIndent\n\n yield '}'\n}\n\nfunction* opMethods(ctx: GeneratorContext): DocumentParts {\n const { app, callConfig } = ctx\n\n if (ctx.mode === 'full') {\n yield* operationMethod(\n ctx,\n `Constructs create ABI call params for the ${app.name} smart contract`,\n callConfig.createMethods,\n 'create',\n true,\n )\n yield* operationMethod(\n ctx,\n `Constructs update ABI call params for the ${app.name} smart contract`,\n callConfig.updateMethods,\n 'update',\n true,\n )\n yield* operationMethod(ctx, `Constructs delete ABI call params for the ${app.name} smart contract`, callConfig.deleteMethods, 'delete')\n }\n yield* operationMethod(ctx, `Constructs opt-in ABI call params for the ${app.name} smart contract`, callConfig.optInMethods, 'optIn')\n yield* operationMethod(\n ctx,\n `Constructs close out ABI call params for the ${app.name} smart contract`,\n callConfig.closeOutMethods,\n 'closeOut',\n )\n}\n\nfunction* operationMethod(\n ctx: GeneratorContext,\n description: string,\n methods: MethodList,\n verb: 'create' | 'update' | 'optIn' | 'closeOut' | 'delete',\n includeCompilation?: boolean,\n): DocumentParts {\n const { app, methodSignatureToUniqueName, sanitizer, name } = ctx\n if (methods.length > 0 && methods.some((m) => m !== BARE_CALL)) {\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 ${ctx.name}${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 methodSig of methods) {\n if (methodSig === BARE_CALL) continue\n\n const uniqueName = methodSignatureToUniqueName[methodSig]\n if (uniqueName !== methodSig) {\n yield `case '${sanitizer.makeSafeStringTypeLiteral(uniqueName)}':`\n }\n yield `case '${sanitizer.makeSafeStringTypeLiteral(methodSig)}':`\n yield* indent(\n `return ${ctx.name}ParamsFactory.${verb}${sanitizer.getSafeMemberAccessor(sanitizer.makeSafeMethodIdentifier(uniqueName))}(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 methodSig of methods) {\n const onComplete = verb === 'create' ? getCreateOnCompleteOptions(methodSig, app) : undefined\n if (methodSig !== BARE_CALL) {\n const method = app.methods.find((m) => new ABIMethod(m).getSignature() === methodSig)!\n const uniqueName = methodSignatureToUniqueName[methodSig]\n yield* jsDoc({\n description: `${description} using the ${methodSig} 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: methodSig,\n args: method.args,\n additionalParamTypes: `${includeCompilation ? ' & AppClientCompilationParams' : ''}${\n onComplete?.type ? ` & ${onComplete.type}` : ''\n }`,\n contractName: name,\n })\n }\n }\n yield DecIndentAndCloseBlock\n yield DecIndentAndCloseBlock\n yield NewLine\n }\n}\n\nfunction* callFactoryMethod({ methodSignatureToUniqueName, callConfig, sanitizer, name }: GeneratorContext, method: Method) {\n const methodSignature = new ABIMethod(method).getSignature()\n if (!callConfig.callMethods.includes(methodSignature)) return\n\n yield* jsDoc({\n description: `Constructs a no op call for the ${methodSignature} 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: sanitizer.makeSafeMethodIdentifier(methodSignatureToUniqueName[methodSignature]),\n signature: methodSignature,\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: Array<{ name?: string }>\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(sanitizer.makeSafePropertyIdentifier(a.name ?? `arg${i + 1}`))}`)\n .join(', ')}],`\n yield DecIndent\n yield '}'\n yield DecIndent\n yield `}${isNested ? ',' : ''}`\n}\n"],"names":[],"mappings":";;;;;AAQe,UAAE,aAAa,CAAC,GAAqB,EAAA;IAClD,OAAO,KAAK,CAAC,CAAA,mFAAA,EAAsF,GAAG,CAAC,IAAI,CAAiB,eAAA,CAAA,CAAC;AAC7H,IAAA,MAAM,CAAyB,sBAAA,EAAA,GAAG,CAAC,IAAI,iBAAiB;AACxD,IAAA,MAAM,SAAS;AAEf,IAAA,OAAO,SAAS,CAAC,GAAG,CAAC;IAErB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;Q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AY;IAClB,MAAM,CAAA,SAAA,EAAY,aAAa,CAAA,WAAA,CAAa;AAC5C,IAAA,MAAM,qDAAqD;AACxD,SAAA,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAc,WAAA,EAAA,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA,GAAA,EAAM,CAAC,GAAG,CAAC,CAAA,CAAE,CAAC,CAAC,EAAE;AAC5H,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;;;;"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"**"
|
|
7
7
|
],
|
|
8
8
|
"name": "@algorandfoundation/algokit-client-generator",
|
|
9
|
-
"version": "6.0.0
|
|
9
|
+
"version": "6.0.0",
|
|
10
10
|
"description": "Generates a TypeScript client for interacting with, and deploying ARC-0032 smart contracts on the Algorand Blockchain.",
|
|
11
11
|
"module": "index.mjs",
|
|
12
12
|
"private": false,
|
|
@@ -20,16 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"author": "Algorand Foundation",
|
|
22
22
|
"license": "MIT",
|
|
23
|
-
"overrides": {
|
|
24
|
-
"semver": "7.5.2",
|
|
25
|
-
"micromatch": "4.0.8",
|
|
26
|
-
"cross-spawn": "^7.0.6",
|
|
27
|
-
"esbuild": "0.25.0"
|
|
28
|
-
},
|
|
29
23
|
"dependencies": {
|
|
30
24
|
"chalk": "^5.4.1",
|
|
31
25
|
"change-case": "^5.4.4",
|
|
32
|
-
"commander": "^
|
|
26
|
+
"commander": "^14.0.0",
|
|
33
27
|
"jsonschema": "^1.5.0"
|
|
34
28
|
},
|
|
35
29
|
"peerDependencies": {
|
package/util/sanitization.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GeneratorOptions } from '../client/generator-context';
|
|
1
2
|
export interface Sanitizer {
|
|
2
3
|
makeSafeTypeIdentifier(value: string): string;
|
|
3
4
|
makeSafeMethodIdentifier(value: string): string;
|
|
@@ -7,6 +8,4 @@ export interface Sanitizer {
|
|
|
7
8
|
getSafeMemberAccessor(value: string): string;
|
|
8
9
|
isSafeVariableIdentifier(value: string): boolean;
|
|
9
10
|
}
|
|
10
|
-
export declare const getSanitizer: (
|
|
11
|
-
preserveNames: boolean;
|
|
12
|
-
}) => Sanitizer;
|
|
11
|
+
export declare const getSanitizer: (options: GeneratorOptions) => Sanitizer;
|
package/util/sanitization.js
CHANGED
|
@@ -55,7 +55,7 @@ const preservingSanitiser = {
|
|
|
55
55
|
return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`;
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
|
-
const getSanitizer = (
|
|
58
|
+
const getSanitizer = (options) => (options.preserveNames ? preservingSanitiser : defaultSanitiser);
|
|
59
59
|
|
|
60
60
|
exports.getSanitizer = getSanitizer;
|
|
61
61
|
//# sourceMappingURL=sanitization.js.map
|
package/util/sanitization.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitization.js","sources":["../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\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 = (
|
|
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,CAAK,EAAA,EAAA,GAAG,CAAE,CAAA,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,OAAOA,oBAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;KAC/D;AACD,IAAA,sBAAsB,CAAC,KAAa,EAAA;QAClC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,E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G;KACnG;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;KACnG;AACD,IAAA,sBAAsB,CAAC,KAAa,EAAA;AAClC,QAAA,OAAO,4BAA4B,CAAC,KAAK,CAAC;KAC3C;AACD,IAAA,0BAA0B,CAAC,KAAa,EAAA;AACtC,QAAA,OAAO,4BAA4B,CAAC,KAAK,CAAC;KAC3C;AACD,IAAA,yBAAyB,CAAC,KAAa,EAAA;AACrC,QAAA,OAAO,YAAY,CAAC,KAAK,CAAC;KAC3B;AACD,IAAA,qBAAqB,CAAC,KAAa,EAAA;QACjC,OAAO,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAA,CAAA,EAAI,KAAK,CAAE,CAAA,GAAG,CAAA,EAAA,EAAK,qBAAqB,CAAC,KAAK,CAAC,CAAA,EAAA,CAAI;KAClG;CACF;MAEY,YAAY,GAAG,CAAC,OAAyB,MAAM,OAAO,CAAC,aAAa,GAAG,mBAAmB,GAAG,gBAAgB;;;;"}
|
package/util/sanitization.mjs
CHANGED
|
@@ -53,7 +53,7 @@ const preservingSanitiser = {
|
|
|
53
53
|
return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`;
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
|
-
const getSanitizer = (
|
|
56
|
+
const getSanitizer = (options) => (options.preserveNames ? preservingSanitiser : defaultSanitiser);
|
|
57
57
|
|
|
58
58
|
export { getSanitizer };
|
|
59
59
|
//# sourceMappingURL=sanitization.mjs.map
|