@algorandfoundation/algokit-client-generator 6.0.0 → 6.0.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 (37) hide show
  1. package/cli.js.map +1 -1
  2. package/cli.mjs.map +1 -1
  3. package/client/app-client.js.map +1 -1
  4. package/client/app-client.mjs.map +1 -1
  5. package/client/app-factory.js.map +1 -1
  6. package/client/app-factory.mjs.map +1 -1
  7. package/client/app-types.js.map +1 -1
  8. package/client/app-types.mjs.map +1 -1
  9. package/client/call-composer-types.js.map +1 -1
  10. package/client/call-composer-types.mjs.map +1 -1
  11. package/client/call-composer.js.map +1 -1
  12. package/client/call-composer.mjs.map +1 -1
  13. package/client/deploy-types.js.map +1 -1
  14. package/client/deploy-types.mjs.map +1 -1
  15. package/client/generate.js.map +1 -1
  16. package/client/generate.mjs.map +1 -1
  17. package/client/generator-context.js.map +1 -1
  18. package/client/generator-context.mjs.map +1 -1
  19. package/client/helpers/get-call-config-summary.js.map +1 -1
  20. package/client/helpers/get-call-config-summary.mjs.map +1 -1
  21. package/client/helpers/get-equivalent-type.js.map +1 -1
  22. package/client/helpers/get-equivalent-type.mjs.map +1 -1
  23. package/client/imports.js.map +1 -1
  24. package/client/imports.mjs.map +1 -1
  25. package/client/params-factory.js.map +1 -1
  26. package/client/params-factory.mjs.map +1 -1
  27. package/output/writer.js.map +1 -1
  28. package/output/writer.mjs.map +1 -1
  29. package/package.json +1 -1
  30. package/schema/load.js.map +1 -1
  31. package/schema/load.mjs.map +1 -1
  32. package/util/boom.js.map +1 -1
  33. package/util/boom.mjs.map +1 -1
  34. package/util/color-console.js.map +1 -1
  35. package/util/color-console.mjs.map +1 -1
  36. package/util/sanitization.js.map +1 -1
  37. package/util/sanitization.mjs.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"writer.mjs","sources":["../../src/output/writer.ts"],"sourcesContent":["export const IncIndent = Symbol('Increase Indent')\nexport const DecIndent = Symbol('Decrease Indent')\nexport const DecIndentAndCloseBlock = Symbol('Decrease Indent and write a closing brace')\nexport const NewLineMode = Symbol('New Line Mode')\nexport const RestoreLineMode = Symbol('Restore Line Mode')\nexport const PropertyDelimiter = Symbol('Property Delimiter')\nexport const InlineMode = Symbol('Inline Mode')\nexport const NewLine = Symbol('New Line')\n\nexport type Part =\n | string\n | typeof IncIndent\n | typeof DecIndent\n | typeof NewLineMode\n | typeof DecIndentAndCloseBlock\n | typeof InlineMode\n | typeof NewLine\n | typeof RestoreLineMode\n | typeof PropertyDelimiter\nexport type DocumentParts = Generator<Part, void>\n\nexport type WriteOptions = {\n indent?: string\n disableEslint?: boolean\n header?: string\n}\n\ninterface StringWriter {\n write(value: string): void\n get last(): string\n}\n\nexport function writeDocumentPartsToStream(document: DocumentParts, stream: { write(chunk: string): void }, options: WriteOptions = {}) {\n const writer = {\n _last: '',\n write(val: string) {\n this._last = val\n stream.write(val)\n },\n get last() {\n return this._last\n },\n }\n writeDocumentPartsTo(document, options, writer)\n}\n\nexport function writeDocumentPartsToString(document: DocumentParts, options: WriteOptions = {}) {\n const writer = {\n result: [] as string[],\n _last: '',\n write(val: string) {\n this._last = val\n this.result.push(val)\n },\n get last() {\n return this._last\n },\n toString() {\n return this.result.join('')\n },\n }\n writeDocumentPartsTo(document, options, writer)\n return writer.toString()\n}\n\nexport function* inline(...parts: Array<Part | DocumentParts>) {\n yield InlineMode\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield RestoreLineMode\n}\n\nexport function* indent(...parts: Array<Part | DocumentParts>) {\n yield IncIndent\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield DecIndent\n}\n\nexport function* jsDoc(\n docs: string | string[] | { description: string | string[]; abiDescription?: string; params?: Record<string, string>; returns?: string },\n) {\n yield `/**`\n if (typeof docs === 'string' || Array.isArray(docs)) {\n const description = typeof docs === 'string' ? [docs] : docs\n for (const line of description) {\n yield ` * ${line}`\n }\n } else {\n const description = typeof docs.description === 'string' ? [docs.description] : docs.description\n for (const line of description) {\n yield ` * ${line}`\n }\n if (docs.abiDescription) {\n yield ' *'\n yield ` * ${docs.abiDescription}`\n }\n if (docs.params || docs.returns) {\n yield ' *'\n }\n for (const [paramName, paramDesc] of Object.entries(docs.params ?? {})) {\n yield ` * @param ${paramName} ${paramDesc}`\n }\n if (docs.returns) yield ` * @returns ${docs.returns}`\n }\n yield ' */'\n}\n\nfunction writeDocumentPartsTo(document: DocumentParts, { indent = ' ', ...options }: WriteOptions, writer: StringWriter): void {\n if (options.header) writer.write(`${options.header}\\n`)\n if (options.disableEslint) writer.write('/* eslint-disable */\\n')\n\n const lineModes = [NewLineMode]\n const currentLineMode = () => lineModes.at(-1) ?? NewLineMode\n\n let curIndent = ''\n for (const part of document) {\n switch (part) {\n case IncIndent:\n curIndent += indent\n break\n case DecIndent:\n curIndent = curIndent.slice(0, -indent.length)\n break\n case DecIndentAndCloseBlock:\n curIndent = curIndent.slice(0, -indent.length)\n writer.write(`${curIndent}}\\n`)\n break\n case NewLineMode:\n lineModes.push(NewLineMode)\n if (writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case InlineMode:\n lineModes.push(InlineMode)\n break\n case RestoreLineMode:\n lineModes.pop()\n\n if (currentLineMode() === NewLineMode && writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case PropertyDelimiter:\n if (currentLineMode() === NewLineMode) {\n writer.write('\\n')\n } else {\n writer.write(', ')\n }\n break\n case NewLine:\n writer.write('\\n')\n break\n default:\n // Multi-line\n if (part.includes('\\n') || part.includes('\\r')) {\n if (writer.last.slice(-1)[0] !== '\\n') writer.write('\\n')\n const normalisedLineEndings = part.replaceAll(/\\r\\n/g, '\\n').replaceAll(/\\r/g, '\\n').replace(/^\\n/, '').trimEnd()\n const lines = normalisedLineEndings.split('\\n')\n const baseIndent = lines[0].match(/^\\s+/)?.[0] ?? ''\n for (const line of lines) {\n writer.write(curIndent + line.replace(new RegExp(`^${baseIndent}`, ''), '').trimEnd())\n writer.write('\\n')\n }\n } else {\n if (writer.last.slice(-1)[0] === '\\n') writer.write(curIndent)\n writer.write(part)\n }\n if (currentLineMode() === NewLineMode) writer.write('\\n')\n break\n }\n }\n}\n"],"names":[],"mappings":"MAAa,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,sBAAsB,GAAG,MAAM,CAAC,2CAA2C;MAC3E,WAAW,GAAG,MAAM,CAAC,eAAe;MACpC,eAAe,GAAG,MAAM,CAAC,mBAAmB;MAC5C,iBAAiB,GAAG,MAAM,CAAC,oBAAoB;MAC/C,UAAU,GAAG,MAAM,CAAC,aAAa;MACjC,OAAO,GAAG,MAAM,CAAC,UAAU;AAyBlC,SAAU,0BAA0B,CAAC,QAAuB,EAAE,MAAsC,EAAE,UAAwB,EAAE,EAAA;AACpI,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;SAClB;AACD,QAAA,IAAI,IAAI,GAAA;YACN,OAAO,IAAI,CAAC,KAAK;SAClB;KACF;AACD,IAAA,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;AACjD;SAEgB,0BAA0B,CAAC,QAAuB,EAAE,UAAwB,EAAE,EAAA;AAC5F,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,MAAM,EAAE,EAAc;AACtB,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB;AACD,QAAA,IAAI,IAAI,GAAA;Y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IAAI,CAAC,EAAE;AAC9C,oBAAA,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;AAAE,wBAAA,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;oBACzD,MAAM,qBAAqB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;oBACjH,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC;AAC/C,oBAAA,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AACpD,oBAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;wBACxB,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,UAAU,CAAA,CAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AACtF,wBAAA,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;;;qBAEf;AACL,oBAAA,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;AAAE,wBAAA,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;AAC9D,oBAAA,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;;gBAEpB,IAAI,eAAe,EAAE,KAAK,WAAW;AAAE,oBAAA,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;gBACzD;;;AAGR;;;;"}
