@vaadin/hilla-generator-core 24.6.5 → 24.7.0-alpha11
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/Generator.d.ts +0 -1
- package/Generator.d.ts.map +1 -1
- package/Generator.js +2 -2
- package/Generator.js.map +2 -2
- package/Plugin.d.ts +2 -2
- package/Plugin.d.ts.map +1 -1
- package/Plugin.js.map +1 -1
- package/PluginManager.d.ts +1 -1
- package/PluginManager.d.ts.map +1 -1
- package/PluginManager.js +2 -0
- package/PluginManager.js.map +2 -2
- package/ReferenceResolver.d.ts +1 -2
- package/ReferenceResolver.d.ts.map +1 -1
- package/ReferenceResolver.js +0 -1
- package/ReferenceResolver.js.map +2 -2
- package/Schema.d.ts +9 -7
- package/Schema.d.ts.map +1 -1
- package/Schema.js +15 -4
- package/Schema.js.map +2 -2
- package/SharedStorage.d.ts +10 -8
- package/package.json +9 -27
- package/File.d.ts +0 -11
- package/File.d.ts.map +0 -1
- package/File.js +0 -15
- package/File.js.map +0 -7
- package/utils.d.ts +0 -6
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -12
- package/utils.js.map +0 -7
package/Generator.d.ts
CHANGED
package/Generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Generator.d.ts","sourceRoot":"","sources":["src/Generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"Generator.d.ts","sourceRoot":"","sources":["src/Generator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;AAGhF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKrD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,SAAS;;gBAMhB,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,OAAO,EAAE,gBAAgB;IAOtE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;CAqBvD"}
|
package/Generator.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import File from "./File.js";
|
|
4
3
|
import PluginManager from "./PluginManager.js";
|
|
5
4
|
import ReferenceResolver from "./ReferenceResolver.js";
|
|
6
5
|
class Generator {
|
|
@@ -22,7 +21,8 @@ class Generator {
|
|
|
22
21
|
apiRefs: this.#parser.$refs,
|
|
23
22
|
outputDir: this.#outputDir,
|
|
24
23
|
pluginStorage: /* @__PURE__ */ new Map(),
|
|
25
|
-
sources: []
|
|
24
|
+
sources: [],
|
|
25
|
+
transferTypes: /* @__PURE__ */ new Map()
|
|
26
26
|
};
|
|
27
27
|
this.#logger.global.debug("Executing plugins");
|
|
28
28
|
await this.#manager.execute(storage);
|
package/Generator.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/Generator.ts"],
|
|
4
|
-
"sourcesContent": ["import SwaggerParser from '@apidevtools/swagger-parser';\nimport type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport
|
|
5
|
-
"mappings": "AAAA,OAAO,mBAAmB;
|
|
4
|
+
"sourcesContent": ["import SwaggerParser from '@apidevtools/swagger-parser';\nimport type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport ts from 'typescript';\nimport type { PluginConstructor } from './Plugin.js';\nimport PluginManager from './PluginManager.js';\nimport ReferenceResolver from './ReferenceResolver.js';\nimport type { SharedStorage } from './SharedStorage.js';\n\nexport type GeneratorContext = Readonly<{\n logger: LoggerFactory;\n outputDir?: string;\n}>;\n\nexport default class Generator {\n readonly #logger: LoggerFactory;\n readonly #manager: PluginManager;\n readonly #parser: SwaggerParser;\n readonly #outputDir: string | undefined;\n\n constructor(plugins: readonly PluginConstructor[], context: GeneratorContext) {\n this.#parser = new SwaggerParser();\n this.#manager = new PluginManager(plugins, new ReferenceResolver(this.#parser), context.logger);\n this.#logger = context.logger;\n this.#outputDir = context.outputDir;\n }\n\n async process(input: string): Promise<readonly File[]> {\n this.#logger.global.debug('Processing OpenAPI');\n const api = (await this.#parser.bundle(JSON.parse(input))) as OpenAPIV3.Document;\n\n const storage: SharedStorage = {\n api,\n apiRefs: this.#parser.$refs,\n outputDir: this.#outputDir,\n pluginStorage: new Map(),\n sources: [],\n transferTypes: new Map(),\n };\n\n this.#logger.global.debug('Executing plugins');\n await this.#manager.execute(storage);\n\n this.#logger.global.debug('Printing files');\n const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });\n\n return storage.sources.map((file) => new File([printer.printFile(file)], file.fileName));\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,mBAAmB;AAG1B,OAAO,QAAQ;AAEf,OAAO,mBAAmB;AAC1B,OAAO,uBAAuB;AAQ9B,MAAO,UAAwB;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAAuC,SAA2B;AAC5E,SAAK,UAAU,IAAI,cAAc;AACjC,SAAK,WAAW,IAAI,cAAc,SAAS,IAAI,kBAAkB,KAAK,OAAO,GAAG,QAAQ,MAAM;AAC9F,SAAK,UAAU,QAAQ;AACvB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AAAA,EAEA,MAAM,QAAQ,OAAyC;AACrD,SAAK,QAAQ,OAAO,MAAM,oBAAoB;AAC9C,UAAM,MAAO,MAAM,KAAK,QAAQ,OAAO,KAAK,MAAM,KAAK,CAAC;AAExD,UAAM,UAAyB;AAAA,MAC7B;AAAA,MACA,SAAS,KAAK,QAAQ;AAAA,MACtB,WAAW,KAAK;AAAA,MAChB,eAAe,oBAAI,IAAI;AAAA,MACvB,SAAS,CAAC;AAAA,MACV,eAAe,oBAAI,IAAI;AAAA,IACzB;AAEA,SAAK,QAAQ,OAAO,MAAM,mBAAmB;AAC7C,UAAM,KAAK,SAAS,QAAQ,OAAO;AAEnC,SAAK,QAAQ,OAAO,MAAM,gBAAgB;AAC1C,UAAM,UAAU,GAAG,cAAc,EAAE,SAAS,GAAG,YAAY,SAAS,CAAC;AAErE,WAAO,QAAQ,QAAQ,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,UAAU,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC;AAAA,EACzF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Plugin.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';
|
|
|
2
2
|
import type { Logger } from '@vaadin/hilla-generator-utils/LoggerFactory.js';
|
|
3
3
|
import type { Constructor } from 'type-fest';
|
|
4
4
|
import type ReferenceResolver from './ReferenceResolver.js';
|
|
5
|
-
import type SharedStorage from './SharedStorage.js';
|
|
5
|
+
import type { SharedStorage } from './SharedStorage.js';
|
|
6
6
|
export default abstract class Plugin {
|
|
7
7
|
readonly resolver: ReferenceResolver;
|
|
8
8
|
readonly logger: Logger;
|
|
9
9
|
constructor(resolver: ReferenceResolver, logger: LoggerFactory);
|
|
10
10
|
get name(): string;
|
|
11
11
|
abstract get path(): string;
|
|
12
|
-
abstract execute(storage: SharedStorage): Promise<void
|
|
12
|
+
abstract execute(storage: SharedStorage): Promise<void> | void;
|
|
13
13
|
}
|
|
14
14
|
export type PluginConstructor = Constructor<Plugin, ConstructorParameters<typeof Plugin>>;
|
|
15
15
|
//# sourceMappingURL=Plugin.d.ts.map
|
package/Plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["src/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;AAChF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gDAAgD,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["src/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;AAChF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gDAAgD,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,MAAM;IAClC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa;IAK9D,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAC;IAE5B,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CAC/D;AAED,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,EAAE,qBAAqB,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC"}
|
package/Plugin.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/Plugin.ts"],
|
|
4
|
-
"sourcesContent": ["import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type { Logger } from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type { Constructor } from 'type-fest';\nimport type ReferenceResolver from './ReferenceResolver.js';\nimport type SharedStorage from './SharedStorage.js';\n\nexport default abstract class Plugin {\n readonly resolver: ReferenceResolver;\n readonly logger: Logger;\n\n constructor(resolver: ReferenceResolver, logger: LoggerFactory) {\n this.logger = logger.for(this.constructor.name);\n this.resolver = resolver;\n }\n\n get name(): string {\n return this.constructor.name;\n }\n\n abstract get path(): string;\n\n abstract execute(storage: SharedStorage): Promise<void
|
|
4
|
+
"sourcesContent": ["import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type { Logger } from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type { Constructor } from 'type-fest';\nimport type ReferenceResolver from './ReferenceResolver.js';\nimport type { SharedStorage } from './SharedStorage.js';\n\nexport default abstract class Plugin {\n readonly resolver: ReferenceResolver;\n readonly logger: Logger;\n\n constructor(resolver: ReferenceResolver, logger: LoggerFactory) {\n this.logger = logger.for(this.constructor.name);\n this.resolver = resolver;\n }\n\n get name(): string {\n return this.constructor.name;\n }\n\n abstract get path(): string;\n\n abstract execute(storage: SharedStorage): Promise<void> | void;\n}\n\nexport type PluginConstructor = Constructor<Plugin, ConstructorParameters<typeof Plugin>>;\n"],
|
|
5
5
|
"mappings": "AAMA,MAAO,OAA8B;AAAA,EAC1B;AAAA,EACA;AAAA,EAET,YAAY,UAA6B,QAAuB;AAC9D,SAAK,SAAS,OAAO,IAAI,KAAK,YAAY,IAAI;AAC9C,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAKF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/PluginManager.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';
|
|
2
2
|
import type { PluginConstructor } from './Plugin.js';
|
|
3
3
|
import type ReferenceResolver from './ReferenceResolver.js';
|
|
4
|
-
import type SharedStorage from './SharedStorage.js';
|
|
4
|
+
import type { SharedStorage } from './SharedStorage.js';
|
|
5
5
|
export default class PluginManager {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(plugins: readonly PluginConstructor[], resolver: ReferenceResolver, logger: LoggerFactory);
|
package/PluginManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["src/PluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;AAEhF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["src/PluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,gDAAgD,CAAC;AAEhF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,aAAa;;gBAGpB,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa;IAkB/F,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CASrD"}
|
package/PluginManager.js
CHANGED
package/PluginManager.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/PluginManager.ts"],
|
|
4
|
-
"sourcesContent": ["import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type Plugin from './Plugin.js';\nimport type { PluginConstructor } from './Plugin.js';\nimport type ReferenceResolver from './ReferenceResolver.js';\nimport type SharedStorage from './SharedStorage.js';\n\nexport default class PluginManager {\n readonly #plugins: Plugin[];\n\n constructor(plugins: readonly PluginConstructor[], resolver: ReferenceResolver, logger: LoggerFactory) {\n const standardPlugins = [\n 'BackbonePlugin',\n 'ClientPlugin',\n 'BarrelPlugin',\n 'ModelPlugin',\n 'PushPlugin',\n 'SubTypesPlugin',\n 'SignalsPlugin',\n ];\n const customPlugins = plugins.filter((p) => !standardPlugins.includes(p.name));\n if (customPlugins.length > 0) {\n logger.global.info(`Plugins: ${plugins.map(({ name }) => name).join(', ')}`);\n }\n this.#plugins = plugins.map((PluginClass) => new PluginClass(resolver, logger));\n }\n\n async execute(storage: SharedStorage): Promise<void> {\n // We need to run plugins sequentially\n for (const plugin of this.#plugins) {\n const { name, path } = plugin;\n plugin.logger.debug({ plugin: { name, path } }, `Executing plugin '${plugin.name}'`);\n // eslint-disable-next-line no-await-in-loop\n await plugin.execute(storage);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAMA,MAAO,cAA4B;AAAA,EACxB;AAAA,EAET,YAAY,SAAuC,UAA6B,QAAuB;AACrG,UAAM,kBAAkB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,UAAM,gBAAgB,QAAQ,OAAO,CAAC,MAAM,CAAC,gBAAgB,SAAS,EAAE,IAAI,CAAC;AAC7E,QAAI,cAAc,SAAS,GAAG;AAC5B,aAAO,OAAO,KAAK,YAAY,QAAQ,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,IAAI,CAAC,EAAE;AAAA,IAC7E;AACA,SAAK,WAAW,QAAQ,IAAI,CAAC,gBAAgB,IAAI,YAAY,UAAU,MAAM,CAAC;AAAA,EAChF;AAAA,EAEA,MAAM,QAAQ,SAAuC;AAEnD,eAAW,UAAU,KAAK,UAAU;AAClC,YAAM,EAAE,MAAM,KAAK,IAAI;AACvB,aAAO,OAAO,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,EAAE,GAAG,qBAAqB,OAAO,IAAI,GAAG;AAEnF,YAAM,OAAO,QAAQ,OAAO;AAAA,IAC9B;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import type LoggerFactory from '@vaadin/hilla-generator-utils/LoggerFactory.js';\nimport type Plugin from './Plugin.js';\nimport type { PluginConstructor } from './Plugin.js';\nimport type ReferenceResolver from './ReferenceResolver.js';\nimport type { SharedStorage } from './SharedStorage.js';\n\nexport default class PluginManager {\n readonly #plugins: Plugin[];\n\n constructor(plugins: readonly PluginConstructor[], resolver: ReferenceResolver, logger: LoggerFactory) {\n const standardPlugins = [\n 'TransferTypesPlugin', // should go before Backbone Plugin\n 'BackbonePlugin',\n 'ClientPlugin',\n 'BarrelPlugin',\n 'ModelPlugin',\n 'PushPlugin',\n 'SubTypesPlugin',\n 'SignalsPlugin',\n ];\n const customPlugins = plugins.filter((p) => !standardPlugins.includes(p.name));\n if (customPlugins.length > 0) {\n logger.global.info(`Plugins: ${plugins.map(({ name }) => name).join(', ')}`);\n }\n this.#plugins = plugins.map((PluginClass) => new PluginClass(resolver, logger));\n }\n\n async execute(storage: SharedStorage): Promise<void> {\n // We need to run plugins sequentially\n for (const plugin of this.#plugins) {\n const { name, path } = plugin;\n plugin.logger.debug({ plugin: { name, path } }, `Executing plugin '${plugin.name}'`);\n // eslint-disable-next-line no-await-in-loop\n await plugin.execute(storage);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,MAAO,cAA4B;AAAA,EACxB;AAAA,EAET,YAAY,SAAuC,UAA6B,QAAuB;AACrG,UAAM,kBAAkB;AAAA,MACtB;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,UAAM,gBAAgB,QAAQ,OAAO,CAAC,MAAM,CAAC,gBAAgB,SAAS,EAAE,IAAI,CAAC;AAC7E,QAAI,cAAc,SAAS,GAAG;AAC5B,aAAO,OAAO,KAAK,YAAY,QAAQ,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,IAAI,CAAC,EAAE;AAAA,IAC7E;AACA,SAAK,WAAW,QAAQ,IAAI,CAAC,gBAAgB,IAAI,YAAY,UAAU,MAAM,CAAC;AAAA,EAChF;AAAA,EAEA,MAAM,QAAQ,SAAuC;AAEnD,eAAW,UAAU,KAAK,UAAU;AAClC,YAAM,EAAE,MAAM,KAAK,IAAI;AACvB,aAAO,OAAO,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,EAAE,GAAG,qBAAqB,OAAO,IAAI,GAAG;AAEnF,YAAM,OAAO,QAAQ,OAAO;AAAA,IAC9B;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/ReferenceResolver.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type SwaggerParser from '@apidevtools/swagger-parser';
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
|
-
import type { ReadonlyDeep } from 'type-fest';
|
|
4
3
|
export default class ReferenceResolver {
|
|
5
4
|
#private;
|
|
6
5
|
constructor(parser: SwaggerParser);
|
|
7
|
-
resolve<T extends
|
|
6
|
+
resolve<T extends object>(obj: OpenAPIV3.ReferenceObject | T): T;
|
|
8
7
|
}
|
|
9
8
|
//# sourceMappingURL=ReferenceResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferenceResolver.d.ts","sourceRoot":"","sources":["src/ReferenceResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ReferenceResolver.d.ts","sourceRoot":"","sources":["src/ReferenceResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,iBAAiB;;gBAGxB,MAAM,EAAE,aAAa;IAIjC,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,eAAe,GAAG,CAAC,GAAG,CAAC;CAGjE"}
|
package/ReferenceResolver.js
CHANGED
package/ReferenceResolver.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/ReferenceResolver.ts"],
|
|
4
|
-
"sourcesContent": ["import type SwaggerParser from '@apidevtools/swagger-parser';\nimport type { OpenAPIV3 } from 'openapi-types';\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type SwaggerParser from '@apidevtools/swagger-parser';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nexport default class ReferenceResolver {\n readonly #parser: SwaggerParser;\n\n constructor(parser: SwaggerParser) {\n this.#parser = parser;\n }\n\n resolve<T extends object>(obj: OpenAPIV3.ReferenceObject | T): T {\n return '$ref' in obj ? this.#parser.$refs.get(obj.$ref) : obj;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAGA,MAAO,kBAAgC;AAAA,EAC5B;AAAA,EAET,YAAY,QAAuB;AACjC,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAA0B,KAAuC;AAC/D,WAAO,UAAU,MAAM,KAAK,QAAQ,MAAM,IAAI,IAAI,IAAI,IAAI;AAAA,EAC5D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Schema.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export type NonArraySchema = ReadonlyDeep<OpenAPIV3.NonArraySchemaObject>;
|
|
2
|
+
export type Nullified<T, K extends keyof T> = T & Record<K, undefined>;
|
|
3
|
+
export type ReferenceSchema = OpenAPIV3.ReferenceObject;
|
|
4
|
+
export type ArraySchema = OpenAPIV3.ArraySchemaObject;
|
|
5
|
+
export type NonArraySchema = OpenAPIV3.NonArraySchemaObject;
|
|
7
6
|
export type RegularSchema = ArraySchema | NonArraySchema;
|
|
8
7
|
export type NullableSchema = Readonly<Required<Pick<RegularSchema, 'nullable'>>> & RegularSchema;
|
|
9
8
|
export type AnyOfRuleComposedSchema = Readonly<Required<Pick<RegularSchema, 'anyOf'>>> & RegularSchema;
|
|
@@ -52,7 +51,10 @@ export declare function isStringSchema(schema: Schema): schema is StringSchema;
|
|
|
52
51
|
export declare function isEnumSchema(schema: Schema): schema is EnumSchema;
|
|
53
52
|
export declare function isEmptyObject(schema: Schema): schema is EmptyObjectSchema;
|
|
54
53
|
export declare function isMapSchema(schema: Schema): schema is MapSchema;
|
|
54
|
+
export declare function simplifyFullyQualifiedName(name: string): string;
|
|
55
55
|
export declare function convertReferenceSchemaToSpecifier({ $ref }: ReferenceSchema): string;
|
|
56
|
-
export declare function
|
|
57
|
-
export declare function
|
|
56
|
+
export declare function convertReferenceSchemaToFullyQualifiedName({ $ref }: ReferenceSchema): string;
|
|
57
|
+
export declare function convertFullyQualifiedNameToRelativePath(name: string): string;
|
|
58
|
+
export declare function convertReferenceSchemaToPath(schema: ReferenceSchema): string;
|
|
59
|
+
export declare function resolveReference(schemas: OpenAPIV3.ComponentsObject['schemas'], { $ref }: ReferenceSchema): Schema | undefined;
|
|
58
60
|
//# sourceMappingURL=Schema.d.ts.map
|
package/Schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|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AAM,EAAE,MAAM,GAAG,MAAM,IAAI,YAAY,CAErE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,YAAY,CAErE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,UAAU,CAEjE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,iBAAiB,CAEzE;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,SAAS,CAE/D;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,iCAAiC,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,MAAM,CAEnF;AAID,wBAAgB,0CAA0C,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,MAAM,CAE5F;AAED,wBAAgB,uCAAuC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAE5E;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAC9C,EAAE,IAAI,EAAE,EAAE,eAAe,GACxB,MAAM,GAAG,SAAS,CAUpB"}
|
package/Schema.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { convertFullyQualifiedNameToRelativePath, simplifyFullyQualifiedName } from "./utils.js";
|
|
2
1
|
function isReferenceSchema(schema) {
|
|
3
2
|
return "$ref" in schema;
|
|
4
3
|
}
|
|
@@ -65,12 +64,21 @@ function isEmptyObject(schema) {
|
|
|
65
64
|
function isMapSchema(schema) {
|
|
66
65
|
return isEmptyObject(schema) && !!schema.additionalProperties;
|
|
67
66
|
}
|
|
67
|
+
function simplifyFullyQualifiedName(name) {
|
|
68
|
+
return name.substring(name.lastIndexOf(name.includes("$") ? "$" : ".") + 1, name.length);
|
|
69
|
+
}
|
|
68
70
|
function convertReferenceSchemaToSpecifier({ $ref }) {
|
|
69
71
|
return simplifyFullyQualifiedName($ref);
|
|
70
72
|
}
|
|
71
73
|
const COMPONENTS_SCHEMAS_REF_LENGTH = "#/components/schemas/".length;
|
|
72
|
-
function
|
|
73
|
-
return
|
|
74
|
+
function convertReferenceSchemaToFullyQualifiedName({ $ref }) {
|
|
75
|
+
return $ref.substring(COMPONENTS_SCHEMAS_REF_LENGTH);
|
|
76
|
+
}
|
|
77
|
+
function convertFullyQualifiedNameToRelativePath(name) {
|
|
78
|
+
return name.replace(/[$.]/gu, "/");
|
|
79
|
+
}
|
|
80
|
+
function convertReferenceSchemaToPath(schema) {
|
|
81
|
+
return convertFullyQualifiedNameToRelativePath(convertReferenceSchemaToFullyQualifiedName(schema));
|
|
74
82
|
}
|
|
75
83
|
function resolveReference(schemas, { $ref }) {
|
|
76
84
|
if (schemas) {
|
|
@@ -83,6 +91,8 @@ function resolveReference(schemas, { $ref }) {
|
|
|
83
91
|
return void 0;
|
|
84
92
|
}
|
|
85
93
|
export {
|
|
94
|
+
convertFullyQualifiedNameToRelativePath,
|
|
95
|
+
convertReferenceSchemaToFullyQualifiedName,
|
|
86
96
|
convertReferenceSchemaToPath,
|
|
87
97
|
convertReferenceSchemaToSpecifier,
|
|
88
98
|
decomposeSchema,
|
|
@@ -104,6 +114,7 @@ export {
|
|
|
104
114
|
isOneOfRuleComposedSchema,
|
|
105
115
|
isReferenceSchema,
|
|
106
116
|
isStringSchema,
|
|
107
|
-
resolveReference
|
|
117
|
+
resolveReference,
|
|
118
|
+
simplifyFullyQualifiedName
|
|
108
119
|
};
|
|
109
120
|
//# sourceMappingURL=Schema.js.map
|
package/Schema.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/Schema.ts"],
|
|
4
|
-
"sourcesContent": ["import type { OpenAPIV3 } from 'openapi-types';\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { OpenAPIV3 } from 'openapi-types';\n\nexport type Nullified<T, K extends keyof T> = T & Record<K, undefined>;\n\nexport type ReferenceSchema = OpenAPIV3.ReferenceObject;\nexport type ArraySchema = OpenAPIV3.ArraySchemaObject;\nexport type NonArraySchema = OpenAPIV3.NonArraySchemaObject;\nexport type RegularSchema = ArraySchema | NonArraySchema;\n\nexport type NullableSchema = Readonly<Required<Pick<RegularSchema, 'nullable'>>> & RegularSchema;\n\nexport type AnyOfRuleComposedSchema = Readonly<Required<Pick<RegularSchema, 'anyOf'>>> & RegularSchema;\nexport type AllOfRuleComposedSchema = Readonly<Required<Pick<RegularSchema, 'allOf'>>> & RegularSchema;\nexport type OneOfRuleComposedSchema = Readonly<Required<Pick<RegularSchema, 'oneOf'>>> & RegularSchema;\nexport type NotRuleComposedSchema = Readonly<Required<Pick<RegularSchema, 'not'>>> & RegularSchema;\nexport type ComposedSchema =\n | AllOfRuleComposedSchema\n | AnyOfRuleComposedSchema\n | NotRuleComposedSchema\n | OneOfRuleComposedSchema;\n\nexport type NonComposedRegularSchema = Readonly<Nullified<RegularSchema, 'allOf' | 'anyOf' | 'oneOf'>> & RegularSchema;\nexport type NonComposedSchema = NonComposedRegularSchema | ReferenceSchema;\n\nexport type BooleanSchema = NonComposedRegularSchema & Readonly<{ type: 'boolean' }>;\nexport type IntegerSchema = NonComposedRegularSchema & Readonly<{ type: 'integer' }>;\nexport type NumberSchema = NonComposedRegularSchema & Readonly<{ type: 'number' }>;\nexport type ObjectSchema = NonComposedRegularSchema & Readonly<{ type: 'object' }>;\nexport type StringSchema = NonComposedRegularSchema & Readonly<{ type: 'string' }>;\n\nexport type EnumSchema = Readonly<Required<Pick<StringSchema, 'enum'>>> & StringSchema;\nexport type EmptyObjectSchema = ObjectSchema & Readonly<Nullified<ObjectSchema, 'properties'>>;\nexport type NonEmptyObjectSchema = ObjectSchema & Readonly<Required<Pick<ObjectSchema, 'properties'>>>;\nexport type MapSchema = EmptyObjectSchema & Readonly<Required<Pick<ObjectSchema, 'additionalProperties'>>>;\n\nexport type Schema = ReferenceSchema | RegularSchema;\n\nexport function isReferenceSchema(schema: Schema): schema is ReferenceSchema {\n return '$ref' in schema;\n}\n\nexport function isAnyOfRuleComposedSchema(schema: Schema): schema is AnyOfRuleComposedSchema {\n return 'anyOf' in schema;\n}\n\nexport function isAllOfRuleComposedSchema(schema: Schema): schema is AllOfRuleComposedSchema {\n return 'allOf' in schema;\n}\n\nexport function isOneOfRuleComposedSchema(schema: Schema): schema is OneOfRuleComposedSchema {\n return 'oneOf' in schema;\n}\n\nexport function isNotRuleComposedSchema(schema: Schema): schema is NotRuleComposedSchema {\n return 'not' in schema;\n}\n\nexport function isComposedSchema(schema: Schema): schema is ComposedSchema {\n return (\n isAnyOfRuleComposedSchema(schema) ||\n isAllOfRuleComposedSchema(schema) ||\n isOneOfRuleComposedSchema(schema) ||\n isNotRuleComposedSchema(schema)\n );\n}\n\nexport function isNonComposedSchema(schema: Schema): schema is NonComposedSchema {\n return !isComposedSchema(schema);\n}\n\nexport function isNonComposedRegularSchema(schema: Schema): schema is NonComposedRegularSchema {\n return isNonComposedSchema(schema) && !isReferenceSchema(schema);\n}\n\nexport function isNullableSchema(schema: Schema): schema is NullableSchema {\n return !isReferenceSchema(schema) && !!schema.nullable;\n}\n\nexport function decomposeSchema(schema: ComposedSchema): readonly Schema[] {\n if (isAnyOfRuleComposedSchema(schema)) {\n return schema.anyOf;\n }\n\n if (isAllOfRuleComposedSchema(schema)) {\n return schema.allOf;\n }\n\n if (isOneOfRuleComposedSchema(schema)) {\n return schema.oneOf;\n }\n\n return [schema.not];\n}\n\nexport function isArraySchema(schema: Schema): schema is ArraySchema {\n return isNonComposedRegularSchema(schema) && schema.type === 'array';\n}\n\nexport function isBooleanSchema(schema: Schema): schema is BooleanSchema {\n return isNonComposedRegularSchema(schema) && schema.type === 'boolean';\n}\n\nexport function isIntegerSchema(schema: Schema): schema is IntegerSchema {\n return isNonComposedRegularSchema(schema) && schema.type === 'integer';\n}\n\nexport function isNumberSchema(schema: Schema): schema is NumberSchema {\n return isNonComposedRegularSchema(schema) && schema.type === 'number';\n}\n\nexport function isObjectSchema(schema: Schema): schema is ObjectSchema {\n return isNonComposedRegularSchema(schema) && schema.type === 'object';\n}\n\nexport function isStringSchema(schema: Schema): schema is StringSchema {\n return isNonComposedRegularSchema(schema) && schema.type === 'string';\n}\n\nexport function isEnumSchema(schema: Schema): schema is EnumSchema {\n return isStringSchema(schema) && !!schema.enum;\n}\n\nexport function isEmptyObject(schema: Schema): schema is EmptyObjectSchema {\n return isObjectSchema(schema) && !schema.properties;\n}\n\nexport function isMapSchema(schema: Schema): schema is MapSchema {\n return isEmptyObject(schema) && !!schema.additionalProperties;\n}\n\nexport function simplifyFullyQualifiedName(name: string): string {\n return name.substring(name.lastIndexOf(name.includes('$') ? '$' : '.') + 1, name.length);\n}\n\nexport function convertReferenceSchemaToSpecifier({ $ref }: ReferenceSchema): string {\n return simplifyFullyQualifiedName($ref);\n}\n\nconst COMPONENTS_SCHEMAS_REF_LENGTH = '#/components/schemas/'.length;\n\nexport function convertReferenceSchemaToFullyQualifiedName({ $ref }: ReferenceSchema): string {\n return $ref.substring(COMPONENTS_SCHEMAS_REF_LENGTH);\n}\n\nexport function convertFullyQualifiedNameToRelativePath(name: string): string {\n return name.replace(/[$.]/gu, '/');\n}\n\nexport function convertReferenceSchemaToPath(schema: ReferenceSchema): string {\n return convertFullyQualifiedNameToRelativePath(convertReferenceSchemaToFullyQualifiedName(schema));\n}\n\nexport function resolveReference(\n schemas: OpenAPIV3.ComponentsObject['schemas'],\n { $ref }: ReferenceSchema,\n): Schema | undefined {\n if (schemas) {\n for (const [name, schema] of Object.entries(schemas)) {\n if ($ref.includes(name)) {\n return schema;\n }\n }\n }\n\n return undefined;\n}\n"],
|
|
5
|
+
"mappings": "AAqCO,SAAS,kBAAkB,QAA2C;AAC3E,SAAO,UAAU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AAS,eAAe,QAAwC;AACrE,SAAO,2BAA2B,MAAM,KAAK,OAAO,SAAS;AAC/D;AAEO,SAAS,aAAa,QAAsC;AACjE,SAAO,eAAe,MAAM,KAAK,CAAC,CAAC,OAAO;AAC5C;AAEO,SAAS,cAAc,QAA6C;AACzE,SAAO,eAAe,MAAM,KAAK,CAAC,OAAO;AAC3C;AAEO,SAAS,YAAY,QAAqC;AAC/D,SAAO,cAAc,MAAM,KAAK,CAAC,CAAC,OAAO;AAC3C;AAEO,SAAS,2BAA2B,MAAsB;AAC/D,SAAO,KAAK,UAAU,KAAK,YAAY,KAAK,SAAS,GAAG,IAAI,MAAM,GAAG,IAAI,GAAG,KAAK,MAAM;AACzF;AAEO,SAAS,kCAAkC,EAAE,KAAK,GAA4B;AACnF,SAAO,2BAA2B,IAAI;AACxC;AAEA,MAAM,gCAAgC,wBAAwB;AAEvD,SAAS,2CAA2C,EAAE,KAAK,GAA4B;AAC5F,SAAO,KAAK,UAAU,6BAA6B;AACrD;AAEO,SAAS,wCAAwC,MAAsB;AAC5E,SAAO,KAAK,QAAQ,UAAU,GAAG;AACnC;AAEO,SAAS,6BAA6B,QAAiC;AAC5E,SAAO,wCAAwC,2CAA2C,MAAM,CAAC;AACnG;AAEO,SAAS,iBACd,SACA,EAAE,KAAK,GACa;AACpB,MAAI,SAAS;AACX,eAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,OAAO,GAAG;AACpD,UAAI,KAAK,SAAS,IAAI,GAAG;AACvB,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/SharedStorage.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { $Refs } from '@apidevtools/swagger-parser';
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
|
-
import type {
|
|
4
|
-
import type { SourceFile } from 'typescript';
|
|
3
|
+
import type { SourceFile, TypeNode } from 'typescript';
|
|
5
4
|
|
|
6
|
-
type
|
|
7
|
-
|
|
5
|
+
export type TransferTypeMaker = (typeArguments: readonly TypeNode[] | undefined) => TypeNode;
|
|
6
|
+
|
|
7
|
+
export type TransferTypes = Map<string, TransferTypeMaker>;
|
|
8
|
+
|
|
9
|
+
export type SharedStorage = Readonly<{
|
|
10
|
+
api: OpenAPIV3.Document;
|
|
8
11
|
apiRefs: $Refs;
|
|
9
|
-
sources: SourceFile[];
|
|
10
|
-
pluginStorage: Map<string, unknown>;
|
|
11
12
|
outputDir?: string;
|
|
13
|
+
pluginStorage: Map<string, unknown>;
|
|
14
|
+
sources: SourceFile[];
|
|
15
|
+
transferTypes: TransferTypes;
|
|
12
16
|
}>;
|
|
13
|
-
|
|
14
|
-
export default SharedStorage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-generator-core",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.7.0-alpha11",
|
|
4
4
|
"description": "A Hilla tool to generate TypeScript code from the OpenAPI document",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
"build:copy": "cd src && copyfiles **/*.d.ts ..",
|
|
16
16
|
"lint": "eslint src test",
|
|
17
17
|
"lint:fix": "eslint src test --fix",
|
|
18
|
-
"test": "
|
|
19
|
-
"test:coverage": "
|
|
18
|
+
"test": "vitest --run",
|
|
19
|
+
"test:coverage": "vitest --run --coverage",
|
|
20
|
+
"test:watch": "vitest",
|
|
20
21
|
"typecheck": "tsc --noEmit"
|
|
21
22
|
},
|
|
22
23
|
"exports": {
|
|
@@ -43,9 +44,6 @@
|
|
|
43
44
|
},
|
|
44
45
|
"./SharedStorage.js": {
|
|
45
46
|
"types": "./SharedStorage.d.ts"
|
|
46
|
-
},
|
|
47
|
-
"./utils.js": {
|
|
48
|
-
"default": "./utils.js"
|
|
49
47
|
}
|
|
50
48
|
},
|
|
51
49
|
"repository": {
|
|
@@ -71,26 +69,10 @@
|
|
|
71
69
|
"access": "public"
|
|
72
70
|
},
|
|
73
71
|
"dependencies": {
|
|
74
|
-
"@apidevtools/swagger-parser": "
|
|
75
|
-
"@vaadin/hilla-generator-utils": "24.
|
|
76
|
-
"meow": "
|
|
77
|
-
"openapi-types": "
|
|
78
|
-
"typescript": "5.7.
|
|
79
|
-
},
|
|
80
|
-
"devDependencies": {
|
|
81
|
-
"@types/chai": "^4.3.6",
|
|
82
|
-
"@types/mocha": "^10.0.2",
|
|
83
|
-
"@types/node": "^20.7.1",
|
|
84
|
-
"@types/sinon": "^10.0.17",
|
|
85
|
-
"@types/sinon-chai": "^3.2.10",
|
|
86
|
-
"c8": "^10.1.2",
|
|
87
|
-
"chai": "^4.3.10",
|
|
88
|
-
"concurrently": "^8.2.1",
|
|
89
|
-
"copyfiles": "^2.4.1",
|
|
90
|
-
"mocha": "^10.8.2",
|
|
91
|
-
"monocart-coverage-reports": "^2.11.5",
|
|
92
|
-
"sinon": "^16.1.3",
|
|
93
|
-
"sinon-chai": "^3.7.0",
|
|
94
|
-
"type-fest": "^4.3.2"
|
|
72
|
+
"@apidevtools/swagger-parser": "10.1.1",
|
|
73
|
+
"@vaadin/hilla-generator-utils": "24.7.0-alpha11",
|
|
74
|
+
"meow": "13.2.0",
|
|
75
|
+
"openapi-types": "12.1.3",
|
|
76
|
+
"typescript": "5.7.3"
|
|
95
77
|
}
|
|
96
78
|
}
|
package/File.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Blob, type BlobOptions } from 'node:buffer';
|
|
2
|
-
import type { BinaryLike } from 'node:crypto';
|
|
3
|
-
export type FileOptions = Readonly<BlobOptions & {
|
|
4
|
-
lastModified?: number;
|
|
5
|
-
}>;
|
|
6
|
-
export default class File extends Blob {
|
|
7
|
-
#private;
|
|
8
|
-
constructor(fileBits: Array<BinaryLike | Blob>, fileName: string, options?: FileOptions);
|
|
9
|
-
get name(): string;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=File.d.ts.map
|
package/File.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["src/File.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG,QAAQ,CAChC,WAAW,GAAG;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CACF,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,IAAI;;gBAGxB,QAAQ,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;IAKvF,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
package/File.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Blob } from "node:buffer";
|
|
2
|
-
class File extends Blob {
|
|
3
|
-
#name;
|
|
4
|
-
constructor(fileBits, fileName, options) {
|
|
5
|
-
super(fileBits, options);
|
|
6
|
-
this.#name = fileName;
|
|
7
|
-
}
|
|
8
|
-
get name() {
|
|
9
|
-
return this.#name;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
File as default
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=File.js.map
|
package/File.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/File.ts"],
|
|
4
|
-
"sourcesContent": ["import { Blob, type BlobOptions } from 'node:buffer';\nimport type { BinaryLike } from 'node:crypto';\n\nexport type FileOptions = Readonly<\n BlobOptions & {\n lastModified?: number;\n }\n>;\n\nexport default class File extends Blob {\n readonly #name: string;\n\n constructor(fileBits: Array<BinaryLike | Blob>, fileName: string, options?: FileOptions) {\n super(fileBits, options);\n this.#name = fileName;\n }\n\n get name(): string {\n return this.#name;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAA8B;AASvC,MAAO,aAA2B,KAAK;AAAA,EAC5B;AAAA,EAET,YAAY,UAAoC,UAAkB,SAAuB;AACvF,UAAM,UAAU,OAAO;AACvB,SAAK,QAAQ;AAAA,EACf;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/utils.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type Nullified<T, K extends keyof T> = T & {
|
|
2
|
-
[P in K]: undefined;
|
|
3
|
-
};
|
|
4
|
-
export declare function simplifyFullyQualifiedName(name: string): string;
|
|
5
|
-
export declare function convertFullyQualifiedNameToRelativePath(name: string): string;
|
|
6
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,GAAG,SAAS;CAAE,CAAC;AAE1E,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAID,wBAAgB,uCAAuC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5E"}
|
package/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
function simplifyFullyQualifiedName(name) {
|
|
2
|
-
return name.substring(name.lastIndexOf(name.includes("$") ? "$" : ".") + 1, name.length);
|
|
3
|
-
}
|
|
4
|
-
const QUALIFIED_NAME_DELIMITER = /[$.]/gu;
|
|
5
|
-
function convertFullyQualifiedNameToRelativePath(name) {
|
|
6
|
-
return name.replace(QUALIFIED_NAME_DELIMITER, "/");
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
convertFullyQualifiedNameToRelativePath,
|
|
10
|
-
simplifyFullyQualifiedName
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=utils.js.map
|
package/utils.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["src/utils.ts"],
|
|
4
|
-
"sourcesContent": ["export type Nullified<T, K extends keyof T> = T & { [P in K]: undefined };\n\nexport function simplifyFullyQualifiedName(name: string): string {\n return name.substring(name.lastIndexOf(name.includes('$') ? '$' : '.') + 1, name.length);\n}\n\nconst QUALIFIED_NAME_DELIMITER = /[$.]/gu;\n\nexport function convertFullyQualifiedNameToRelativePath(name: string): string {\n return name.replace(QUALIFIED_NAME_DELIMITER, '/');\n}\n"],
|
|
5
|
-
"mappings": "AAEO,SAAS,2BAA2B,MAAsB;AAC/D,SAAO,KAAK,UAAU,KAAK,YAAY,KAAK,SAAS,GAAG,IAAI,MAAM,GAAG,IAAI,GAAG,KAAK,MAAM;AACzF;AAEA,MAAM,2BAA2B;AAE1B,SAAS,wCAAwC,MAAsB;AAC5E,SAAO,KAAK,QAAQ,0BAA0B,GAAG;AACnD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|