@azure-tools/codegen
Advanced tools
Comparing version 2.6.0 to 2.7.0-dev.1
@@ -9,3 +9,3 @@ { | ||
"packages/libs/codegen/jest.config.js": "37a264bc912dd5e8d055d71e7719a0e4b5e66cb5", | ||
"packages/libs/codegen/package.json": "700745d780d264eb928245facc15a0dcaefaeb0c", | ||
"packages/libs/codegen/package.json": "f45fe429e5b44b76db3932f604d83ed730e5230d", | ||
"packages/libs/codegen/readme.md": "2ee26d6c053063c75ebce1f7203e5614c730a843", | ||
@@ -17,19 +17,19 @@ "packages/libs/codegen/src/apiversion/apiversion.test.ts": "d2a5567118ca9198fa96fb7a4119c3314584ffe8", | ||
"packages/libs/codegen/src/formatter/formatter.test.ts": "52c0f723ca893cb814d26bba283a0a9eba23c7c8", | ||
"packages/libs/codegen/src/formatter/formatter.ts": "967a77ae5338c046cb5ff4915265c370281f2ef1", | ||
"packages/libs/codegen/src/formatter/formatter.ts": "ccf0399dec70aa72b06e1c52c074c5e482c44e10", | ||
"packages/libs/codegen/src/index.ts": "099365b3957ef4ab7420f914c23c63c86c4f490d", | ||
"packages/libs/codegen/src/initializer.ts": "a6495476a1bc94dedf22cb70a685543c87b91607", | ||
"packages/libs/codegen/src/initializer.ts": "3ef7ca403817731b434f4ffc8f1a0c003a100f5c", | ||
"packages/libs/codegen/src/intersect.ts": "697481f619de2c31331cfc5ecd08594f5edb3c69", | ||
"packages/libs/codegen/src/media-types.ts": "088726337420fa095a3d46fad422523dc4a89359", | ||
"packages/libs/codegen/src/pluralization.ts": "710f0af72ff9b6411c243fffc5551103ffdcf89f", | ||
"packages/libs/codegen/src/pluralization.ts": "1e649a233892bc2ab7e3597418b26d01cc182dc9", | ||
"packages/libs/codegen/src/safe-eval.ts": "658d4e78226ece6f5f52fd8028dc3e42b88a35cd", | ||
"packages/libs/codegen/src/source-track.ts": "f494b76f4f8d849d4f5ac792935c29c7b09c282c", | ||
"packages/libs/codegen/src/text-manipulation.ts": "b8701d5c9d1c449dd9e9e9f28cffbd2203929027", | ||
"packages/libs/codegen/src/source-track.ts": "d6cd9672ca157c544e57b0c782756453dfdb0616", | ||
"packages/libs/codegen/src/text-manipulation.ts": "be00464a9a71edf9b790c798e3bd2d87e89fcd22", | ||
"packages/libs/codegen/src/type.ts": "5d3203985562968a486e283d9a87311fe44ee154", | ||
"packages/libs/codegen/src/utility.ts": "e5f09f6b46d49b9cf2733f3c339a960eca59085b", | ||
"packages/libs/codegen/src/utility.ts": "07879670dea4e23055d344c40bc2792d7f6b116d", | ||
"packages/libs/codegen/src/yaml.ts": "206b0350ed1849e0433d6dd9b9050b72d828fee3", | ||
"packages/libs/codegen/tsconfig.build.json": "b4079ce75de1aff6128d84ef08634d399f794171", | ||
"packages/libs/codegen/tsconfig.json": "91b3259f9e6fdec611acc36bb88ab6cbfe85c3e0", | ||
"packages/libs/codegen/.rush/temp/shrinkwrap-deps.json": "658b7e4ae06b87d92c920eabadc41b0f6d2ec5f1" | ||
"packages/libs/codegen/.rush/temp/shrinkwrap-deps.json": "afb8bac27a25c9b84cc9edf9ceb80527188d6484" | ||
}, | ||
"arguments": "tsc -p ./tsconfig.build.json " | ||
} |
{ | ||
"@azure-tools/async-io@3.0.253": "sha512-5Zo6Sr7ttnh6vaDhG1ESycJtOKzJCxo+bdJ68dmGgU/czm2HDptjKcVvenNuJNeWpvf0DmklXQDXZIkg11swzw==", | ||
"@azure-tools/linq@3.1.262": "sha512-7ctcSXYoGkTvWahsgnHh50D8+nT4hF6h+benQUKDQWdQHUFiV14QvLmGbPqux4Yp57OcX1NOwqKeA6JQDWsEuQ==", | ||
"@azure-tools/tasks@3.0.253": "sha512-ViYOxgal9iukwbebZUpj5hEnT6OjSLDFItqPXYfMkntm7BCM1OQbBVo49KMBqOyCu6o+M5EVC7KF8SldL3oGtg==", | ||
@@ -5,0 +4,0 @@ "@babel/code-frame@7.12.11": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", |
@@ -1,12 +0,11 @@ | ||
import { Dictionary } from "@azure-tools/linq"; | ||
export declare type Styler = (identifier: string | Array<string>, removeDuplicates: boolean | undefined, overrides: Dictionary<string> | undefined) => string; | ||
export declare type Styler = (identifier: string | Array<string>, removeDuplicates: boolean | undefined, overrides: Record<string, string> | undefined) => string; | ||
export declare class Style { | ||
static select(style: any, fallback: Styler, maxUppercasePreserve: number): Styler; | ||
static kebab(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>, maxUppercasePreserve?: number): string; | ||
static space(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>, maxUppercasePreserve?: number): string; | ||
static snake(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>, maxUppercasePreserve?: number): string; | ||
static upper(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>, maxUppercasePreserve?: number): string; | ||
static pascal(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>, maxUppercasePreserve?: number): string; | ||
static camel(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Dictionary<string>, maxUppercasePreserve?: number): string; | ||
static kebab(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Record<string, string>, maxUppercasePreserve?: number): string; | ||
static space(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Record<string, string>, maxUppercasePreserve?: number): string; | ||
static snake(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Record<string, string>, maxUppercasePreserve?: number): string; | ||
static upper(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Record<string, string>, maxUppercasePreserve?: number): string; | ||
static pascal(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Record<string, string>, maxUppercasePreserve?: number): string; | ||
static camel(identifier: string | Array<string>, removeDuplicates?: boolean, overrides?: Record<string, string>, maxUppercasePreserve?: number): string; | ||
} | ||
//# sourceMappingURL=formatter.d.ts.map |
@@ -5,3 +5,2 @@ "use strict"; | ||
const text_manipulation_1 = require("../text-manipulation"); | ||
const linq_1 = require("@azure-tools/linq"); | ||
function capitalize(s) { | ||
@@ -30,3 +29,3 @@ return s ? `${s.charAt(0).toUpperCase()}${s.substr(1)}` : s; | ||
if (Array.isArray(identifier)) { | ||
return [...linq_1.values(identifier).selectMany((each) => deconstruct(each, maxUppercasePreserve))]; | ||
return [...identifier.flatMap((each) => deconstruct(each, maxUppercasePreserve))]; | ||
} | ||
@@ -33,0 +32,0 @@ return `${identifier}` |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.Initializer = void 0; | ||
const linq_1 = require("@azure-tools/linq"); | ||
const empty = new Set(); | ||
@@ -15,3 +14,3 @@ function applyTo(source, target, exclusions, cache = new Set()) { | ||
} | ||
for (const i of linq_1.keys(source)) { | ||
for (const i of Object.keys(source !== null && source !== void 0 ? source : {})) { | ||
if (exclusions.has(i)) { | ||
@@ -18,0 +17,0 @@ continue; |
@@ -347,117 +347,117 @@ "use strict"; | ||
this.classicalInflectionDictionary = { | ||
"stamen": "stamina", | ||
"foramen": "foramina", | ||
"lumen": "lumina", | ||
"anathema": "anathemata", | ||
stamen: "stamina", | ||
foramen: "foramina", | ||
lumen: "lumina", | ||
anathema: "anathemata", | ||
"----": "----ta", | ||
"oedema": "oedemata", | ||
"bema": "bemata", | ||
"enigma": "enigmata", | ||
"sarcoma": "sarcomata", | ||
"carcinoma": "carcinomata", | ||
"gumma": "gummata", | ||
"schema": "schemata", | ||
"charisma": "charismata", | ||
"lemma": "lemmata", | ||
"soma": "somata", | ||
"diploma": "diplomata", | ||
"lymphoma": "lymphomata", | ||
"stigma": "stigmata", | ||
"dogma": "dogmata", | ||
"magma": "magmata", | ||
"stoma": "stomata", | ||
"drama": "dramata", | ||
"melisma": "melismata", | ||
"trauma": "traumata", | ||
"edema": "edemata", | ||
"miasma": "miasmata", | ||
"abscissa": "abscissae", | ||
"formula": "formulae", | ||
"medusa": "medusae", | ||
"amoeba": "amoebae", | ||
"hydra": "hydrae", | ||
"nebula": "nebulae", | ||
"antenna": "antennae", | ||
"hyperbola": "hyperbolae", | ||
"nova": "novae", | ||
"aurora": "aurorae", | ||
"lacuna": "lacunae", | ||
"parabola": "parabolae", | ||
"apex": "apices", | ||
"latex": "latices", | ||
"vertex": "vertices", | ||
"cortex": "cortices", | ||
"pontifex": "pontifices", | ||
"vortex": "vortices", | ||
"index": "indices", | ||
"simplex": "simplices", | ||
"iris": "irides", | ||
oedema: "oedemata", | ||
bema: "bemata", | ||
enigma: "enigmata", | ||
sarcoma: "sarcomata", | ||
carcinoma: "carcinomata", | ||
gumma: "gummata", | ||
schema: "schemata", | ||
charisma: "charismata", | ||
lemma: "lemmata", | ||
soma: "somata", | ||
diploma: "diplomata", | ||
lymphoma: "lymphomata", | ||
stigma: "stigmata", | ||
dogma: "dogmata", | ||
magma: "magmata", | ||
stoma: "stomata", | ||
drama: "dramata", | ||
melisma: "melismata", | ||
trauma: "traumata", | ||
edema: "edemata", | ||
miasma: "miasmata", | ||
abscissa: "abscissae", | ||
formula: "formulae", | ||
medusa: "medusae", | ||
amoeba: "amoebae", | ||
hydra: "hydrae", | ||
nebula: "nebulae", | ||
antenna: "antennae", | ||
hyperbola: "hyperbolae", | ||
nova: "novae", | ||
aurora: "aurorae", | ||
lacuna: "lacunae", | ||
parabola: "parabolae", | ||
apex: "apices", | ||
latex: "latices", | ||
vertex: "vertices", | ||
cortex: "cortices", | ||
pontifex: "pontifices", | ||
vortex: "vortices", | ||
index: "indices", | ||
simplex: "simplices", | ||
iris: "irides", | ||
"----oris": "----orides", | ||
"alto": "alti", | ||
"contralto": "contralti", | ||
"soprano": "soprani", | ||
alto: "alti", | ||
contralto: "contralti", | ||
soprano: "soprani", | ||
"b----o": "b----i", | ||
"crescendo": "crescendi", | ||
"tempo": "tempi", | ||
"canto": "canti", | ||
"solo": "soli", | ||
"aquarium": "aquaria", | ||
"interregnum": "interregna", | ||
"quantum": "quanta", | ||
"compendium": "compendia", | ||
"lustrum": "lustra", | ||
"rostrum": "rostra", | ||
"consortium": "consortia", | ||
"maximum": "maxima", | ||
"spectrum": "spectra", | ||
"cranium": "crania", | ||
"medium": "media", | ||
"speculum": "specula", | ||
"curriculum": "curricula", | ||
"memorandum": "memoranda", | ||
"stadium": "stadia", | ||
"dictum": "dicta", | ||
"millenium": "millenia", | ||
crescendo: "crescendi", | ||
tempo: "tempi", | ||
canto: "canti", | ||
solo: "soli", | ||
aquarium: "aquaria", | ||
interregnum: "interregna", | ||
quantum: "quanta", | ||
compendium: "compendia", | ||
lustrum: "lustra", | ||
rostrum: "rostra", | ||
consortium: "consortia", | ||
maximum: "maxima", | ||
spectrum: "spectra", | ||
cranium: "crania", | ||
medium: "media", | ||
speculum: "specula", | ||
curriculum: "curricula", | ||
memorandum: "memoranda", | ||
stadium: "stadia", | ||
dictum: "dicta", | ||
millenium: "millenia", | ||
"t----zium": "t----zia", | ||
"emporium": "emporia", | ||
"minimum": "minima", | ||
"ultimatum": "ultimata", | ||
"enconium": "enconia", | ||
"momentum": "momenta", | ||
"vacuum": "vacua", | ||
"gymnasium": "gymnasia", | ||
"optimum": "optima", | ||
"velum": "vela", | ||
"honorarium": "honoraria", | ||
"phylum": "phyla", | ||
"focus": "foci", | ||
"nimbus": "nimbi", | ||
"succubus": "succubi", | ||
"fungus": "fungi", | ||
"nucleolus": "nucleoli", | ||
"torus": "tori", | ||
"genius": "genii", | ||
"radius": "radii", | ||
"umbilicus": "umbilici", | ||
"incubus": "incubi", | ||
"stylus": "styli", | ||
"uterus": "uteri", | ||
"stimulus": "stimuli", | ||
"apparatus": "apparatus", | ||
"impetus": "impetus", | ||
"prospectus": "prospectus", | ||
"cantus": "cantus", | ||
"nexus": "nexus", | ||
"sinus": "sinus", | ||
"coitus": "coitus", | ||
"plexus": "plexus", | ||
"status": "status", | ||
"hiatus": "hiatus", | ||
"afreet": "afreeti", | ||
"afrit": "afriti", | ||
"efreet": "efreeti", | ||
"cherub": "cherubim", | ||
"goy": "goyim", | ||
"seraph": "seraphim", | ||
"alumnus": "alumni", | ||
emporium: "emporia", | ||
minimum: "minima", | ||
ultimatum: "ultimata", | ||
enconium: "enconia", | ||
momentum: "momenta", | ||
vacuum: "vacua", | ||
gymnasium: "gymnasia", | ||
optimum: "optima", | ||
velum: "vela", | ||
honorarium: "honoraria", | ||
phylum: "phyla", | ||
focus: "foci", | ||
nimbus: "nimbi", | ||
succubus: "succubi", | ||
fungus: "fungi", | ||
nucleolus: "nucleoli", | ||
torus: "tori", | ||
genius: "genii", | ||
radius: "radii", | ||
umbilicus: "umbilici", | ||
incubus: "incubi", | ||
stylus: "styli", | ||
uterus: "uteri", | ||
stimulus: "stimuli", | ||
apparatus: "apparatus", | ||
impetus: "impetus", | ||
prospectus: "prospectus", | ||
cantus: "cantus", | ||
nexus: "nexus", | ||
sinus: "sinus", | ||
coitus: "coitus", | ||
plexus: "plexus", | ||
status: "status", | ||
hiatus: "hiatus", | ||
afreet: "afreeti", | ||
afrit: "afriti", | ||
efreet: "efreeti", | ||
cherub: "cherubim", | ||
goy: "goyim", | ||
seraph: "seraphim", | ||
alumnus: "alumni", | ||
}; | ||
@@ -469,96 +469,96 @@ // this list contains all the plural words that being treated as singluar form, for example, "they" -> "they" | ||
this.wordsEndingWithSeDictionary = { | ||
"house": "houses", | ||
"case": "cases", | ||
"enterprise": "enterprises", | ||
"purchase": "purchases", | ||
"surprise": "surprises", | ||
"release": "releases", | ||
"disease": "diseases", | ||
"promise": "promises", | ||
"refuse": "refuses", | ||
"whose": "whoses", | ||
"phase": "phases", | ||
"noise": "noises", | ||
"nurse": "nurses", | ||
"rose": "roses", | ||
"franchise": "franchises", | ||
"supervise": "supervises", | ||
"farmhouse": "farmhouses", | ||
"suitcase": "suitcases", | ||
"recourse": "recourses", | ||
"impulse": "impulses", | ||
"license": "licenses", | ||
"diocese": "dioceses", | ||
"excise": "excises", | ||
"demise": "demises", | ||
"blouse": "blouses", | ||
"bruise": "bruises", | ||
"misuse": "misuses", | ||
"curse": "curses", | ||
"prose": "proses", | ||
"purse": "purses", | ||
"goose": "gooses", | ||
"tease": "teases", | ||
"poise": "poises", | ||
"vase": "vases", | ||
"fuse": "fuses", | ||
"muse": "muses", | ||
"slaughterhouse": "slaughterhouses", | ||
"clearinghouse": "clearinghouses", | ||
"endonuclease": "endonucleases", | ||
"steeplechase": "steeplechases", | ||
"metamorphose": "metamorphoses", | ||
house: "houses", | ||
case: "cases", | ||
enterprise: "enterprises", | ||
purchase: "purchases", | ||
surprise: "surprises", | ||
release: "releases", | ||
disease: "diseases", | ||
promise: "promises", | ||
refuse: "refuses", | ||
whose: "whoses", | ||
phase: "phases", | ||
noise: "noises", | ||
nurse: "nurses", | ||
rose: "roses", | ||
franchise: "franchises", | ||
supervise: "supervises", | ||
farmhouse: "farmhouses", | ||
suitcase: "suitcases", | ||
recourse: "recourses", | ||
impulse: "impulses", | ||
license: "licenses", | ||
diocese: "dioceses", | ||
excise: "excises", | ||
demise: "demises", | ||
blouse: "blouses", | ||
bruise: "bruises", | ||
misuse: "misuses", | ||
curse: "curses", | ||
prose: "proses", | ||
purse: "purses", | ||
goose: "gooses", | ||
tease: "teases", | ||
poise: "poises", | ||
vase: "vases", | ||
fuse: "fuses", | ||
muse: "muses", | ||
slaughterhouse: "slaughterhouses", | ||
clearinghouse: "clearinghouses", | ||
endonuclease: "endonucleases", | ||
steeplechase: "steeplechases", | ||
metamorphose: "metamorphoses", | ||
"----": "----s", | ||
"commonsense": "commonsenses", | ||
"intersperse": "intersperses", | ||
"merchandise": "merchandises", | ||
"phosphatase": "phosphatases", | ||
"summerhouse": "summerhouses", | ||
"watercourse": "watercourses", | ||
"catchphrase": "catchphrases", | ||
"compromise": "compromises", | ||
"greenhouse": "greenhouses", | ||
"lighthouse": "lighthouses", | ||
"paraphrase": "paraphrases", | ||
"mayonnaise": "mayonnaises", | ||
commonsense: "commonsenses", | ||
intersperse: "intersperses", | ||
merchandise: "merchandises", | ||
phosphatase: "phosphatases", | ||
summerhouse: "summerhouses", | ||
watercourse: "watercourses", | ||
catchphrase: "catchphrases", | ||
compromise: "compromises", | ||
greenhouse: "greenhouses", | ||
lighthouse: "lighthouses", | ||
paraphrase: "paraphrases", | ||
mayonnaise: "mayonnaises", | ||
"----course": "----courses", | ||
"apocalypse": "apocalypses", | ||
"courthouse": "courthouses", | ||
"powerhouse": "powerhouses", | ||
"storehouse": "storehouses", | ||
"glasshouse": "glasshouses", | ||
"hypotenuse": "hypotenuses", | ||
"peroxidase": "peroxidases", | ||
"pillowcase": "pillowcases", | ||
"roundhouse": "roundhouses", | ||
"streetwise": "streetwises", | ||
"expertise": "expertises", | ||
"discourse": "discourses", | ||
"warehouse": "warehouses", | ||
"staircase": "staircases", | ||
"workhouse": "workhouses", | ||
"briefcase": "briefcases", | ||
"clubhouse": "clubhouses", | ||
"clockwise": "clockwises", | ||
"concourse": "concourses", | ||
"playhouse": "playhouses", | ||
"turquoise": "turquoises", | ||
"boathouse": "boathouses", | ||
"cellulose": "celluloses", | ||
"epitomise": "epitomises", | ||
"gatehouse": "gatehouses", | ||
"grandiose": "grandioses", | ||
"menopause": "menopauses", | ||
"penthouse": "penthouses", | ||
apocalypse: "apocalypses", | ||
courthouse: "courthouses", | ||
powerhouse: "powerhouses", | ||
storehouse: "storehouses", | ||
glasshouse: "glasshouses", | ||
hypotenuse: "hypotenuses", | ||
peroxidase: "peroxidases", | ||
pillowcase: "pillowcases", | ||
roundhouse: "roundhouses", | ||
streetwise: "streetwises", | ||
expertise: "expertises", | ||
discourse: "discourses", | ||
warehouse: "warehouses", | ||
staircase: "staircases", | ||
workhouse: "workhouses", | ||
briefcase: "briefcases", | ||
clubhouse: "clubhouses", | ||
clockwise: "clockwises", | ||
concourse: "concourses", | ||
playhouse: "playhouses", | ||
turquoise: "turquoises", | ||
boathouse: "boathouses", | ||
cellulose: "celluloses", | ||
epitomise: "epitomises", | ||
gatehouse: "gatehouses", | ||
grandiose: "grandioses", | ||
menopause: "menopauses", | ||
penthouse: "penthouses", | ||
"----horse": "----horses", | ||
"transpose": "transposes", | ||
"almshouse": "almshouses", | ||
"customise": "customises", | ||
"footloose": "footlooses", | ||
"galvanise": "galvanises", | ||
"princesse": "princesses", | ||
"universe": "universes", | ||
"workhorse": "workhorses", | ||
"response": "responses", | ||
"phrase": "phrases", | ||
transpose: "transposes", | ||
almshouse: "almshouses", | ||
customise: "customises", | ||
footloose: "footlooses", | ||
galvanise: "galvanises", | ||
princesse: "princesses", | ||
universe: "universes", | ||
workhorse: "workhorses", | ||
response: "responses", | ||
phrase: "phrases", | ||
}; | ||
@@ -565,0 +565,0 @@ this.wordsEndingWithSisDictionary = { |
@@ -1,5 +0,4 @@ | ||
import { Dictionary } from "@azure-tools/linq"; | ||
export declare function getMappings(instance: any): any; | ||
export declare function enableSourceTracking<T extends object>(instance: T, enforce?: boolean, path?: string, map?: Dictionary<any>, cache?: Map<string, any>): T; | ||
export declare function enableSourceTracking<T extends object>(instance: T, enforce?: boolean, path?: string, map?: Record<string, any>, cache?: Map<string, any>): T; | ||
export declare function shadow<T extends object>(source: T, document: string, path?: string, cache?: Map<string, any>): T; | ||
//# sourceMappingURL=source-track.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.shadow = exports.enableSourceTracking = exports.getMappings = void 0; | ||
const linq_1 = require("@azure-tools/linq"); | ||
const type_1 = require("./type"); | ||
const sourceMarker = "_#source#_"; | ||
const mapMarker = "_#map#_"; | ||
const getMap = "_#get-map#_"; | ||
const getPosition = "_#get-position#_"; | ||
const getActualValue = "_#get-value#_"; | ||
const noSource = { | ||
$f: "none", | ||
$p: "none", | ||
}; | ||
function getMappings(instance) { | ||
@@ -19,3 +12,3 @@ return instance[getMap]; | ||
exports.getMappings = getMappings; | ||
function enableSourceTracking(instance, enforce = true, path = "$", map = new linq_1.Dictionary(), cache = new Map()) { | ||
function enableSourceTracking(instance, enforce = true, path = "$", map = {}, cache = new Map()) { | ||
let proxy = cache.get(path); | ||
@@ -22,0 +15,0 @@ if (!proxy) { |
import { TextPossibilities } from "./file-generator"; | ||
import { Dictionary } from "@azure-tools/linq"; | ||
export declare const lineCommentPrefix = "//"; | ||
@@ -32,4 +31,4 @@ export declare const docCommentPrefix = "///"; | ||
export declare function dotCombine(prefix: string, content: string): string; | ||
export declare function map<T, U>(dictionary: Dictionary<T>, callbackfn: (key: string, value: T) => U, thisArg?: any): Array<U>; | ||
export declare function ToMap<T>(dictionary: Dictionary<T>): Map<string, T>; | ||
export declare function map<T, U>(dictionary: Record<string, T>, callbackfn: (key: string, value: T) => U, thisArg?: any): Array<U>; | ||
export declare function ToMap<T>(dictionary: Record<string, T>): Map<string, T>; | ||
export declare function __selectMany<T>(multiArray: Array<Array<T>>): Array<T>; | ||
@@ -36,0 +35,0 @@ export declare function pall<T, U>(array: Array<T>, callbackfn: (value: T, index: number, array: Array<T>) => Promise<U>, thisArg?: any): Promise<Array<U>>; |
@@ -9,3 +9,2 @@ "use strict"; | ||
const file_generator_1 = require("./file-generator"); | ||
const linq_1 = require("@azure-tools/linq"); | ||
let indentation = " "; | ||
@@ -31,7 +30,7 @@ exports.lineCommentPrefix = "//"; | ||
/* eslint-disable */ | ||
if (!Array.prototype.hasOwnProperty('last')) { | ||
Object.defineProperty(Array.prototype, 'last', { | ||
if (!Array.prototype.hasOwnProperty("last")) { | ||
Object.defineProperty(Array.prototype, "last", { | ||
get() { | ||
return this[this.length - 1]; | ||
} | ||
}, | ||
}); | ||
@@ -52,6 +51,6 @@ } | ||
String.prototype.slim = function () { | ||
return this.trim().replace(/([^ ]) +/g, '$1 '); | ||
return this.trim().replace(/([^ ]) +/g, "$1 "); | ||
}; | ||
function join(items, separator) { | ||
return items.filter(v => v ? true : false).join(separator); | ||
return items.filter((v) => (v ? true : false)).join(separator); | ||
} | ||
@@ -68,7 +67,7 @@ exports.join = join; | ||
function setIndentation(spaces) { | ||
indentation = ' '.repeat(spaces); | ||
indentation = " ".repeat(spaces); | ||
} | ||
exports.setIndentation = setIndentation; | ||
function trimDots(content) { | ||
return content.replace(/^[.\s]*(.*?)[.\s]*$/g, '$1'); | ||
return content.replace(/^[.\s]*(.*?)[.\s]*$/g, "$1"); | ||
} | ||
@@ -102,8 +101,8 @@ exports.trimDots = trimDots; | ||
const result = new Array(); | ||
let line = ''; | ||
let line = ""; | ||
prefix = indent(prefix, factor); | ||
content = content.trim(); | ||
if (content) { | ||
for (const word of content.replace(/\n+/g, ' » ').split(/\s+/g)) { | ||
if (word === '»') { | ||
for (const word of content.replace(/\n+/g, " » ").split(/\s+/g)) { | ||
if (word === "»") { | ||
result.push(line); | ||
@@ -115,3 +114,3 @@ line = prefix; | ||
result.push(line); | ||
line = ''; | ||
line = ""; | ||
} | ||
@@ -128,3 +127,3 @@ if (!line) { | ||
} | ||
return ''; | ||
return ""; | ||
} | ||
@@ -137,3 +136,3 @@ exports.comment = comment; | ||
function dotCombine(prefix, content) { | ||
return trimDots([trimDots(prefix), trimDots(content)].join('.')); | ||
return trimDots([trimDots(prefix), trimDots(content)].join(".")); | ||
} | ||
@@ -147,3 +146,3 @@ exports.dotCombine = dotCombine; | ||
const result = new Map(); | ||
Object.getOwnPropertyNames(dictionary).map(key => result.set(key, dictionary[key])); | ||
Object.getOwnPropertyNames(dictionary).map((key) => result.set(key, dictionary[key])); | ||
return result; | ||
@@ -154,3 +153,3 @@ } | ||
const result = new Array(); | ||
multiArray.map(v => result.push(...v)); | ||
multiArray.map((v) => result.push(...v)); | ||
return result; | ||
@@ -165,9 +164,10 @@ } | ||
if (Array.isArray(identifier)) { | ||
return [...linq_1.values(identifier).selectMany(deconstruct)]; | ||
return identifier.flatMap(deconstruct); | ||
} | ||
return `${identifier}`. | ||
replace(/([a-z]+)([A-Z])/g, '$1 $2'). | ||
replace(/(\d+)([a-z|A-Z]+)/g, '$1 $2'). | ||
replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3'). | ||
split(/[\W|_]+/).map(each => each.toLowerCase()); | ||
return `${identifier}` | ||
.replace(/([a-z]+)([A-Z])/g, "$1 $2") | ||
.replace(/(\d+)([a-z|A-Z]+)/g, "$1 $2") | ||
.replace(/\b([A-Z]+)([A-Z])([a-z])/, "$1 $2$3") | ||
.split(/[\W|_]+/) | ||
.map((each) => each.toLowerCase()); | ||
} | ||
@@ -179,14 +179,55 @@ exports.deconstruct = deconstruct; | ||
exports.isCapitalized = isCapitalized; | ||
const ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']; | ||
const teens = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']; | ||
const tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']; | ||
const magnitude = ['thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'septillion', 'octillion']; | ||
const ones = [ | ||
"", | ||
"one", | ||
"two", | ||
"three", | ||
"four", | ||
"five", | ||
"six", | ||
"seven", | ||
"eight", | ||
"nine", | ||
"ten", | ||
"eleven", | ||
"twelve", | ||
"thirteen", | ||
"fourteen", | ||
"fifteen", | ||
"sixteen", | ||
"seventeen", | ||
"eighteen", | ||
"nineteen", | ||
]; | ||
const teens = [ | ||
"ten", | ||
"eleven", | ||
"twelve", | ||
"thirteen", | ||
"fourteen", | ||
"fifteen", | ||
"sixteen", | ||
"seventeen", | ||
"eighteen", | ||
"nineteen", | ||
]; | ||
const tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; | ||
const magnitude = [ | ||
"thousand", | ||
"million", | ||
"billion", | ||
"trillion", | ||
"quadrillion", | ||
"quintillion", | ||
"septillion", | ||
"octillion", | ||
]; | ||
const magvalues = [10 ** 3, 10 ** 6, 10 ** 9, 10 ** 12, 10 ** 15, 10 ** 18, 10 ** 21, 10 ** 24, 10 ** 27]; | ||
function* convert(num) { | ||
if (!num) { | ||
yield 'zero'; | ||
yield "zero"; | ||
return; | ||
} | ||
if (num > 1e+30) { | ||
yield 'lots'; | ||
if (num > 1e30) { | ||
yield "lots"; | ||
return; | ||
@@ -206,3 +247,3 @@ } | ||
yield ones[Math.floor(num / 100)]; | ||
yield 'hundred'; | ||
yield "hundred"; | ||
num %= 100; | ||
@@ -228,4 +269,4 @@ } | ||
if (identifier.toLowerCase().startsWith(prohibitedPrefix.toLowerCase())) { | ||
const regex = new RegExp(`(^${prohibitedPrefix})(.*)`, 'i'); | ||
let newIdentifier = identifier.replace(regex, '$2'); | ||
const regex = new RegExp(`(^${prohibitedPrefix})(.*)`, "i"); | ||
let newIdentifier = identifier.replace(regex, "$2"); | ||
if (newIdentifier.length < 2) { | ||
@@ -237,3 +278,7 @@ // if it results in an empty string or a single letter string | ||
newIdentifier = isCapitalized(identifier) ? newIdentifier.capitalize() : newIdentifier.uncapitalize(); | ||
return (skipIdentifiers !== undefined) ? skipIdentifiers.includes(newIdentifier) ? identifier : newIdentifier : newIdentifier; | ||
return skipIdentifiers !== undefined | ||
? skipIdentifiers.includes(newIdentifier) | ||
? identifier | ||
: newIdentifier | ||
: newIdentifier; | ||
} | ||
@@ -246,7 +291,7 @@ return identifier; | ||
// To prevent that, first we need to check if s2 is undefined. | ||
return s2 !== undefined && !!s1 && !s1.localeCompare(s2, undefined, { sensitivity: 'base' }); | ||
return s2 !== undefined && !!s1 && !s1.localeCompare(s2, undefined, { sensitivity: "base" }); | ||
} | ||
exports.isEqual = isEqual; | ||
function removeSequentialDuplicates(identifier) { | ||
const ids = [...identifier].filter(each => !!each); | ||
const ids = [...identifier].filter((each) => !!each); | ||
for (let i = 0; i < ids.length; i++) { | ||
@@ -264,9 +309,13 @@ while (isEqual(ids[i], ids[i - 1])) { | ||
function pascalCase(identifier, removeDuplicates = true) { | ||
return identifier === undefined ? '' : typeof identifier === 'string' ? | ||
pascalCase(fixLeadingNumber(deconstruct(identifier)), removeDuplicates) : | ||
(removeDuplicates ? [...removeSequentialDuplicates(identifier)] : identifier).map(each => each.capitalize()).join(''); | ||
return identifier === undefined | ||
? "" | ||
: typeof identifier === "string" | ||
? pascalCase(fixLeadingNumber(deconstruct(identifier)), removeDuplicates) | ||
: (removeDuplicates ? [...removeSequentialDuplicates(identifier)] : identifier) | ||
.map((each) => each.capitalize()) | ||
.join(""); | ||
} | ||
exports.pascalCase = pascalCase; | ||
function camelCase(identifier) { | ||
if (typeof (identifier) === 'string') { | ||
if (typeof identifier === "string") { | ||
return camelCase(fixLeadingNumber(deconstruct(identifier))); | ||
@@ -276,3 +325,3 @@ } | ||
case 0: | ||
return ''; | ||
return ""; | ||
case 1: | ||
@@ -293,3 +342,3 @@ return identifier[0].uncapitalize(); | ||
} | ||
return ''; | ||
return ""; | ||
} | ||
@@ -299,4 +348,4 @@ exports.escapeString = escapeString; | ||
function nameof(text) { | ||
if (text.indexOf('[') > -1) { | ||
return `$"${text.replace(/\[(.*)\]/, '[{$1}]')}"`; | ||
if (text.indexOf("[") > -1) { | ||
return `$"${text.replace(/\[(.*)\]/, "[{$1}]")}"`; | ||
} | ||
@@ -306,16 +355,16 @@ return `nameof(${text})`; | ||
exports.nameof = nameof; | ||
function* getRegions(source, prefix = '#', postfix = '') { | ||
source = source.replace(/\r?\n|\r/g, '«'); | ||
const rx = new RegExp(`(.*?)«?(\\s*${prefix}\\s*region\\s*(.*?)\\s*${postfix})\\s*«(.*?)«(\\s*${prefix}\\s*endregion\\s*${postfix})\\s*?«`, 'g'); | ||
function* getRegions(source, prefix = "#", postfix = "") { | ||
source = source.replace(/\r?\n|\r/g, "«"); | ||
const rx = new RegExp(`(.*?)«?(\\s*${prefix}\\s*region\\s*(.*?)\\s*${postfix})\\s*«(.*?)«(\\s*${prefix}\\s*endregion\\s*${postfix})\\s*?«`, "g"); | ||
let match; | ||
let finalPosition = 0; | ||
/* eslint-disable */ | ||
while (match = rx.exec(source)) { | ||
while ((match = rx.exec(source))) { | ||
if (match[1]) { | ||
// we have text before this region. | ||
yield { | ||
name: '', | ||
start: '', | ||
content: match[1].replace(/«/g, '\n'), | ||
end: '' | ||
name: "", | ||
start: "", | ||
content: match[1].replace(/«/g, "\n"), | ||
end: "", | ||
}; | ||
@@ -327,4 +376,4 @@ } | ||
start: match[2], | ||
content: match[4].replace(/«/g, '\n'), | ||
end: match[5] | ||
content: match[4].replace(/«/g, "\n"), | ||
end: match[5], | ||
}; | ||
@@ -336,6 +385,6 @@ finalPosition = rx.lastIndex; | ||
yield { | ||
name: '', | ||
start: '', | ||
content: source.substring(finalPosition).replace(/«/g, '\n'), | ||
end: '', | ||
name: "", | ||
start: "", | ||
content: source.substring(finalPosition).replace(/«/g, "\n"), | ||
end: "", | ||
}; | ||
@@ -345,5 +394,8 @@ } | ||
exports.getRegions = getRegions; | ||
function setRegion(source, region, content, prepend = true, prefix = '#', postfix = '') { | ||
function setRegion(source, region, content, prepend = true, prefix = "#", postfix = "") { | ||
const result = new Array(); | ||
const ct = new file_generator_1.Text(content).text.replace(/\r?\n|\r/g, '«').replace(/^«*/, '').replace(/«*$/, ''); | ||
const ct = new file_generator_1.Text(content).text | ||
.replace(/\r?\n|\r/g, "«") | ||
.replace(/^«*/, "") | ||
.replace(/«*$/, ""); | ||
let found = false; | ||
@@ -356,3 +408,3 @@ for (const each of getRegions(source, prefix, postfix)) { | ||
// well, only if it has content, otherwise, we're deleting it. | ||
result.push(each.start, ct, each.end, '«'); | ||
result.push(each.start, ct, each.end, "«"); | ||
found = true; | ||
@@ -362,3 +414,3 @@ } | ||
else { | ||
result.push(each.start, each.content, each.end, '«'); | ||
result.push(each.start, each.content, each.end, "«"); | ||
} | ||
@@ -374,10 +426,19 @@ } | ||
} | ||
return result.join('«').replace(/\r?\n|\r/g, '«').replace(/^«*/, '').replace(/«*$/, '').replace(/«««*/g, '««').replace(/«/g, '\n'); | ||
return result | ||
.join("«") | ||
.replace(/\r?\n|\r/g, "«") | ||
.replace(/^«*/, "") | ||
.replace(/«*$/, "") | ||
.replace(/«««*/g, "««") | ||
.replace(/«/g, "\n"); | ||
} | ||
exports.setRegion = setRegion; | ||
// Note: Where is this used? | ||
function _setRegion(source, region, content, prepend = true, prefix = '#', postfix = '') { | ||
const ct = new file_generator_1.Text(content).text.replace(/\r?\n|\r/g, '«').replace(/^«*/, '').replace(/«*$/, ''); | ||
source = source.replace(/\r?\n|\r/g, '«'); | ||
const rx = new RegExp(`«(\\s*${prefix}\\s*region\\s*${region}\\s*${postfix})\\s*«.*?(«\\s*${prefix}\\s*endregion\\s*${postfix}«?)`, 'g'); | ||
function _setRegion(source, region, content, prepend = true, prefix = "#", postfix = "") { | ||
const ct = new file_generator_1.Text(content).text | ||
.replace(/\r?\n|\r/g, "«") | ||
.replace(/^«*/, "") | ||
.replace(/«*$/, ""); | ||
source = source.replace(/\r?\n|\r/g, "«"); | ||
const rx = new RegExp(`«(\\s*${prefix}\\s*region\\s*${region}\\s*${postfix})\\s*«.*?(«\\s*${prefix}\\s*endregion\\s*${postfix}«?)`, "g"); | ||
if (rx.test(source)) { | ||
@@ -388,3 +449,3 @@ if (ct.length > 0) { | ||
else { | ||
source = source.replace(rx, ''); | ||
source = source.replace(rx, ""); | ||
} | ||
@@ -398,3 +459,3 @@ } | ||
} | ||
source = source.replace(/«««*/g, '««').replace(/«/g, '\n'); | ||
source = source.replace(/«««*/g, "««").replace(/«/g, "\n"); | ||
return source; | ||
@@ -412,3 +473,3 @@ } | ||
} | ||
// hmm, none of the names were suitable. | ||
// hmm, none of the names were suitable. | ||
// use the first one, and tack on a number until we have a free value | ||
@@ -415,0 +476,0 @@ let i = 1; |
@@ -1,7 +0,6 @@ | ||
import { Dictionary } from "@azure-tools/linq"; | ||
export declare function fail(text: string): never; | ||
export declare function applyOverrides(content: string, overrides: Dictionary<string>): string; | ||
export declare function copyResources(sourceFolder: string, fileWriter: (filename: string, content: string) => Promise<void>, overrides?: Dictionary<string>, contentManipulator?: (content: string) => Promise<string>): Promise<void>; | ||
export declare function applyOverrides(content: string, overrides: Record<string, string>): string; | ||
export declare function copyResources(sourceFolder: string, fileWriter: (filename: string, content: string) => Promise<void>, overrides?: Record<string, string>, contentManipulator?: (content: string) => Promise<string>): Promise<void>; | ||
export declare function copyBinaryResources(sourceFolder: string, fileWriter: (filename: string, content: string) => Promise<void>): Promise<void>; | ||
export declare function guid(): string; | ||
//# sourceMappingURL=utility.d.ts.map |
@@ -27,3 +27,2 @@ "use strict"; | ||
exports.guid = exports.copyBinaryResources = exports.copyResources = exports.applyOverrides = exports.fail = void 0; | ||
const linq_1 = require("@azure-tools/linq"); | ||
const aio = __importStar(require("@azure-tools/async-io")); | ||
@@ -40,3 +39,3 @@ const path_1 = require("path"); | ||
/* eslint-disable */ | ||
} while (obj = Object.getPrototypeOf(obj)); | ||
} while ((obj = Object.getPrototypeOf(obj))); | ||
return props; | ||
@@ -49,4 +48,4 @@ } | ||
function applyOverrides(content, overrides) { | ||
for (const { key: from, value: to } of linq_1.items(overrides)) { | ||
content = content.replace(new RegExp(from, 'g'), to); | ||
for (const [from, to] of Object.entries(overrides)) { | ||
content = content.replace(new RegExp(from, "g"), to); | ||
} | ||
@@ -56,7 +55,9 @@ return content; | ||
exports.applyOverrides = applyOverrides; | ||
async function copyResources(sourceFolder, fileWriter, overrides = {}, contentManipulator = async (i) => { return i; }) { | ||
async function copyResources(sourceFolder, fileWriter, overrides = {}, contentManipulator = async (i) => { | ||
return i; | ||
}) { | ||
const done = new Array(); | ||
try { | ||
const files = await aio.readdir(sourceFolder); | ||
for (const file of linq_1.values(files)) { | ||
for (const file of files) { | ||
const fullPath = path_1.join(sourceFolder, file); | ||
@@ -68,3 +69,6 @@ if (await aio.isDirectory(fullPath)) { | ||
if (await aio.isFile(fullPath)) { | ||
done.push(aio.readFile(fullPath).then(contentManipulator).then(async (content) => fileWriter(file, applyOverrides(content, overrides)))); | ||
done.push(aio | ||
.readFile(fullPath) | ||
.then(contentManipulator) | ||
.then(async (content) => fileWriter(file, applyOverrides(content, overrides)))); | ||
} | ||
@@ -83,3 +87,3 @@ } | ||
const files = await aio.readdir(sourceFolder); | ||
for (const file of linq_1.values(files)) { | ||
for (const file of files) { | ||
const fullPath = path_1.join(sourceFolder, file); | ||
@@ -105,5 +109,16 @@ if (await aio.isDirectory(fullPath)) { | ||
function guid() { | ||
return (quartet() + quartet() + '-' + quartet() + '-4' + quartet().substr(0, 3) + '-' + quartet() + '-' + quartet() + quartet() + quartet()).toLowerCase(); | ||
return (quartet() + | ||
quartet() + | ||
"-" + | ||
quartet() + | ||
"-4" + | ||
quartet().substr(0, 3) + | ||
"-" + | ||
quartet() + | ||
"-" + | ||
quartet() + | ||
quartet() + | ||
quartet()).toLowerCase(); | ||
} | ||
exports.guid = guid; | ||
//# sourceMappingURL=utility.js.map |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.6.0", | ||
"version": "2.7.0-dev.1", | ||
"description": "Autorest Code generator common and base classes", | ||
@@ -58,6 +58,5 @@ "directories": { | ||
"@azure-tools/async-io": "~3.0.0", | ||
"@azure-tools/linq": "~3.1.0", | ||
"js-yaml": "~4.0.0", | ||
"semver": "^5.5.1" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
3699
279198
2
- Removed@azure-tools/linq@~3.1.0
- Removed@azure-tools/linq@3.1.263(transitive)