1
+ {"version":3,"file":"writer.mjs","sources":["../../src/output/writer.ts"],"sourcesContent":["export const IncIndent = Symbol('Increase Indent')\nexport const DecIndent = Symbol('Decrease Indent')\nexport const DecIndentAndCloseBlock = Symbol('Decrease Indent and write a closing brace')\nexport const NewLineMode = Symbol('New Line Mode')\nexport const RestoreLineMode = Symbol('Restore Line Mode')\nexport const PropertyDelimiter = Symbol('Property Delimiter')\nexport const InlineMode = Symbol('Inline Mode')\nexport const NewLine = Symbol('New Line')\n\nexport type Part =\n | string\n | typeof IncIndent\n | typeof DecIndent\n | typeof NewLineMode\n | typeof DecIndentAndCloseBlock\n | typeof InlineMode\n | typeof NewLine\n | typeof RestoreLineMode\n | typeof PropertyDelimiter\nexport type DocumentParts = Generator<Part, void>\n\nexport type WriteOptions = {\n indent?: string\n disableEslint?: boolean\n header?: string\n}\n\ninterface StringWriter {\n write(value: string): void\n get last(): string\n}\n\nexport function writeDocumentPartsToStream(document: DocumentParts, stream: { write(chunk: string): void }, options: WriteOptions = {}) {\n const writer = {\n _last: '',\n write(val: string) {\n this._last = val\n stream.write(val)\n },\n get last() {\n return this._last\n },\n }\n writeDocumentPartsTo(document, options, writer)\n}\n\nexport function writeDocumentPartsToString(document: DocumentParts, options: WriteOptions = {}) {\n const writer = {\n result: [] as string[],\n _last: '',\n write(val: string) {\n this._last = val\n this.result.push(val)\n },\n get last() {\n return this._last\n },\n toString() {\n return this.result.join('')\n },\n }\n writeDocumentPartsTo(document, options, writer)\n return writer.toString()\n}\n\nexport function* inline(...parts: Array<Part | DocumentParts>) {\n yield InlineMode\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield RestoreLineMode\n}\n\nexport function* indent(...parts: Array<Part | DocumentParts>) {\n yield IncIndent\n for (const part of parts) {\n if (typeof part === 'string' || typeof part === 'symbol') yield part\n else yield* part\n }\n yield DecIndent\n}\n\nexport function* jsDoc(\n docs: string | string[] | { description: string | string[]; abiDescription?: string; params?: Record<string, string>; returns?: string },\n) {\n yield `/**`\n if (typeof docs === 'string' || Array.isArray(docs)) {\n const description = typeof docs === 'string' ? [docs] : docs\n for (const line of description) {\n yield ` * ${line}`\n }\n } else {\n const description = typeof docs.description === 'string' ? [docs.description] : docs.description\n for (const line of description) {\n yield ` * ${line}`\n }\n if (docs.abiDescription) {\n yield ' *'\n yield ` * ${docs.abiDescription}`\n }\n if (docs.params || docs.returns) {\n yield ' *'\n }\n for (const [paramName, paramDesc] of Object.entries(docs.params ?? {})) {\n yield ` * @param ${paramName} ${paramDesc}`\n }\n if (docs.returns) yield ` * @returns ${docs.returns}`\n }\n yield ' */'\n}\n\nfunction writeDocumentPartsTo(document: DocumentParts, { indent = ' ', ...options }: WriteOptions, writer: StringWriter): void {\n if (options.header) writer.write(`${options.header}\\n`)\n if (options.disableEslint) writer.write('/* eslint-disable */\\n')\n\n const lineModes = [NewLineMode]\n const currentLineMode = () => lineModes.at(-1) ?? NewLineMode\n\n let curIndent = ''\n for (const part of document) {\n switch (part) {\n case IncIndent:\n curIndent += indent\n break\n case DecIndent:\n curIndent = curIndent.slice(0, -indent.length)\n break\n case DecIndentAndCloseBlock:\n curIndent = curIndent.slice(0, -indent.length)\n writer.write(`${curIndent}}\\n`)\n break\n case NewLineMode:\n lineModes.push(NewLineMode)\n if (writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case InlineMode:\n lineModes.push(InlineMode)\n break\n case RestoreLineMode:\n lineModes.pop()\n\n if (currentLineMode() === NewLineMode && writer.last.slice(-1)[0] !== '\\n') {\n writer.write('\\n')\n }\n break\n case PropertyDelimiter:\n if (currentLineMode() === NewLineMode) {\n writer.write('\\n')\n } else {\n writer.write(', ')\n }\n break\n case NewLine:\n writer.write('\\n')\n break\n default:\n // Multi-line\n if (part.includes('\\n') || part.includes('\\r')) {\n if (writer.last.slice(-1)[0] !== '\\n') writer.write('\\n')\n const normalisedLineEndings = part.replaceAll(/\\r\\n/g, '\\n').replaceAll(/\\r/g, '\\n').replace(/^\\n/, '').trimEnd()\n const lines = normalisedLineEndings.split('\\n')\n const baseIndent = lines[0].match(/^\\s+/)?.[0] ?? ''\n for (const line of lines) {\n writer.write(curIndent + line.replace(new RegExp(`^${baseIndent}`, ''), '').trimEnd())\n writer.write('\\n')\n }\n } else {\n if (writer.last.slice(-1)[0] === '\\n') writer.write(curIndent)\n writer.write(part)\n }\n if (currentLineMode() === NewLineMode) writer.write('\\n')\n break\n }\n }\n}\n"],"names":[],"mappings":"MAAa,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,SAAS,GAAG,MAAM,CAAC,iBAAiB;MACpC,sBAAsB,GAAG,MAAM,CAAC,2CAA2C;MAC3E,WAAW,GAAG,MAAM,CAAC,eAAe;MACpC,eAAe,GAAG,MAAM,CAAC,mBAAmB;MAC5C,iBAAiB,GAAG,MAAM,CAAC,oBAAoB;MAC/C,UAAU,GAAG,MAAM,CAAC,aAAa;MACjC,OAAO,GAAG,MAAM,CAAC,UAAU;AAyBlC,SAAU,0BAA0B,CAAC,QAAuB,EAAE,MAAsC,EAAE,UAAwB,EAAE,EAAA;AACpI,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACnB,CAAC;AACD,QAAA,IAAI,IAAI,GAAA;YACN,OAAO,IAAI,CAAC,KAAK;QACnB,CAAC;KACF;AACD,IAAA,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC;AACjD;SAEgB,0BAA0B,CAAC,QAAuB,EAAE,UAAwB,EAAE,EAAA;AAC5F,IAAA,MAAM,MAAM,GAAG;AACb,QAAA,MAAM,EAAE,EAAc;AACtB,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,KAAK,CAAC,GAAW,EAAA;AACf,YAAA,IAAI,CAAC,KAAK,GAAG,GAAG;AAChB,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACvB,CAAC;AACD,QAAA,IAAI,IAAI,GAAA;Y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
7
  ],
8
8
  "name": "@algorandfoundation/algokit-client-generator",
9
- "version": "6.0.0",
9
+ "version": "6.0.1-beta.1",
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,
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sources":["../../src/schema/load.ts"],"sourcesContent":["import { Schema, Validator } from 'jsonschema'\nimport { boom } from '../util/boom'\nimport arc32Schema from './application.schema.json' with { type: 'json' }\nimport arc56Schema from './arc56.schema.json' with { type: 'json' }\nimport contractSchema from './contract.schema.json' with { type: 'json' }\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { AppSpec, arc32ToArc56 } from '@algorandfoundation/algokit-utils/types/app-spec'\n\nexport async function loadApplicationJson(appJsonPath: string): Promise<Arc56Contract> {\n const fs = await import('fs')\n if (!fs.existsSync(appJsonPath)) boom(`Could not find application.json file at ${appJsonPath}`)\n\n let jsonText = fs.readFileSync(appJsonPath, 'utf-8')\n let file = JSON.parse(jsonText)\n // Temporary to get backwards compatibility with TEALScript draft ARC-56\n if (!('contract' in file) /* ARC-56 */) {\n jsonText = jsonText.replace(/ype\":\\s*\"bytes\"/g, 'ype\":\"AVMBytes\"').replace(/import\\(.+?\\)\\./g, '')\n file = JSON.parse(jsonText)\n }\n\n return validateApplicationJson(file, appJsonPath)\n}\n\nexport function validateApplicationJson(json: unknown, appJsonPath: string): Arc56Contract {\n if (typeof json !== 'object') boom(`Could not parse ${appJsonPath} as JSON object`)\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n if ('contract' in (json as any)) {\n // ARC-32\n const arc32Validator = new Validator()\n arc32Validator.addSchema(contractSchema, '/contract.schema.json')\n const arc32Result = arc32Validator.validate(json, arc32Schema as unknown as Schema)\n if (!arc32Result.valid) boom(`Could not parse ${appJsonPath} as ARC-32.\\n${arc32Result}`)\n return arc32ToArc56(json as AppSpec)\n }\n // ARC-56\n const arc56Validator = new Validator()\n const arc56Result = arc56Validator.validate(json, arc56Schema as unknown as Schema)\n if (!arc56Result.valid) boom(`Could not parse ${appJsonPath} as ARC-56.\\n${arc56Result}`)\n return json as Arc56Contract\n}\n"],"names":["boom","Validator","contractSchema","arc32Schema","arc32ToArc56","arc56Schema"],"mappings":";;;;;;;;;AAQO,eAAe,mBAAmB,CAAC,WAAmB,EAAA;AAC3D,IAAA,MAAM,EAAE,GAAG,MAAM,OAAO,IAAI,CAAC;AAC7B,IAAA,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;AAAE,QAAAA,SAAI,CAAC,CAAA,wCAAA,EAA2C,WAAW,CAAA,CAAE,CAAC;IAE/F,IAAI,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC;IACpD,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;IAE/B,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,eAAe;AACtC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AAClG,QAAA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;AAG7B,IAAA,OAAO,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC;AACnD;AAEgB,SAAA,uBAAuB,CAAC,IAAa,EAAE,WAAmB,EAAA;IACxE,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAAA,SAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,CAAA,eAAA,CAAiB,CAAC;;AAGnF,IAAA,IAAI,UAAU,IAAK,IAAY,EAAE;;AAE/B,QAAA,MAAM,cAAc,GAAG,IAAIC,oBAAS,EAAE;AACtC,QAAA,cAAc,CAAC,SAAS,CAACC,uBAAc,EAAE,uBAAuB,CAAC;QACjE,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAEC,0BAAgC,CAAC;QACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,YAAAH,SAAI,CAAC,CAAmB,gBAAA,EAAA,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,QAAA,OAAOI,oBAAY,CAAC,IAAe,CAAC;;;AAGtC,IAAA,MAAM,cAAc,GAAG,IAAIH,oBAAS,EAAE;IACtC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAEI,oBAAgC,CAAC;IACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,QAAAL,SAAI,CAAC,CAAmB,gBAAA,EAAA,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,IAAA,OAAO,IAAqB;AAC9B;;;;;"}
1
+ {"version":3,"file":"load.js","sources":["../../src/schema/load.ts"],"sourcesContent":["import { Schema, Validator } from 'jsonschema'\nimport { boom } from '../util/boom'\nimport arc32Schema from './application.schema.json' with { type: 'json' }\nimport arc56Schema from './arc56.schema.json' with { type: 'json' }\nimport contractSchema from './contract.schema.json' with { type: 'json' }\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { AppSpec, arc32ToArc56 } from '@algorandfoundation/algokit-utils/types/app-spec'\n\nexport async function loadApplicationJson(appJsonPath: string): Promise<Arc56Contract> {\n const fs = await import('fs')\n if (!fs.existsSync(appJsonPath)) boom(`Could not find application.json file at ${appJsonPath}`)\n\n let jsonText = fs.readFileSync(appJsonPath, 'utf-8')\n let file = JSON.parse(jsonText)\n // Temporary to get backwards compatibility with TEALScript draft ARC-56\n if (!('contract' in file) /* ARC-56 */) {\n jsonText = jsonText.replace(/ype\":\\s*\"bytes\"/g, 'ype\":\"AVMBytes\"').replace(/import\\(.+?\\)\\./g, '')\n file = JSON.parse(jsonText)\n }\n\n return validateApplicationJson(file, appJsonPath)\n}\n\nexport function validateApplicationJson(json: unknown, appJsonPath: string): Arc56Contract {\n if (typeof json !== 'object') boom(`Could not parse ${appJsonPath} as JSON object`)\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n if ('contract' in (json as any)) {\n // ARC-32\n const arc32Validator = new Validator()\n arc32Validator.addSchema(contractSchema, '/contract.schema.json')\n const arc32Result = arc32Validator.validate(json, arc32Schema as unknown as Schema)\n if (!arc32Result.valid) boom(`Could not parse ${appJsonPath} as ARC-32.\\n${arc32Result}`)\n return arc32ToArc56(json as AppSpec)\n }\n // ARC-56\n const arc56Validator = new Validator()\n const arc56Result = arc56Validator.validate(json, arc56Schema as unknown as Schema)\n if (!arc56Result.valid) boom(`Could not parse ${appJsonPath} as ARC-56.\\n${arc56Result}`)\n return json as Arc56Contract\n}\n"],"names":["boom","Validator","contractSchema","arc32Schema","arc32ToArc56","arc56Schema"],"mappings":";;;;;;;;;AAQO,eAAe,mBAAmB,CAAC,WAAmB,EAAA;AAC3D,IAAA,MAAM,EAAE,GAAG,MAAM,OAAO,IAAI,CAAC;AAC7B,IAAA,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;AAAE,QAAAA,SAAI,CAAC,CAAA,wCAAA,EAA2C,WAAW,CAAA,CAAE,CAAC;IAE/F,IAAI,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC;IACpD,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;IAE/B,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,eAAe;AACtC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AAClG,QAAA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B;AAEA,IAAA,OAAO,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC;AACnD;AAEM,SAAU,uBAAuB,CAAC,IAAa,EAAE,WAAmB,EAAA;IACxE,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAAA,SAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,CAAA,eAAA,CAAiB,CAAC;;AAGnF,IAAA,IAAI,UAAU,IAAK,IAAY,EAAE;;AAE/B,QAAA,MAAM,cAAc,GAAG,IAAIC,oBAAS,EAAE;AACtC,QAAA,cAAc,CAAC,SAAS,CAACC,uBAAc,EAAE,uBAAuB,CAAC;QACjE,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAEC,0BAAgC,CAAC;QACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,YAAAH,SAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,QAAA,OAAOI,oBAAY,CAAC,IAAe,CAAC;IACtC;;AAEA,IAAA,MAAM,cAAc,GAAG,IAAIH,oBAAS,EAAE;IACtC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAEI,oBAAgC,CAAC;IACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,QAAAL,SAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,IAAA,OAAO,IAAqB;AAC9B;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"load.mjs","sources":["../../src/schema/load.ts"],"sourcesContent":["import { Schema, Validator } from 'jsonschema'\nimport { boom } from '../util/boom'\nimport arc32Schema from './application.schema.json' with { type: 'json' }\nimport arc56Schema from './arc56.schema.json' with { type: 'json' }\nimport contractSchema from './contract.schema.json' with { type: 'json' }\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { AppSpec, arc32ToArc56 } from '@algorandfoundation/algokit-utils/types/app-spec'\n\nexport async function loadApplicationJson(appJsonPath: string): Promise<Arc56Contract> {\n const fs = await import('fs')\n if (!fs.existsSync(appJsonPath)) boom(`Could not find application.json file at ${appJsonPath}`)\n\n let jsonText = fs.readFileSync(appJsonPath, 'utf-8')\n let file = JSON.parse(jsonText)\n // Temporary to get backwards compatibility with TEALScript draft ARC-56\n if (!('contract' in file) /* ARC-56 */) {\n jsonText = jsonText.replace(/ype\":\\s*\"bytes\"/g, 'ype\":\"AVMBytes\"').replace(/import\\(.+?\\)\\./g, '')\n file = JSON.parse(jsonText)\n }\n\n return validateApplicationJson(file, appJsonPath)\n}\n\nexport function validateApplicationJson(json: unknown, appJsonPath: string): Arc56Contract {\n if (typeof json !== 'object') boom(`Could not parse ${appJsonPath} as JSON object`)\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n if ('contract' in (json as any)) {\n // ARC-32\n const arc32Validator = new Validator()\n arc32Validator.addSchema(contractSchema, '/contract.schema.json')\n const arc32Result = arc32Validator.validate(json, arc32Schema as unknown as Schema)\n if (!arc32Result.valid) boom(`Could not parse ${appJsonPath} as ARC-32.\\n${arc32Result}`)\n return arc32ToArc56(json as AppSpec)\n }\n // ARC-56\n const arc56Validator = new Validator()\n const arc56Result = arc56Validator.validate(json, arc56Schema as unknown as Schema)\n if (!arc56Result.valid) boom(`Could not parse ${appJsonPath} as ARC-56.\\n${arc56Result}`)\n return json as Arc56Contract\n}\n"],"names":[],"mappings":";;;;;;;AAQO,eAAe,mBAAmB,CAAC,WAAmB,EAAA;AAC3D,IAAA,MAAM,EAAE,GAAG,MAAM,OAAO,IAAI,CAAC;AAC7B,IAAA,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;AAAE,QAAA,IAAI,CAAC,CAAA,wCAAA,EAA2C,WAAW,CAAA,CAAE,CAAC;IAE/F,IAAI,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC;IACpD,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;IAE/B,IAAI,EAAE,UAAU,IAAI,IAAI,CAAC,eAAe;AACtC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;AAClG,QAAA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;AAG7B,IAAA,OAAO,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC;AACnD;AAEgB,SAAA,uBAAuB,CAAC,IAAa,EAAE,WAAmB,EAAA;IACxE,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,QAAA,IAAI,CAAC,CAAA,gBAAA,EAAmB,WAAW,CAAA,eAAA,CAAiB,CAAC;;AAGnF,IAAA,IAAI,UAAU,IAAK,IAAY,EAAE;;AAE/B,QAAA,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE;AACtC,QAAA,cAAc,CAAC,SAAS,CAAC,cAAc,EAAE,uBAAuB,CAAC;QACjE,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAgC,CAAC;QACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,YAAA,IAAI,CAAC,CAAmB,gBAAA,EAAA,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,QAAA,OAAO,YAAY,CAAC,IAAe,CAAC;;;AAGtC,IAAA,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE;IACtC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAgC,CAAC;IACnF,IAAI,CAAC,WAAW,CAAC,KAAK;AAAE,QAAA,IAAI,CAAC,CAAmB,gBAAA,EAAA,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,IAAA,OAAO,IAAqB;AAC9B;;;;"}
1
+ {"version":3,"file":"load.mjs","sources":["../../src/schema/load.ts"],"sourcesContent":["import { Schema, Validator } from 'jsonschema'\nimport { boom } from '../util/boom'\nimport arc32Schema from './application.schema.json' with { type: 'json' }\nimport arc56Schema from './arc56.schema.json' with { type: 'json' }\nimport contractSchema from './contract.schema.json' with { type: 'json' }\nimport { Arc56Contract } from '@algorandfoundation/algokit-utils/types/app-arc56'\nimport { AppSpec, arc32ToArc56 } from '@algorandfoundation/algokit-utils/types/app-spec'\n\nexport async function loadApplicationJson(appJsonPath: string): Promise<Arc56Contract> {\n const fs = await import('fs')\n if (!fs.existsSync(appJsonPath)) boom(`Could not find application.json file at ${appJsonPath}`)\n\n let jsonText = fs.readFileSync(appJsonPath, 'utf-8')\n let file = JSON.parse(jsonText)\n // Temporary to get backwards compatibility with TEALScript draft ARC-56\n if (!('contract' in file) /* ARC-56 */) {\n jsonText = jsonText.replace(/ype\":\\s*\"bytes\"/g, 'ype\":\"AVMBytes\"').replace(/import\\(.+?\\)\\./g, '')\n file = JSON.parse(jsonText)\n }\n\n return validateApplicationJson(file, appJsonPath)\n}\n\nexport function validateApplicationJson(json: unknown, appJsonPath: string): Arc56Contract {\n if (typeof json !== 'object') boom(`Could not parse ${appJsonPath} as JSON object`)\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n if ('contract' in (json as any)) {\n // ARC-32\n const arc32Validator = new Validator()\n arc32Validator.addSchema(contractSchema, '/contract.schema.json')\n const arc32Result = arc32Validator.validate(json, arc32Schema as unknown as Schema)\n if (!arc32Result.valid) boom(`Could not parse ${appJsonPath} as ARC-32.\\n${arc32Result}`)\n return arc32ToArc56(json as AppSpec)\n }\n // ARC-56\n const arc56Validator = new Validator()\n const arc56Result = arc56Validator.validate(json, arc56Schema as unknown as Schema)\n if (!arc56Result.valid) boom(`Could not parse ${appJsonPath} as ARC-56.\\n${arc56Result}`)\n return json as Arc56Contract\n}\n"],"names":[],"mappings":";;;;;;;AAQO,eAAe,mBAAmB,CAAC,WAAmB,EAAA;AAC3D,IAAA,MAAM,EAAE,GAAG,MAAM,OAAO,IAAI,CAAC;AAC7B,IAAA,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;AAAE,QAAA,IAAI,CAAC,CAAA,wC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gBAAA,EAAmB,WAAW,gBAAgB,WAAW,CAAA,CAAE,CAAC;AACzF,IAAA,OAAO,IAAqB;AAC9B;;;;"}
package/util/boom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"boom.js","sources":["../../src/util/boom.ts"],"sourcesContent":["export const boom = (reason: string): never => {\n throw new Error(reason)\n}\n"],"names":[],"mappings":";;AAAa,MAAA,IAAI,GAAG,CAAC,MAAc,KAAW;AAC5C,IAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;AACzB;;;;"}
1
+ {"version":3,"file":"boom.js","sources":["../../src/util/boom.ts"],"sourcesContent":["export const boom = (reason: string): never => {\n throw new Error(reason)\n}\n"],"names":[],"mappings":";;AAAO,MAAM,IAAI,GAAG,CAAC,MAAc,KAAW;AAC5C,IAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;AACzB;;;;"}
package/util/boom.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"boom.mjs","sources":["../../src/util/boom.ts"],"sourcesContent":["export const boom = (reason: string): never => {\n throw new Error(reason)\n}\n"],"names":[],"mappings":"AAAa,MAAA,IAAI,GAAG,CAAC,MAAc,KAAW;AAC5C,IAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;AACzB;;;;"}
1
+ {"version":3,"file":"boom.mjs","sources":["../../src/util/boom.ts"],"sourcesContent":["export const boom = (reason: string): never => {\n throw new Error(reason)\n}\n"],"names":[],"mappings":"AAAO,MAAM,IAAI,GAAG,CAAC,MAAc,KAAW;AAC5C,IAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;AACzB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"color-console.js","sources":["../../src/util/color-console.ts"],"sourcesContent":["import chalk from 'chalk'\n\ntype ColorFn = (text: string) => string\n\nconst createColorFormatter =\n (textColor: ColorFn, argColor: ColorFn, consoleFn: 'log' | 'error' | 'info' | 'warn') =>\n (textParts: TemplateStringsArray, ...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console[consoleFn](\n textParts\n .flatMap((t, i) => (args.length > i ? [textColor(t), argColor(`${args[i]}`)] : textColor(t)))\n .reduce((acc, cur) => acc + cur, ''),\n )\n }\n\nexport const colorConsole = {\n info: createColorFormatter(chalk.cyan, chalk.blue, 'info'),\n warn: createColorFormatter(chalk.yellow, chalk.yellow.bold, 'warn'),\n success: createColorFormatter(chalk.green, chalk.green.bold, 'info'),\n error: createColorFormatter(chalk.red, chalk.red.bold, 'error'),\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,oBAAoB,GACxB,CAAC,SAAkB,EAAE,QAAiB,EAAE,SAA4C,KACpF,CAAC,SAA+B,EAAE,GAAG,IAAe,KAAU;;AAE5D,IAAA,OAAO,CAAC,SAAS,CAAC,CAChB;AACG,SAAA,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3F,SAAA,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CACvC;AACH,CAAC;AAEU,MAAA,YAAY,GAAG;AAC1B,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AAC1D,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;AACnE,IAAA,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AACpE,IAAA,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;;;;;"}
1
+ {"version":3,"file":"color-console.js","sources":["../../src/util/color-console.ts"],"sourcesContent":["import chalk from 'chalk'\n\ntype ColorFn = (text: string) => string\n\nconst createColorFormatter =\n (textColor: ColorFn, argColor: ColorFn, consoleFn: 'log' | 'error' | 'info' | 'warn') =>\n (textParts: TemplateStringsArray, ...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console[consoleFn](\n textParts\n .flatMap((t, i) => (args.length > i ? [textColor(t), argColor(`${args[i]}`)] : textColor(t)))\n .reduce((acc, cur) => acc + cur, ''),\n )\n }\n\nexport const colorConsole = {\n info: createColorFormatter(chalk.cyan, chalk.blue, 'info'),\n warn: createColorFormatter(chalk.yellow, chalk.yellow.bold, 'warn'),\n success: createColorFormatter(chalk.green, chalk.green.bold, 'info'),\n error: createColorFormatter(chalk.red, chalk.red.bold, 'error'),\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,oBAAoB,GACxB,CAAC,SAAkB,EAAE,QAAiB,EAAE,SAA4C,KACpF,CAAC,SAA+B,EAAE,GAAG,IAAe,KAAU;;AAE5D,IAAA,OAAO,CAAC,SAAS,CAAC,CAChB;AACG,SAAA,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3F,SAAA,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CACvC;AACH,CAAC;AAEI,MAAM,YAAY,GAAG;AAC1B,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AAC1D,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;AACnE,IAAA,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AACpE,IAAA,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"color-console.mjs","sources":["../../src/util/color-console.ts"],"sourcesContent":["import chalk from 'chalk'\n\ntype ColorFn = (text: string) => string\n\nconst createColorFormatter =\n (textColor: ColorFn, argColor: ColorFn, consoleFn: 'log' | 'error' | 'info' | 'warn') =>\n (textParts: TemplateStringsArray, ...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console[consoleFn](\n textParts\n .flatMap((t, i) => (args.length > i ? [textColor(t), argColor(`${args[i]}`)] : textColor(t)))\n .reduce((acc, cur) => acc + cur, ''),\n )\n }\n\nexport const colorConsole = {\n info: createColorFormatter(chalk.cyan, chalk.blue, 'info'),\n warn: createColorFormatter(chalk.yellow, chalk.yellow.bold, 'warn'),\n success: createColorFormatter(chalk.green, chalk.green.bold, 'info'),\n error: createColorFormatter(chalk.red, chalk.red.bold, 'error'),\n}\n"],"names":[],"mappings":";;AAIA,MAAM,oBAAoB,GACxB,CAAC,SAAkB,EAAE,QAAiB,EAAE,SAA4C,KACpF,CAAC,SAA+B,EAAE,GAAG,IAAe,KAAU;;AAE5D,IAAA,OAAO,CAAC,SAAS,CAAC,CAChB;AACG,SAAA,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3F,SAAA,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CACvC;AACH,CAAC;AAEU,MAAA,YAAY,GAAG;AAC1B,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AAC1D,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;AACnE,IAAA,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AACpE,IAAA,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;;;;;"}
1
+ {"version":3,"file":"color-console.mjs","sources":["../../src/util/color-console.ts"],"sourcesContent":["import chalk from 'chalk'\n\ntype ColorFn = (text: string) => string\n\nconst createColorFormatter =\n (textColor: ColorFn, argColor: ColorFn, consoleFn: 'log' | 'error' | 'info' | 'warn') =>\n (textParts: TemplateStringsArray, ...args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console[consoleFn](\n textParts\n .flatMap((t, i) => (args.length > i ? [textColor(t), argColor(`${args[i]}`)] : textColor(t)))\n .reduce((acc, cur) => acc + cur, ''),\n )\n }\n\nexport const colorConsole = {\n info: createColorFormatter(chalk.cyan, chalk.blue, 'info'),\n warn: createColorFormatter(chalk.yellow, chalk.yellow.bold, 'warn'),\n success: createColorFormatter(chalk.green, chalk.green.bold, 'info'),\n error: createColorFormatter(chalk.red, chalk.red.bold, 'error'),\n}\n"],"names":[],"mappings":";;AAIA,MAAM,oBAAoB,GACxB,CAAC,SAAkB,EAAE,QAAiB,EAAE,SAA4C,KACpF,CAAC,SAA+B,EAAE,GAAG,IAAe,KAAU;;AAE5D,IAAA,OAAO,CAAC,SAAS,CAAC,CAChB;AACG,SAAA,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA,CAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3F,SAAA,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC,CACvC;AACH,CAAC;AAEI,MAAM,YAAY,GAAG;AAC1B,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AAC1D,IAAA,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;AACnE,IAAA,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC;AACpE,IAAA,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitization.js","sources":["../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\nimport { GeneratorOptions } from '../client/generator-context'\n\nconst replaceInvalidWithUnderscore = (value: string) => value.replace(/[^a-z0-9_$]+/gi, '_')\n\nconst escapeQuotes = (value: string) => value.replace(/['\"]/g, (val) => `\\\\${val}`)\n\nconst removeEnclosingQuotes = (value: string) => value.replace(/^\"|\"$/g, '')\n\nexport interface Sanitizer {\n makeSafeTypeIdentifier(value: string): string\n makeSafeMethodIdentifier(value: string): string\n makeSafeVariableIdentifier(value: string): string\n makeSafePropertyIdentifier(value: string): string\n makeSafeStringTypeLiteral(value: string): string\n getSafeMemberAccessor(value: string): string\n isSafeVariableIdentifier(value: string): boolean\n}\n\nconst defaultSanitiser: Sanitizer = {\n makeSafePropertyIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeTypeIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return pascalCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeMethodIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n isSafeVariableIdentifier(value: string) {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeVariableIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${this.makeSafeStringTypeLiteral(value)}']`\n },\n}\n\nconst preservingSanitiser: Sanitizer = {\n isSafeVariableIdentifier(value: string): boolean {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeMethodIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafePropertyIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafeTypeIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeVariableIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`\n },\n}\n\nexport const getSanitizer = (options: GeneratorOptions) => (options.preserveNames ? preservingSanitiser : defaultSanitiser)\n"],"names":["camelCase","pascalCase"],"mappings":";;;;AAGA,MAAM,4BAA4B,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAE5F,MAAM,YAAY,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,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,EAAE;QACtE,OAAOC,qBAAU,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;KAChE;AACD,IAAA,wBAAwB,CAAC,KAAa,EAAA;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE;QACtE,OAAOD,oBAAS,CAAC,4BAA4B,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;KAC/D;AACD,IAAA,wBAAwB,CAAC,KAAa,EAA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AAK,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;;;;"}
1
+ {"version":3,"file":"sanitization.js","sources":["../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\nimport { GeneratorOptions } from '../client/generator-context'\n\nconst replaceInvalidWithUnderscore = (value: string) => value.replace(/[^a-z0-9_$]+/gi, '_')\n\nconst escapeQuotes = (value: string) => value.replace(/['\"]/g, (val) => `\\\\${val}`)\n\nconst removeEnclosingQuotes = (value: string) => value.replace(/^\"|\"$/g, '')\n\nexport interface Sanitizer {\n makeSafeTypeIdentifier(value: string): string\n makeSafeMethodIdentifier(value: string): string\n makeSafeVariableIdentifier(value: string): string\n makeSafePropertyIdentifier(value: string): string\n makeSafeStringTypeLiteral(value: string): string\n getSafeMemberAccessor(value: string): string\n isSafeVariableIdentifier(value: string): boolean\n}\n\nconst defaultSanitiser: Sanitizer = {\n makeSafePropertyIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeTypeIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return pascalCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeMethodIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n isSafeVariableIdentifier(value: string) {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeVariableIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${this.makeSafeStringTypeLiteral(value)}']`\n },\n}\n\nconst preservingSanitiser: Sanitizer = {\n isSafeVariableIdentifier(value: string): boolean {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeMethodIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafePropertyIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafeTypeIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeVariableIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`\n },\n}\n\nexport const getSanitizer = (options: GeneratorOptions) => (options.preserveNames ? preservingSanitiser : defaultSanitiser)\n"],"names":["camelCase","pascalCase"],"mappings":";;;;AAGA,MAAM,4BAA4B,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAE5F,MAAM,YAAY,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,CAAC;AAEnF,MAAM,qBAAqB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,E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;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitization.mjs","sources":["../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\nimport { GeneratorOptions } from '../client/generator-context'\n\nconst replaceInvalidWithUnderscore = (value: string) => value.replace(/[^a-z0-9_$]+/gi, '_')\n\nconst escapeQuotes = (value: string) => value.replace(/['\"]/g, (val) => `\\\\${val}`)\n\nconst removeEnclosingQuotes = (value: string) => value.replace(/^\"|\"$/g, '')\n\nexport interface Sanitizer {\n makeSafeTypeIdentifier(value: string): string\n makeSafeMethodIdentifier(value: string): string\n makeSafeVariableIdentifier(value: string): string\n makeSafePropertyIdentifier(value: string): string\n makeSafeStringTypeLiteral(value: string): string\n getSafeMemberAccessor(value: string): string\n isSafeVariableIdentifier(value: string): boolean\n}\n\nconst defaultSanitiser: Sanitizer = {\n makeSafePropertyIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeTypeIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return pascalCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeMethodIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n isSafeVariableIdentifier(value: string) {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeVariableIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${this.makeSafeStringTypeLiteral(value)}']`\n },\n}\n\nconst preservingSanitiser: Sanitizer = {\n isSafeVariableIdentifier(value: string): boolean {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeMethodIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafePropertyIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafeTypeIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeVariableIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`\n },\n}\n\nexport const getSanitizer = (options: GeneratorOptions) => (options.preserveNames ? preservingSanitiser : defaultSanitiser)\n"],"names":[],"mappings":";;AAGA,MAAM,4BAA4B,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;AAE5F,MAAM,YAAY,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,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,OAAO,SAAS,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,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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;;;;"}
1
+ {"version":3,"file":"sanitization.mjs","sources":["../../src/util/sanitization.ts"],"sourcesContent":["import { camelCase, pascalCase } from 'change-case'\nimport { GeneratorOptions } from '../client/generator-context'\n\nconst replaceInvalidWithUnderscore = (value: string) => value.replace(/[^a-z0-9_$]+/gi, '_')\n\nconst escapeQuotes = (value: string) => value.replace(/['\"]/g, (val) => `\\\\${val}`)\n\nconst removeEnclosingQuotes = (value: string) => value.replace(/^\"|\"$/g, '')\n\nexport interface Sanitizer {\n makeSafeTypeIdentifier(value: string): string\n makeSafeMethodIdentifier(value: string): string\n makeSafeVariableIdentifier(value: string): string\n makeSafePropertyIdentifier(value: string): string\n makeSafeStringTypeLiteral(value: string): string\n getSafeMemberAccessor(value: string): string\n isSafeVariableIdentifier(value: string): boolean\n}\n\nconst defaultSanitiser: Sanitizer = {\n makeSafePropertyIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeTypeIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return pascalCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeMethodIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n isSafeVariableIdentifier(value: string) {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeVariableIdentifier(value: string) {\n const options = value.startsWith('_') ? { prefixCharacters: '_' } : {}\n return camelCase(replaceInvalidWithUnderscore(value), options)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${this.makeSafeStringTypeLiteral(value)}']`\n },\n}\n\nconst preservingSanitiser: Sanitizer = {\n isSafeVariableIdentifier(value: string): boolean {\n return /^[a-z$_][a-z0-9_$]*$/i.test(value)\n },\n makeSafeMethodIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafePropertyIdentifier(value: string): string {\n return this.isSafeVariableIdentifier(value) ? value : `\"${this.makeSafeStringTypeLiteral(value)}\"`\n },\n makeSafeTypeIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeVariableIdentifier(value: string): string {\n return replaceInvalidWithUnderscore(value)\n },\n makeSafeStringTypeLiteral(value: string): string {\n return escapeQuotes(value)\n },\n getSafeMemberAccessor(value: string): string {\n return this.isSafeVariableIdentifier(value) ? `.${value}` : `['${removeEnclosingQuotes(value)}']`\n },\n}\n\nexport const getSanitizer = (options: GeneratorOptions) => (options.preserveNames ? preservingSanitiser : defaultSanitiser)\n"],"names":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